# User Guide ## What This Tool Does Strategy Generator Studio helps you search for rule-based long-only trading strategies on Yahoo Finance market data. It generates candidate entry and exit rules, backtests them, scores them, optionally applies credibility checks, and produces dashboards plus exported strategy files. The tool is designed for research, comparison, and idea generation. It is not a live-trading engine. ## Who This Guide Is For Use this guide if you want to: - run the desktop app - understand each setting in the UI - interpret ranked results and fallback results - find the files generated by a research run - troubleshoot empty or weak result sets ## Installation ### Requirements - Python 3.10 or newer - Internet access for Yahoo Finance downloads - TA-Lib installed and importable from Python ### Python Packages Install the main Python packages with: ```bash pip install pandas numpy matplotlib yfinance PyQt5 TA-Lib ``` If `TA-Lib` fails to install, install the platform-specific binary or native library first, then retry `pip install TA-Lib`. ## Starting the App From the project folder run: ```bash python strategy_gui.py ``` The main window is divided into: - a top action bar - a left control panel - a right results panel ## Typical Workflow 1. Choose a ticker, period, and interval. 2. Pick `Random search` or `Grid search`. 3. Adjust risk, validation, and weekly ranking settings. 4. Choose a reports folder. 5. Click `Run Research`. 6. Review the ranked table and dashboards. 7. Open exported strategy scripts for the best candidates. ## UI Sections ### 1. Market Data ### Ticker Examples: - `ETH-USD` - `BTC-USD` - `AAPL` - `SPY` ### Period Examples: - `60d` - `365d` - `730d` - `5y` This controls how much historical data is requested from Yahoo Finance. ### Interval Common values: - `1h` - `60m` - `1d` Choose an interval that matches the style of strategy you want to research. ### 2. Discovery Mode ### Random Search Random search samples fresh strategy specifications until it reaches: - `max_attempts`, or - `target_valid_strategies` passing candidates Best when: - you want variety quickly - full grid search would be too large - you are experimenting with parameters ### Grid Search Grid search combines ranked entry combos with a controlled set of exit variants. Best when: - you want repeatable comparisons - you want coverage of the predefined combo universe ### Discovery Controls #### Max attempts Upper bound on random search attempts. #### Target valid strategies How many passing strategies random mode tries to collect before stopping. #### Entry conditions per strategy How many entry clauses to combine in random mode. #### Exit conditions per strategy How many exit clauses to combine in random mode. #### Random seed Makes random search more reproducible. #### Grid exit variants How many exit rule combinations to pair with entry rules in grid mode. ### 3. Strategy Engine ### Strategies to rank Used when grid mode is active and `Ignore limit and use all generated combos` is off. ### Dashboards to export How many top strategies receive HTML dashboards. ### Ignore limit and use all generated combos When enabled, the engine evaluates the entire generated grid instead of sampling a subset. ### Use credibility screen When enabled, strategies must pass the weekly and validation filters to count as ranked. If no strategy passes, the app can still generate fallback dashboards for the strongest screened-out candidates. ### Enter on next open If enabled, entries are executed on the next bar open instead of the current close. ### 4. Risk Model ### ATR period ATR lookback used by stop-loss and take-profit logic. ### Stop loss ATR multiple Distance from entry to stop-loss in ATR units. ### Take profit ATR multiple Distance from entry to take-profit in ATR units. ### Fees (bps) Transaction cost in basis points per side. ### Minimum trades Used as part of ranking and credibility checks. ### Max drawdown floor Strategies whose drawdown is worse than this threshold fail the screen. Example: - `-0.20` means maximum allowed drawdown is -20% ### Max holding bars Optional time stop. `0` disables it in the GUI. ### Trailing stop Optional trailing stop as a percentage. `0` disables it in the GUI. ### Assume stop-loss when SL and TP hit same bar Conservative same-bar assumption when both stop and target are touched. ### Force close any open trade on final bar Closes remaining positions on the last available data bar. ### 5. Validation and Export ### Require in-sample, out-of-sample, and holdout pass Enables three-phase validation. The default split is: - 60% in-sample - 20% out-of-sample - 20% holdout ### Validation split Enter three positive numbers separated by commas. Example: ```text 0.60,0.20,0.20 ``` ### Max one-trade profit share Rejects strategies where a single winning trade dominates total profits too heavily. ### Max IS-to-holdout drop Rejects strategies whose holdout performance drops too sharply relative to in-sample performance. ### Standalone files to export Number of individual Python strategy files to export for the strongest candidates. ### 6. Weekly Ranking This section is central to how strategies are compared. ### Evaluation horizons (years) Comma-separated list such as: ```text 1,3,5 ``` The engine evaluates the strategy on trailing slices of that length when enough history exists. ### Minimum weeks per window Minimum number of weekly observations required for a horizon to count. ### Minimum valid horizons How many valid horizons are needed for the weekly aggregation to count. ### History coverage threshold Prevents a horizon from being used when too little data exists. Example: - `0.90` means the dataset must contain at least 90% of the requested horizon ### Weekly resample rule Controls how weekly returns are grouped, for example `W-FRI`. ### 7. Output ### Base reports folder Each run creates a new timestamped subfolder inside the selected base folder. ## Understanding the Results Panel ### Top Metrics The top cards summarize the latest run: - best score - average weekly return of the top strategy - negative week rate - ranked strategies count - overfit risk - horizons used - output folder - dataset span ### Result Modes The table can show different kinds of outputs: ### Ranked Strategies Shown when strategies pass the credibility screen. ### Screened-Out Strategies Shown when the credibility screen rejects everything. In this case the app surfaces the strongest rejected candidates and can still generate fallback dashboards. This is useful when: - the filters are too strict - the market regime is poor for the current rule universe - the history is too short for the requested evaluation settings ## What the Dashboards Show Each strategy dashboard includes: - summary cards - performance overview plot - annual comparison plot - monthly return heatmap - trade outcome analysis - compact recent-trades table - strategy logic - benchmark-relative metrics The dashboard index page shows a narrower research-style summary of the exported strategies. ## Output Files Each run usually creates these files: ### Core Reports - `strategies_report.csv`: raw run results - `strategies_report_with_meta.csv`: raw results plus run metadata - `top30_by_score.csv`: top passing candidates by score ### Ranked Candidate Files - `credible_candidates.csv`: strategies that passed the credibility screen - `ranked_candidates.csv`: ranked candidates when the screen is off - `screened_out_candidates.csv`: evaluated but rejected strategies - `fallback_ranked_candidates.csv`: strongest rejected strategies used for fallback dashboards ### Dashboards - `dashboards/index.html` - `dashboards/top_ranked_table.csv` - `dashboards/*.html` - `dashboards/assets/*.png` ### Exported Strategy Scripts Saved under: ```text reports/output// ``` These scripts are standalone reproductions of selected strategies. ## How to Read Strategy Quality No single metric is enough. Start with: 1. trade count 2. max drawdown 3. holdout performance 4. weekly negative rate 5. overfitting risk score Useful signs: - enough trades to matter - positive holdout return - manageable drawdown - reasonable weekly consistency - no single trade dominating performance Warning signs: - very few trades - strong in-sample result but weak holdout - large drawdown - negative weeks dominating - strategy only looks good because of one outlier trade ## Recommended Starting Presets ### Hourly Crypto Exploration - Ticker: `ETH-USD` - Period: `730d` - Interval: `1h` - Mode: `Random search` - Max attempts: `500-2000` - Target valid strategies: `10-25` - Use credibility screen: on ### Daily Equity Exploration - Ticker: `SPY` - Period: `5y` - Interval: `1d` - Mode: `Grid search` - Use credibility screen: on - Evaluation horizons: `1,3,5` ## Troubleshooting ### No ranked strategies Try one or more of: - lower `Minimum trades` - relax `Max drawdown floor` - reduce `Minimum valid horizons` - reduce `Minimum weeks per window` - lower `History coverage threshold` - disable three-phase validation temporarily - switch to fallback dashboards and inspect screened-out reasons ### Horizons are skipped Your dataset is too short for the requested evaluation windows given the coverage threshold. Solutions: - shorten the horizons - request a longer period - lower history coverage threshold ### Very slow run Causes: - too many grid combinations - long history at fine intervals - all-combos mode enabled Mitigations: - reduce `Strategies to rank` - reduce `Grid exit variants` - shorten the data period - switch to random search ### Strategy file does not open The strategy export only exists when a candidate was selected for export and the file was successfully written. ### Yahoo Finance returns no data Check: - ticker spelling - period/interval combination - network access ## Important Limitations - Long-only backtest only - Single-position logic - Yahoo Finance data quality depends on source availability - No slippage model beyond configured fees - Rule language is limited to implemented parser patterns - This is a research environment, not execution infrastructure ## Best Practice - use dashboards to compare, not to over-trust - inspect holdout and weekly behavior, not just headline score - export only a few top candidates first - rerun with different assets and periods before trusting a pattern