Binance Auto Trader
user manual
We have configured it so that even first-time installers can follow the instructions in order from connecting API to backtesting and starting actual trading. Everything you need is in this HTML file and it will open even without an internet connection.
If this is your first time, just follow these steps
Binance Auto Trader categorizes market conditions in the Binance USDⓈ-M futures market, Trend Following class Mean Reversion Execute your strategy automatically. It is important not to start with actual trading immediately after turning on the program, but to follow the order below.
The fastest way to read this manual
- First-time user: Sign up · API settings → First execution sequence → Backtest step 3 → Live trading check
- Operating User: Trading Settings → Screen Panel → Trade History → Troubleshooting
- User adjusting strategy: Regime → TF/MR → Position Sizing → Backtest Engine
Sign up for Binance and set up API
1. Prepare a Binance account
at the top of the program Sign up for Binance Click the button to open the signup page. Complete account creation, identity verification, and USDⓈ-M Futures activation in order. If you already have an account, skip this step.
2. Generate API Key on Binance
- 1Open API Management
Go to the API management screen of your Binance account. - 2Create new API
Give it a friendly name and complete the security authentication. - 3Key and secret storage
A Secret can only be displayed once, immediately after creation, so keep it in a safe place. - 4Permission settings
It only enables reading and Futures trading permissions, but does not enable withdrawal permissions.
API permission check
| Permission | Required? | Notes |
|---|---|---|
| Enable Futures | Required | Check on Binance API management page |
| Enable Reading | Required | View balances and positions |
| Enable Spot & Margin Trading | Not required | Recommended to disable as it is for Spot trading |
| Enable Withdrawals | Never enable | No need for automated trading |
| IP restrictions | Highly recommended | Allow list registration when a 24-hour operating PC has a static IP |
3. Enter API into the program
- 1at the top of the program API Settings Press the button.
- 2API Key and Secret Key Paste . Secret is masked on the screen.
- 3When you first practice Testnet Select and enter the testnet-specific key. The live trading key and testnet key are different.
- 4After saving, check the connection status and balance display in Account Dashboard.
.env file manually. API credentials and the Testnet selection are saved from the API Settings window.First run order
- 1run program
Run your distribution executable or the latest Python file. Make sure the window title is the current distribution version. - 2Check API connection
API Settings Save the key and check that the balance appears in Account Dashboard. - 3Setting market and excluded items
Select the target among CRYPTO / TRADFI / ALL and enter trading restricted or unwanted items one line at a time in Excluded Symbols. - 4Check Cache Manager
The initial candle download continues in the background. Trading can begin once the latest data is available, but it is better to run long-term backtests only after the cache for the required period is ready. - 5Execute 3 steps of backtesting
Find candidates with sweep and check for over-optimization with validation and walk-forward. - 6Apply recommended settings and check again
After clicking Apply Best Settings, directly check whether the Market, Top N, Timeframe, and regime-specific parameters are reflected in the Trading tab as intended. - 7Start with Testnet or a small amount
Start Auto Trade Press and check Log, Current Top N, Open Positions, and Trade History together.
Recommended starting value (conservative)
| parameters | Recommended value | reason |
|---|---|---|
| Decision TF | 15m | For direction/trend judgment. Determine EMA, ADX, Volume, Regime, RSI Exhaustion |
| Execute TF | 5m | For actual entry timing. Order only when a Donchian breakout occurs in the same direction as the decision. |
| Trailing TF | 5m | If set to shorter or equal to Decision/Execute TF, trailing responds quickly. |
| Leverage | 3 ~ 5 | If it exceeds 5 times, the risk of forced liquidation increases rapidly due to volatility. |
| Risk % | 0.25 ~ 0.5 | Only 0.25~0.5% of the balance is consumed by stopping one position. 0.25 recommended initially |
| Max Position % | 10 ~ 15 | 1 position notional cap. If it is too large, there is a risk of balance imbalance. |
| ATR Mult | 1.5 ~ 2.0 | If it is low, the stop loss is too narrow and frequent stop losses occur. |
| EMA Gap % | Separation rate (%) of EMA20 and EMA60. LONG is allowed to enter Trend Following only when it is above the EMA Gap, and SHORT is only below the -EMA Gap. 0 disables the filter. | Not used in Mean Reversion. |
| Trigger R | 1.0 ~ 1.5 | Activate trailing after achieving 1R profit — Minimize stop loss before entering profit zone |
| Regime active | NORMAL + TREND | Initial operating standards. The final value is determined by the results of a backtest performed by the user. |
Cache Manager
The program uses Parquet-based candle cache. When running for the first time, the necessary candles are built in the background, and thereafter only newly closed candles are incrementally updated.
How it works
- 1Check manifest
When the program starts, it reads manifest.json to immediately check the cache status for each symbol. The manifest is a lightweight index (65KB level) that stores only the first and last candle times of each symbol. - 2Trading first
Automated trading can begin immediately after obtaining the latest data, and the rest of the history continues to be built in the background. - 3Periodic incremental updates
We periodically add 4h candles for selected Decision / Execute / Trailing TF and Dynamic TopN volume ranking. After the update is finished, it waits until the next deadline, so the next update is not queued during long downloads. - 4Backtest API Skip
When running a backtest, the manifest is loaded into memory and an O(1) freshness check is performed for each symbol. If the cache is fresh, only the parquet file is read and returned without calling API. After the cache build is complete, API calls are reduced to 0 in the iterative backtest. - 5safe storage
Protect existing caches even during shutdown using Atomic Write (.tmp→rename). The manifest is saved in batches up to twice at the end of the backtest pass.
| Metric | explanation |
|---|---|
| Status | Initial Build: No cache, first downloading matching 365 Updating: Existing cache present, adding new candle increments Ready: Construction completed Error: Network error, etc. |
| Progress | Number of (symbols × intervals) processed / total. Example: 490 / 1058 (46%) |
| Cache Hit | The manifest covers the number of reads directly from local files without calling API. |
| API Download | The number of downloads by calling the actual API without covering the manifest. |
| Errors | Number of download failure symbols. Displayed only when an error occurs. Skip that symbol and continue |
| Mode | 365-day initial download: First construction background append: Periodic incremental update 4h volume cache: Pre-updated 4-hour bar for Dynamic TopN volume ranking |
| Next Update | When the next automatic incremental update is due. After the update is complete, wait until the next closing bar of each interval. |
| Cache Size | Local cache directory total size |
| Last Sync | Last incremental update completion time |
/fapi/v1/klines) is used. Even if the API key is not set, the cache will be built normally as long as you have an Internet connection.4h Candlesticks are also built in advance and updated incrementally in the background. When Sweep is executed, Pass 1 is mostly processed as a local parquet/manifest read rather than a API download, and only the insufficient sections are downloaded to make up for it.- Added Top N panel (shows current Top N symbols)
- Currently owned Top N stocks are highlighted in bold blue letters.
- Added Excluded Symbols panel (enter one symbol per line)
- Excluded Symbols are applied equally to live trading, backtesting, validation, and walk-forward.
- Improved Log/Top N/Cache Manager layout
- OPEN status in Trade History shows both date and time
Trading tab
All settings for live automated trading are concentrated in this tab. Setting fields are disabled during automated trading.
default settings
| parameters | default | range | explanation |
|---|---|---|---|
| Top N Symbols | 30 | 10~50 | Top N stocks with 24h trading volume are selected for scanning. The bigger it is, the greater the opportunity for entry.·API load increases. The symbol universe automatically updates every 4 hours. |
| Market Universe | CRYPTO | CRYPTO / TRADFI / ALL | CRYPTO: Coin Futures Top N TRADFI: Gold, stocks, ETF, etc. TRADFI futures Top N ALL: Top N trading volume combining two markets |
| Decision TF | 15m | 1m~4h | Candlestick timeframe for judging entry signals. The shorter the signal, the higher the signal frequency and the more noise. Only the completed candle (closed candle) is used for signal judgment. |
| Trailing TF | 5m | 1m~15m | Timeframe for calculating Trailing Stop ATR. Trailing responds faster when set shorter than Decision TF. |
| Leverage | 5 | 1~20 | Futures leverage multiple. Automatically set to the exchange upon entry. Both profits and losses are multiplied. 5x or less is strongly recommended. |
| Risk % | 1.0 | 0.1~5.0 | Maximum amount lost when stop loss is activated in one position = Total balance × Risk%. If you do not specify a risk% for each regime, this value will be used as the default fallback. |
| Max Long Pos. | 5 | 1~20 | Maximum number of LONG positions held simultaneously. When the limit is reached, entering a new LONG is skipped. |
| Max Short Pos. | 5 | 1~20 | Maximum number of SHORT positions held simultaneously. Independent management with LONG. |
| Max Position % | 20 | 5~100 | Notional limit for 1 position = Total balance × Max Position% × Leverage. Use the smaller of the Risk reference quantity and this upper limit. |
3-TF Entry Engine
The Trend Following strategy uses a three-step timeframe structure that separates judgment and execution. The Decision TF authorizes direction, the Execute TF confirms the actual entry timing, and the Trailing TF manages position close after entry.
| division | role | Usage Metrics | example |
|---|---|---|---|
| Decision TF | Determination of trade direction and entry permission | EMA, ADX, Volume, Regime, RSI Exhaustion | Determine LONG/SHORT direction at 15m |
| Execute TF | Check live order timing | Donchian High/Low Breakthrough | Enter when there is a breakthrough in the same direction at 5m. |
| Trailing TF | Exit and trailing-stop management after entry | ATR Trailing, Exit Mode | Stop update based on 5m ATR |
Regime Settings
Strategies and parameters are set independently for each regime (QUIET · NORMAL · TREND · PANIC). If checkbox OFF is checked, there will be no new entries in that regime.
| parameters | Trend Following | Mean Reversion |
|---|---|---|
| Strategy | trend_following (breakout trend following) | mean_reversion (mean reversion) |
| ADX ADX Min / ADX Max |
ADX Min: Minimum trend strength allowed for entry. If ADX < this value, entry is ignored. If it is low, the signal increases / false signal ↑ | ADX Max: Maximum trend strength allowed for entry. ADX > Ignore entry if this value (block entry into trend market) |
| ATR Mult | commonness. Stop Loss = Entry ATR × ATR Mult. If it is low, there will be frequent stop losses / if it is high, the loss will increase with one stop loss. | |
| Vol Mult / RSI Entry |
Vol Mult: Trading volume > Volume MA × Vol Mult. If it is low, the frequency of entry increases. | RSI Entry: LONG: RSI ≤ this value / SHORT: RSI ≥ (100 − this value). If it is low, only extreme oversoldness is captured. |
| Trigger R / BB Sigma |
Trigger R: Trailing activation distance = Stop loss × Trigger R. If it is low, trailing starts at the beginning of profit. | BB Sigma: Bollinger Band Bandwidth multiple (σ). Basic 2.0. If it is low, the frequency of entry increases. |
| Risk % | Position size adjustment by regime. If not entered, use the default Risk% setting. | |
| Exit Mode | Choose trailing/partial_tp/fast_exit (see comparison below) | BB Mid / trailing / partial_tp / fast_exit selectable. BB Mid uses BB Middle at the time of entry as the target price, and the remaining modes use the same exit method as Trend Following. |
Exit Mode Comparison
| Exit Mode | movement | characteristic | Recommended regime |
|---|---|---|---|
| trailing | Close only with stop loss or trailing stop. No separate TP | Long-term tracking of strong trends is possible. Risk of return of profits in case of sideways movement | NORMAL, TREND |
| partial_tp | When the 1R goal is reached, 50% partial close → Trailing of the remaining 50% continues. RSI 50% position close in advance even when overbought/oversold | Certain profits + additional profits if the trend continues. balanced | NORMAL |
| fast_exit | Close the entire amount as soon as the 1R goal is reached. No trailing | Quick confirmation of profits in areas of rapid change. Big trends can be missed | PANIC |
| BB Mid | Mean Reversion only. When the BB middle band (SMA20) is reached, all profits are lost. | Mean reversion goal achieved and closed. Set target to BB Mid at entry point | QUIET (recommended) |
CI Filter (optional)
Use Choppiness Index (CI) to block trend following entry in sideways movements. Does not apply to Mean Reversion strategies.
| setting | explanation |
|---|---|
| CI Filter ON | CI < 61.8 condition added. TF entry is blocked at CI ≥ 61.8 (sideways section) |
| Period | CI calculation lookback period (number of bars). Default value 14. The shorter it is, the faster the response and the higher the noise. The longer it is, the more stable it is and the delay in entering the trend. |
Server Stop (Server-side STOP_MARKET)
When entering a position, the Binance server Order STOP_MARKET automatically registers. Even in situations where the bot process is down or the network is down, the exchange will execute the stop loss on your behalf.
| movement | explanation |
|---|---|
| Register upon entry | STOP_MARKET order is automatically registered on Binance immediately after position opening. workingType=MARK_PRICE Use — Prevent unreasonable position close with Last Price spikes |
| Updated when moving to trailing | Each time the trailing stop moves, cancel the existing order and re-register at the new price. Server stop prices are always synchronized with the latest trailing stop |
| Cancellation upon local position close | When the bot closes a position (STOP, TRAILING_TAKE, TIME_EXIT, etc.), the server stop order is also canceled. No orphan orders left after position close |
| Cancellation during Emergency Close | When you click the [Emergency Close All] button, the server stop for each position is canceled first and then the position is closed at market. |
| Cancellation when an external close is detected | If the position disappears without the bot's knowledge (manual close, etc.), the server stop is automatically canceled in the next monitor cycle. |
| Restore after restart | Saved on restart server_stop_order_id If there is no server stop, automatic re-registration (repair path) |
reduceOnly=true It is registered as . Even if the server stop quantity after partial close is greater than the actual remaining amount, excess positions will not be opened because Binance will close only the remaining amount.[SERVER STOP ERROR] A log is recorded and the local stop monitor continues to operate. However, if the bot is offline and there is no server stop, stop loss will not be executed.Suspension/Emergency Position Close
| button | movement | caution |
|---|---|---|
| Stop | New entry halted. Existing positions continue to be automatically managed | Safe exit possible while maintaining position |
| Emergency Close All | First cancel the server STOP_MARKET order for each position, then immediately close all positions on the exchange at market price reduce-only | Slippage may occur in volatility sections |
Trading screen panel
During live trading, you will check the status panel more often than the settings. You can quickly determine the current program status by learning just the four areas below.
| panel | what does it show | confirmation point |
|---|---|---|
| Account Dashboard | Balance, P&L, number of positions, connection status | Immediately after connecting API, first check if the balance is correct. |
| Open Positions | Current direction, entry price, current price, Stop, PnL | Comparison of quantity and direction with the actual position of the exchange |
| Current Top N | Scanned stocks based on current 24-hour trading volume and last update time | Owned stocks are highlighted in bold blue letters. List updated every 4 hours |
| Log | Universe update, signal, order, stop, position close, error | Don't just look at ERROR, check the previous SIGNAL/OPEN flow chart as well. |
| API Monitor | REST call, WebSocket, User Data Stream status | Call spike, WS SILENT, check for repeat reconnection |
Excluded Symbols
Enter the symbols you want to exclude from automated trading, one per line. yes: BTCUSDT. The saved list applies not only to live trading but also to sweep, validation, and walk-forward.
Start · Stop · Emergency Close
| button | movement | When to use |
|---|---|---|
| Start Auto Trade | Start new signal search and position management with set values | After checking all settings, API, and balance, |
| Stop | Stop new entries and continue to manage existing positions | When safely stopping a program or preventing new entry |
| Emergency Close All | After canceling the server stop, all positions are closed at market price. | Only in emergency situations where normal stopping is difficult |
Trade History
It shows entry, position close, and realized profit and loss based on the trades managed by the program and Binance conclusion history. When you run the program again, it will load the last three days of Binance trades to supplement your history.
| Metric | explanation | How to check |
|---|---|---|
| OPEN | Currently open trades. Open Time displays date and time together | Open Positions and Symbol/Direction Contrast |
| CLOSED | Trade confirmed to be closed | Check Exit Reason and Fill Price |
| Realized PnL | Realized profit and loss based on Binance conclusion | May differ from simple price difference calculation due to fees and multiple partial trades |
| SERVER STOP | Closed with STOP_MARKET order on Binance servers | Synchronizes after restart even if the program was signed while it was turned off |
| Exit Reason | STOP, TRAILING_TAKE, TIME_EXIT, FAST_EXIT, etc. | When analyzing strategy results, separate performance by reason and check |
Backtest Sweep Tab
Batch test multiple parameter combinations to explore optimal parameters for each regime. Sweep is the step of testing each regime independently to find candidate settings, and verification of actual time-base adaptive performance is performed in the Validation tab.
Sweep method
Example: QUIET (3 combinations) + NORMAL (12 combinations) + TREND (6 combinations) =Total 21 times Run (21 = 3 + 12 + 6)
Enter parameter list
If you enter multiple values separated by commas (,) in each parameter field, they will be tested as the Cartesian Product of that regime.
# Example: NORMAL regime ADX Min: 20, 25, 30 ATR Mult: 1.5, 2.0 Vol Mult: 1.2 Trigger R: 1.0, 1.5 Risk %: 0.5 # NORMAL Number of combinations: 3 × 2 × 1 × 2 × 1 = 12
Sweep setup parameters
| parameters | explanation |
|---|---|
| Days / Date Range | Backtest period. Recent Days (last N days) or date range can be specified directly |
| Top N | Number of stocks to use for backtesting. The more there are, the more statistical reliability and time increases. |
| Decision TF / Execute TF / Trailing TF | A three-step timeframe to use for backtesting. Same as actual trading, Decision is used to determine direction, Execute is used for entry timing, and Trailing is used for position close management. |
| Leverage / Wallet | Backtest leverage/virtual initial balance (USDT) |
| Market Universe | CRYPTO / TRADFI / ALL. Determine what to backtest scan |
| Regime checkbox | Whether to include the regime in the sweep |
Sweep Combos Card
This card appears on the right side of the Settings box. Based on the current input value, the number of combinations for each regime, the total, and the estimated time required are calculated in real time.
Adaptive Combined Result and Daily PnL Charts does not display .
Since the purpose of Sweep is not to verify performance but to explore candidate settings for each regime, actual Adaptive performance and daily profit and loss charts are checked in Validation.Interpretation of results
| characteristic | meaning | standard |
|---|---|---|
| PF (Profit Factor) | Total Profit / Total Loss | 1.3 or higher is excellent, less than 1.0 is lossable. |
| Net PnL | Net profit (including commissions) | Must be a positive number to be valid |
| Win Rate | Profit Trade Ratio (%) | Standards vary for each strategy. Interpretation with PF |
| MDD | Maximum Drawdown — Maximum drawdown. USDT absolute value class % from high point displayed together. Example: -234.50 (12.34%) | The lower the better. Caution if % exceeds 20% |
| Trades | Total number of trades | Less than 10 times, statistical reliability is low (INSUFFICIENT) |
| Score | PF×0.45 + Net PnL×0.30 + Trades×0.25 Normalized composite score | Based on top 10 rankings within the regime |
Apply Regime Best
After completing the sweep, click the [Apply Regime Best #1] button and the optimal parameters for each regime will be automatically applied to Regime Settings in the Trading tab.
Backtest Validation Tab
The best settings for each regime selected through sweep are verified using an adaptive method on the actual time axis. By reflecting Top N application, regime conversion, position limits, and profit and loss curve together, we confirm results that are close to actual operation.
Sweep vs Validation Comparison
| Metric | Sweep | Validation |
|---|---|---|
| purpose | Search for optimal parameters by regime | Verification of actual adaptive performance of selected settings |
| Calculation method | Test each regime independently and separately | Integrated execution reflecting Top N and time axis regime conversion |
| input | Parameter list (comma separated) | Single parameter value or Sweep Best applied value |
| result | Adaptive Regime Best Settings + Regime Best Top 10 Ranking | Adaptive Regime Best Settings + Adaptive Combined Result + Daily PnL Charts |
| use | initial navigation | Final confirmation and overfitting verification |
1. Select optimal parameters in sweep
2. Re-verification in another period (Out-of-Sample) with validation
3. If PF ≥ 1.2 or higher in both periods, consider actual operation
Regime Best Top 10 Ranking does not display .
Validation is a verification step, not a candidate search, so it is checked based on the actual Adaptive Combined Result and Daily PnL Charts.Walk-forward tab
Entered in the Validation tab single setpoint By repeatedly applying to multiple time intervals, we check how similar the in-sample (IS) performance remains in the out-of-sample (OOS). Walk-forward is not a function of finding profitable settings, but of the settings you have already chosen. Time base generalization stability This is a function to check.
Sweep·Validation·Walk-forward comparison
| function | purpose | settings source |
|---|---|---|
| Sweep | Exploring candidate settings in multiple combinations | Parameter list in Sweep tab |
| Validation | Verification of absolute performance of a single selected configuration | Current settings in the Validation tab |
| Walk-forward | Verification of IS/OOS performance similarity and stability of identical settings | Validation settings snapshot at execution time |
How it works
The entire period is divided by the specified number of windows, and the front part of each window is used as IS, and the back part is used as OOS. Calculate IS and OOS with the same validation settings, then compare the similarity of the two results.
# Fix once at run time Validation Settings Snapshot→ Commonly applied to all Windows W1→ IS calculation + OOS calculation → PF Similarity evaluation W2→ IS calculation + OOS calculation → PF Similarity evaluation W3→ IS calculation + OOS calculation → PF Similarity evaluation
Setting method
① Validation tab — Prepare a single setting to be validated
Enter the settings you want to validate in the Validation tab. You can apply the Sweep results, or use the settings entered directly by the user.
② Walk-forward tab — Period/Window settings
| Metric | explanation | Recommended value |
|---|---|---|
| Start date / End date | Entire analysis period | Set long enough to cover multiple market phases |
| Number of windows | Decide how many sliding sections the entire period will be divided into | 4 to 6 |
| IS rate (%) | The proportion of IS in each window. The rest is OOS | Around 70% |
Result Table Columns
| column | meaning | analysis |
|---|---|---|
| IS Trade / OOS Trade | Number of trades in each section | If the number of trades is too small, the reliability of PF/WR comparison is low. |
| IS PF / OOS PF | Profit Factor for each section | Absolute profitability is interpreted together with validation results |
| OOS MDD | OOS USDT·% display of maximum drop | Check the downside risks arising from OOS |
| IS WR / OOS WR | Win rate for each section | Used with PF |
| WR Δ | OOS WR − IS WR | The closer it is to 0, the more stable the win rate is. |
| Trade Ratio | OOS number of trades ÷ number of IS trades | Because the period length is different, it is for reference only for changes in signal density rather than for independent evaluation. |
| PF Similarity | min(OOS PF ÷ IS PF, IS PF ÷ OOS PF) × 100 | The closer it is to 100%, the more similar IS and OOS PF are. Even if OOS gets better, it does not exceed 100% |
| Generalization assessment | Automatic rating based on PF Similarity | IS/OOS similarity assessment, not absolute profitability |
| Validation Settings | Snapshot of settings fixed for this run | Used to reproduce results under what conditions |
Generalization evaluation criteria
| rating | PF Similarity | meaning |
|---|---|---|
| Excellent | More than 90% | IS and OOS performance are very similar |
| Good | More than 75% | Good generalization stability |
| Fair | More than 60% | Additional confirmation is required as there are differences. |
| Weak | More than 40% | IS/OOS performance deviation is large |
| Poor | less than 40% | Very large performance instability across time intervals |
last summary window
| Metric | explanation |
|---|---|
| Average PF Similarity | Average similarity of all windows |
| Lowest PF Similarity | The most unstable window similarity |
| OOS PF ≥ 1.0 Window | Number of windows for which OOS had the beneficial interest. Separate reference from generalization score |
| Generalization Risk | Risk that combines the similarity and lowest section of the entire window. lowness / middle / height Show color with |
Recommended Use Procedure
- 1Sweep
If necessary, explore candidate settings in multiple combinations. - 2Validation
See absolute performance including PF, Net PnL, MDD, number of trades, etc. for a single setup of your choice. - 3Walk-forward
Check PF Similarity and Generalization Risk of multiple Windows with the same validation settings. - 4final judgment
Validation When profitability is sufficient and walk-forward risk is low or acceptable, it is considered as a candidate for practical use.
run-time
Final check before live trading begins
If any of the items below are not confirmed, postpone starting actual trading.
- In the API settings, I selected live-trading mode and live trading API Key rather than Testnet.
- API has only Reading/Futures permission and no Withdraw permission.
- Account Dashboard balance and Binance Futures balance match.
- Sweep candidates were verified through validation and walk-forward at different periods.
- Even in the results including fees and slippage, PF, MDD, and number of trades are within the acceptable range.
- After Apply Best Settings, I checked the values for Market, Top N, TF, and regime again in the Trading tab.
- Trading restricted items and unwanted items were entered into Excluded Symbols.
- Start with conservative values such as Leverage 3 to 5 times, Risk 0.25 to 0.5%, and Max Position 10 to 15%.
- After starting, the live order, server stop, and position quantity are directly compared in the Binance app.
- You can log in to the Binance app to respond even in the event of an internet outage or program termination.
Market Regime Classification
At each closing time ATR% Calculate (= ATR ÷ current price × 100) and classify it into 4 regimes. Strategy and parameters are automatically switched depending on the regime.
Parameter tuning guide for each regime
| regime | ATR Mult | Reasons for recommendation |
|---|---|---|
| QUIET | 1.0 ~ 1.5 | Because it is a low-volatility zone, MR risk is limited with narrow stop losses. |
| NORMAL | 1.5 ~ 2.0 | Balance settings. Suitable for use with partial_tp |
| TREND | 2.0 ~ 2.5 | Prevent early stop loss by widening stop loss in strong trends |
| PANIC | 2.0 ~ 3.0 | Extreme volatility. However, since it is a fast_exit, there are many cases where the actual stop loss is not reached. |
Trend Following Strategy
Used in the NORMAL · TREND · PANIC regime. EMA cross + Donchian breakout + surge in trading volume + ADX filter Enter when all four conditions are met.
Usage Metrics
| characteristic | Calculation method | role |
|---|---|---|
| EMA 20 / 60 | Exponential moving average, period 20·60 | Determination of trend direction. EMA20 > EMA60 = Uptrend |
| ATR | SMA method, period 14 (not Wilder RMA) | Stop loss, trailing distance, Regime ATR% calculation |
| ADX | SMA method, period 14 | Trend strength filter. Entry must be ADX ≥ ADX Min |
| Donchian Channel | Highest/lowest price of the last 20 bars | Breakout signal. Closing price > Previous candle Donchian High → LONG |
| Volume MA | 20-period simple moving average | Volume surge filter. Volume > MA × Vol Mult |
| RSI | Wilder RSI, period 14 | partial_tp mode secondary exit signal (overbought/oversold) |
| CI | Choppiness Index, period 14 (default) | Optional. Blocks sideways entry when adding CI < 61.8 condition |
Entry conditions (4+1)
| condition | Enter LONG | Enter SHORT |
|---|---|---|
| ① Trend direction | EMA20 > EMA60 | EMA20 < EMA60 |
| ② Trend strength | ADX ≥ ADX Min | ADX ≥ ADX Min |
| ③ Rapid increase in trading volume | Volume > Volume MA × Vol Mul | Volume > Volume MA × Vol Mul |
| ④ Price breakthrough | Wanjeongbong closing price > Ijeonbong Donchian High | Dongwanbong closing price < previous peak Donchian Low |
| ⑤ CI filter(select) | Added when CI Filter is ON: CI < 61.8 | |
Trailing stop mechanism
Trailing TF When the bar standard ATR changes, the trailing distance is also dynamically updated.
Time Exit
After opening a position 72 hours After this period, compulsory position close will occur. It is a safety net that protects against cases where mean reversion fails over a long period of time.
Mean Reversion Strategy
Used in the QUIET regime (ATR% < 2, low volatility sideways). Entry occurs when all three conditions are met: Bollinger Band Breakout + RSI Oversold/Overbought + ADX Max Filter, and returns to the BB middle band (SMA20).
Usage Metrics
| characteristic | Calculation method | role |
|---|---|---|
| Bollinger Bands | 20 bars SMA ± BB Sigma × σ | Entry boundary: exit from the lower band (LONG) / exit from the upper band (SHORT). The middle band (SMA20) is the profit target. |
| RSI | Wilder RSI, period 14 | Oversold/overbought confirmation. RSI ≤ RSI Entry → LONG / RSI ≥ (100 − RSI Entry) → SHORT |
| ATR | SMA method, period 14 | Stop loss. Stop Loss = Entry Price ± ATR × ATR Mult |
| ADX | SMA method, period 14 | Upper limit filter for checking sideways movements. ADX ≤ ADX must be Max to enter |
Entry conditions (all 3)
| condition | LONG (oversold rebound) | SHORT (overbought and reversal) |
|---|---|---|
| ① ADX sideways movement confirmed | ADX ≤ ADX Max | ADX ≤ ADX Max |
| ② RSI oversold/overbought | RSI ≤ RSI Entry | RSI ≥ (100 − RSI Entry) |
| ③ BB band departure | Closing Price < BB Lower (= SMA20 − BB Sigma × σ) | Closing price > BB Upper (= SMA20 + BB Sigma × σ) |
Exit logic
Position Close priority
In the position monitoring loop, position close conditions are checked in the following order:
| priority | position close conditions | corresponding strategy |
|---|---|---|
| 1 | fast_exit: Close the entire amount when the 1R goal is reached | TF PANIC |
| 2 | partial_tp: 50% partial close when 1R is reached or RSI is overbought/oversold | TF NORMAL |
| 3 | When BB Mid is reached, all profits are lost. | MR QUIET |
| 4 | Time Exit: Retention exceeds 72 hours | strategy common |
| 5 | Stop/Trailing Stop: Price reaches stop loss (local monitor) | strategy common |
| Secondary protection | Server STOP_MARKET: Binance server runs directly when the bot is offline. Automatic cancellation during local position close to avoid overlapping with local position close | strategy common |
position sizing
Quantity is calculated based on two criteria and the smaller value is used as the final quantity.
• If the final quantity is less than the minQty of the exchange
• When the required margin exceeds 95% of the available balance
• If the same symbol already exists in a local position or on an exchange.
Calculation example
# Settings: Balance=1000 USDT, Risk%=0.5, ATR=50, ATR Mult=2.0 # Leverage=5, Max Position%=15, current price=2000 USDT stop loss = 50 × 2.0 = 100 USDT Risk standard quantity = (1000 × 0.5%) ÷ 100 = 0.05 units Quantity based on Cap = (1000 × 15% × 5) ÷ 2000 = 0.375 final quantity = min(0.05, 0.375) = 0.05 units # → Notional 0.05 × 2000 = 100 USDT / Margin = 100 ÷ 5 = 20 USDT
WebSocket & API Structure
PriceWebSocketManager
This is a mark-price WebSocket that only subscribes to currently held positions. Automatically resynchronizes subscriptions when you change positions.
| Metric | detail |
|---|---|
| Backend priority | websockets (async) → websocket-client (fallback) |
| Subscription method | Active-position only: Subscribe to bookTicker/markPrice only for stocks you own |
| SSL | cert_reqs=NONE (Response to certificate issues in some environments) |
| reconnect | When changing the subscription type, the existing connection is terminated → automatically reconnected to the new URL |
| price max_age | WS prices that have elapsed for more than 10 seconds are invalidated → REST fallback |
UserDataWebSocketManager (UDS)
Receive account events (position changes, order execution) in real time with the Binance User Data Stream.
| Metric | detail |
|---|---|
| purpose | REST Real-time detection of position changes without polling |
| Listen Key | Automatic issuance + keepalive renewal every 30 minutes |
| max_age | If there is no UDS event for more than 300 seconds, REST safety sync is performed. |
REST Fallback
If the WS connects but there is no payload for more than 5 seconds, DashboardThread takes a full price snapshot as REST. GLOBAL_PRICE_CACHE Supplements .
pip install websockets Check out .API Monitor
You can check the call status of API in real time in the API Monitor panel at the top of the Trading tab.
| characteristic | Display value example | Description and normal criteria |
|---|---|---|
| Health | 🟢 Healthy 🟡 Warning 🔴 Critical |
Comprehensive data reception status. Healthy= WS LIVE + price cache 90% or more + fallback 5 times or less. Warning= Partially normal. Critical= Unable to receive price |
| Data Source | LIVE / MIXED / REST / OFFLINE |
Pricing and account data source. LIVE= WS+UDS are all normal. MIXED= Mixed use of some REST. REST= Only REST without WS. OFFLINE= No data received |
| Price WS | 🟢 LIVE 🟡 Connected(No Data) 🔴 Disconnected |
Price WebSocket status. LIVE= Payload received within 5 seconds + cache over 80%. Connected(No Data)= Connected but payload not received → REST fallback in operation |
| UDS | 🟢 LIVE ● Connected ● Reconnecting |
User Data Stream status. LIVE= Connect + Receive event within 300 seconds. Connected= Connected but no event (normal when there is no trade). Reconnecting= Reconnecting |
| Price Cache | 28 / 30 (93%) | Number of stocks with current prices cached / Total number of stocks scanned (ratio). Anything over 90% is normal. If it is low, WS subscription is missing or REST fallback is insufficient. |
| Last Price | 1.2 sec waiting |
Price Cache Time elapsed since last update (including WS or REST fallback). Normal within 10 seconds. waiting= No price received yet |
| Last UDS | 42.3 sec no event yet waiting |
UDS (User Data Stream) Time elapsed since the last account event was received. It can get old without a trade — 300 decision within LIVE seconds. no event yet= Connected, but no events yet (normal). waiting= UDS not connected |
| REST/min | 45 (1.9%) | Number of calls to REST API in the last minute (ratio compared to Binance per minute limit of 2, 400). Beware of excessive calls when exceeding 10% |
| WS Msg/min | 120 | Number of price WS payloads received in the last minute. If 0, only WS connection is established and data is not received → REST fallback is in operation. Increases in proportion to the number of stocks held |
| REST Fallback/min | 0 / 3 | Number of times REST price was used instead of WS in the last minute. Normally 0 when WS LIVE, increases when WS is temporarily delayed. The value is automatically updated based on the last minute. Health is judged comprehensively not only by this value but also by Price WS, Cache Fill, and Price Age. |
| Reconnects | 2 | Cumulative number of WS reconnections. A small amount is normal (network is temporarily disconnected). If it continues to increase at a rapid rate, check the endpoint and firewall. |
| Last REST Sync | 38 sec - |
Elapsed time since the last REST safety sync (full position collation). UDS Automatically performed when the event gap becomes long. -= No sync yet |
| WS Version | 1.8.0 | Installed websocket-client version. Recommended version is 1.8.0. If there is a mismatch, output VERSION WARNING to the startup log. |
Troubleshooting
When there is no entry signal at all
| cause | Check/Resolve |
|---|---|
| Regime checkbox OFF | Check whether the checkbox for the relevant regime (NORMAL/TREND, etc.) is ON. |
| ADX Min is too high | If ADX is above 30, the signal may be rare. Search for optimal values with Sweep |
| Vol Mult too high | Trading volume explosion conditions are too strict. 1.2~1.5 range recommended |
| CI Filter transient blocking | Check signal occurrence after CI Filter OFF. In sideways markets, CI can always be high |
| Reach Max Positions | If the existing position has reached the Max Long/Short limit, new entry is skipped. |
| Top N too few | If there are too few stocks to scan, the chances of meeting the conditions are low. Increase Top N or switch TRADFI |
WS connection issues
| symptoms | solve |
|---|---|
| Price WS: SILENT | pip install websockets After restart. Without the websockets package, the websocket-client fallback causes payload not to be received in some environments. |
| Frequent reconnections occur | Check network stability and check if the Testnet/live trading selection in the API settings window matches the key. |
| UDS not connected | In the API settings window, check whether to save the key, Enable Futures permission, and IP restrictions. |
Position related
| symptoms | solve |
|---|---|
| [POSITION UNMANAGED] log | There is no stop information in the position state file (state/open_positions.json). The position needs to be restored by manual close or restart |
| Position disappears after restart | Check if open_positions.json exists in the state/ folder. Manual comparison with exchange status when file is damaged |
| Order omitted due to quantity calculation error | Insufficient balance or less than minQty for price. Increase balance or adjust leverage/Risk% |
| Attempts to repeatedly enter the same stock | Normal operation. Stocks already owned are automatically skipped. |
| [SERVER STOP ERROR] Repeat output | Binance STOP_MARKET registration failed due to error API. The local stop monitor continues to operate. Check whether API Key has Enable Futures permission. In case of network problem, automatic retry in the next cycle |
| Position Close recorded as SERVER_STOP_FILLED | Normal operation with Binance server stop while bot is offline. Automatically detects and records in the next monitor cycle after restart |
| Old STOP orders remain on Binance | Could be a previously created or orphaned stop order left behind by a crash. Recommended manual cancellation and bot restart in Binance app/web |
Backtesting is slow
Disable Apply Regime Best button
If the button is disabled even after the sweep is completed, backtest_results/parameter_sweep_summary.csv The file does not exist. Check the log to see if the sweep was completed normally.
Log interpretation
The format and meaning of messages displayed in the Log window are organized in chronological order. In the message {} Parts are replaced with actual values.
① At startup (Startup)
| log message | Meaning/Action |
|---|---|
| Strategy : universe=ALL, top_n=30, entry=15m, trailing=5m, ... | Output a summary of settings at startup. Verify that parameters are applied as intended |
| BASE_URL=https://fapi.binance.com | Check mainnet connection. If it is testnet testnet.binancefuture.com mark |
| Server time synced. offset={n} ms | Time synchronization with Binance server completed. If the offset is more than 1,000ms, beware of server time discrepancy. |
| API KEY / SECRET KEY missing in .env | error. No API information saved. Enter and save the Key and Secret in the API settings button at the top of the program. |
| [WS] Price websocket enabled: active-position bookTicker + REST fallback | Pricing WebSocket normal start. Subscribe to only the positions held and REST is waiting |
| [UDS] User data stream enabled (REST safety sync kept) | Starting an account event stream. Real-time reception of closing and position changes |
| [WS VERSION WARNING] websocket-client 1.9.x may not receive... | Warning: websocket-client version is different from recommended (1.8.0). pip install websocket-client==1.8.0 After restart |
| Symbol universe refresh: 4h fixed | Notice that the scanned item universe is automatically updated every 4 hours. |
| Position restore: supervised=3, exchange-only=1 | Result of position restoration upon restart. supervised = number of self-managed restores, exchange-only = number of positions on exchange only, without state file |
| WARNING: Some existing exchange positions have no saved SL/TP... | caution. Position without status file → Automatic stop loss management not possible. Manual Close or Emergency Close Required |
② Entry signal (Signal)
| log message | Meaning/Action |
|---|---|
| SIGNAL BTCUSDT LONG / trend_following / REGIME=TREND ATR%=5.21 SET=STRATEGY=trend_following,ADX_MIN25.0,VOL1.5,TRIG1.0,ATR_TRAIL2.0,RISK0.50% | Entry signal detection. Check the combination of items, direction, strategy, regime, ATR%, and parameters. Then proceed with position sizing. |
| BTCUSDT sizing: balance=1000.0, available=850.0, risk=5.0000(0.50%), stop_atr_mult=2.00, notional=240.0000, required_margin≈48.0000 | Quantity calculation details. risk=maximum loss amount of position, notional=notional amount of position, required_margin=required margin |
| BTCUSDT skipped: required_margin=820.0, available=850.0 | The order is skipped because the margin exceeds 95% of the available balance. Insufficient balance or need to adjust leverage/risk% |
| BTCUSDT already in local positions | Stocks you already own. Prevent duplicate entries — normal operation |
| BTCUSDT already exists on exchange | There is a position in the same stock on the exchange. Prevent duplicate entries — normal operation |
| BTCUSDT adjusted qty below minQty | The calculated quantity is less than the minimum order quantity. Need to increase balance or adjust Risk%/Leverage |
③ Position opening (Open)
| log message | Meaning/Action |
|---|---|
| OPEN BTCUSDT LONG qty=0.050 entry=42000.000000 SL=41520.000000 TRAIL_TRIGGER=42480.000000 TRAIL_DIST=480.000000 TRAIL_TF=5m TRIGGER_R=1.0 ATR_MULT=2.0 RISK=0.50% STRATEGY=trend_following REGIME=TREND ATR%=5.21 | Order completion log. SL= stop loss /TRAIL_TRIGGER= Trailing activation price /TRAIL_DIST= Trailing gap |
| OPEN ETHUSDT SHORT qty=0.200 ... STRATEGY=mean_reversion REGIME=QUIET ATR%=1.43 | Enter the MR strategy. TRAIL_TRIGGER is set as BB Mid position close target price |
④ Position monitoring (Monitor)
| log message | Meaning/Action |
|---|---|
| TRAILING ON BTCUSDT LONG trigger=42480.000000 | Activate trailing stop. The price reached TRAIL_TRIGGER. Then start tracking the highest price |
| TRAIL UPDATE BTCUSDT LONG SL=42200.000000 high=42680.000000 | Trailing stop loss has been updated upward. high=highest price to date, SL=updated stop loss price |
| TRAIL UPDATE BTCUSDT SHORT SL=41800.000000 low=41600.000000 | SHORT Trailing. low=lowest price, SL=updated stop loss (upward direction) |
| RSI EXIT SIGNAL BTCUSDT LONG RSI=74.2 | RSI overbought → triggers 50% partial close in partial_tp mode. Afterwards, logs PARTIAL and CLOSE follow. |
| [POSITION UNMANAGED] BTCUSDT: stop/ATR state is missing... | caution. Automatic management is not possible as there is no stop loss status information for the position. Manual position close or state file recovery and restart |
| [POSITION SYNC] REST safety sync OK (3 open exchange positions); next in 60s | Successfully synchronized position status with exchange. Performed periodically when UDS event is blank. |
| [SERVER STOP] BTCUSDT LONG stop=41520.000000 orderId=12345678 | STOP_MARKET order registration completed on Binance. Stop loss will be executed at that price even when the bot is offline |
| [SERVER STOP CANCEL] BTCUSDT orderId=12345678 TRAILING_TAKE | Server stop Order cancellation completed. Removed orphaned orders since they were successfully closed locally. Display the reason for position close in the reason field |
| [SERVER STOP WARN] BTCUSDT cancel failed: {e} | Warning: Server stop cancellation failure — if the order has already been placed or the order ID has expired. Generally negligible due to low probability of local position close and duplicate close |
| [SERVER STOP ERROR] BTCUSDT: {e} | error. STOP_MARKET Order registration failed. The local stop monitor continues to operate, but there is no server loss when the bot is offline. API Check permission/network |
| MANUAL CLOSE DETECTED BTCUSDT LONG PnL=+32.5000 USDT | Positions are manually closed outside the program (app/web). Automatic removal from local state |
| Universe added: XRPUSDT, SOLUSDT | Newly added items when the 4-hour universe is updated |
| Universe removed: DOGEUSDT | Stocks excluded from scanning due to falling trading volume rankings |
⑤ Close
All exit logs are reason Separate causes by fields.
| log message | meaning |
|---|---|
| CLOSE BTCUSDT LONG reason=STOP price=41520.000000 PnL=-5.0000 USDT | Position Close of stop loss. The price reaches the initial stop loss (SL). In case of stop loss before trailing is activated |
| CLOSE BTCUSDT LONG reason=TRAILING_TAKE price=42200.000000 PnL=+35.0000 USDT | Trailing stop profit. Trailing stop loss is reached by falling by trail_distance compared to the highest price. Position Close from beneficial interest |
| CLOSE ETHUSDT SHORT reason=MEAN_REVERSION_TAKE price=2050.000000 PnL=+18.0000 USDT | MR Ikjeol. The price reaches BB Mid at the entry point. Mean Reversion Goal Achieved |
| CLOSE SOLUSDT LONG reason=TIME_EXIT price=98.500000 PnL=-2.0000 USDT | Forced position close beyond 72 hours. Position held for more than 72 hours. Position Close regardless of profit or loss |
| CLOSE XRPUSDT SHORT reason=fast_exit price=0.620000 PnL=+8.0000 USDT | Quick profit. In fast_exit mode, the entire amount is closed as soon as the 1R goal is reached. |
| SERVER_STOP_FILLED BTCUSDT LONG PnL=-5.2000 USDT | Server stop concluded. While the bot was offline, Binance's STOP_MARKET order was filled, liquidating the position. Detected and recorded in the next monitor cycle after restarting the bot |
| PARTIAL CLOSE BTCUSDT LONG reason=RSI_EXIT qty=0.025 price=43100.000000 PnL=+27.5000 USDT remaining=0.025 | RSI overbought/oversold 50% closed first. Half position close with RSI signal in partial_tp mode. remaining=quantity remaining |
| PARTIAL CLOSE BTCUSDT LONG reason=partial_tp qty=0.025 price=42480.000000 PnL=+12.0000 USDT remaining=0.025 | 1R goal reached 50% partial close. Half position close when 1R (stop loss) is achieved in partial_tp mode |
| {symbol} close skipped: invalid qty | Failed to calculate position close quantity → Skip position close. Exchange minQty or less or position quantity error |
⑥ Warning & Error
| log message | Meaning/Action |
|---|---|
| [WS WARN] active price symbol sync failed: {e} | WS subscription item update failed. Automatic retry in the next cycle. Check network on repeat |
| [DASHBOARD] REST fallback standby activated for stale WS price cache | WS price is old → converted to REST. Automatically occurs when WS is in SILENT state. Normal operation or WS check recommended |
| [TRAIL INDICATOR ERROR] BTCUSDT: {e} | Error calculating trailing ATR. Candle data reception may fail. The bar remains the previous ATR |
| [PARTIAL CLOSE ERROR] BTCUSDT: {e} | 50% partial close order failed. All positions are maintained. Network error or exchange error |
| [POSITION SYNC ERROR] {e} | REST safety sync failed. Retry next cycle. Check API Key permission or network when repeating. |
| [SCAN ERROR] BTCUSDT: {e} | Error while scanning the item. Skip stock, retry in next loop. Check detailed error information when repeating |
| [UNIVERSE REFRESH ERROR] keep previous symbols: {e} | Universe update failure → Previous items maintained. Network or API error |
| [FATAL] {e} | Auto trading thread fatal error. Force ending loop. A restart is required after determining the cause through the log contents. |
| Auto trader stopped | Normally terminated with the Stop button. Maintain existing positions (stop automatic management) |
⑦ Backtest log (Backtest)
| log message | meaning |
|---|---|
| Backtest started. Downloading public Binance Futures kline data... | Start backtesting. Downloading candle data |
| [DATA 5/30] BTCUSDT | Data download progress. 5th download out of 30 items |
| [BACKTEST DATA ERROR] XYZUSDT: {e} | Download of relevant item data failed. Skip this item. Delisting, symbol change, etc. |
| [TREND SWEEP 3/12] ADX25.0_VOL1.5_TRIG1.0_ATR2.0_RISK0.50 | TREND Regime Sweep progress. Running 3rd out of 12 combinations. Parameter combination display |
| Stop Backtest requested. | User requests to stop backtesting. Exit after completion of current combination |
Example of normal entry to position close log flow
# ① Signal detection SIGNAL BTCUSDT LONG / trend_following / REGIME=TREND ATR%=5.21 SET=... # ② Quantity calculation BTCUSDT sizing: balance=1000.0, available=850.0, risk=5.0000(0.50%), ... # ③ Entry and conclusion OPEN BTCUSDT LONG qty=0.050 entry=42000.000000 SL=41520.000000 TRAIL_TRIGGER=42480.000000 ... # ④ Server stop registration [SERVER STOP] BTCUSDT LONG stop=41520.000000 orderId=12345678 # ⑤ WS subscription renewal [WS] Active price stream symbols=3 reason=position_open # ⑥ Activate trailing TRAILING ON BTCUSDT LONG trigger=42480.000000 # ⑦ Stop loss update + server stop update (repeat) TRAIL UPDATE BTCUSDT LONG SL=42200.000000 high=42680.000000 [SERVER STOP] BTCUSDT LONG stop=42200.000000 orderId=12345679 TRAIL UPDATE BTCUSDT LONG SL=42400.000000 high=42880.000000 [SERVER STOP] BTCUSDT LONG stop=42400.000000 orderId=12345680 # ⑧ Position Close + Server stop cancellation CLOSE BTCUSDT LONG reason=TRAILING_TAKE price=42400.000000 PnL=+20.0000 USDT [SERVER STOP CANCEL] BTCUSDT orderId=12345680 TRAILING_TAKE
glossary of terms
All terms that appear in the program UI and log are organized in alphabetical order.
Technical Indicators
| terminology | Description and Examples |
|---|---|
| ATR Average True Range |
Average Amplitude — The standard unit of volatility. The simple average (SMA) of the High-Low range of 14 bars. Used to determine stop loss, position size, and regime. Example: 15-minute bar BTCUSDT ATR = 120 USDT → Average 120 USDT movement in one bar |
| ATR% ATR Percent |
The ratio of ATR divided by the current price. Regime classification criteria. ATR% = ATR ÷ Current price × 100 Example: ATR = 120, price = 60,000 → ATR% = 0.2% (QUIET), ATR = 2,400 → ATR% = 4% (TREND) |
| ADX Average Directional Index |
Trend strength indicator (0~100). Measures only the strength of the trend itself, without direction. If it is above 25, it is generally judged that there is a trend. This program uses the SMA method instead of Wilder RMA. Example: ADX = 15 → weak trend (sideways), ADX = 35 → strong trend in progress |
| EMA Exponential Moving Average |
Exponential Moving Average — Higher weighting on recent bars. If EMA20 (short-term) is above EMA60 (long-term), it is judged to be an upward trend, and if it is below, it is a downward trend. Example: EMA20 = 42,500 / EMA60 = 41,800 → EMA20 > EMA60 → LONG Allow directions |
| RSI Relative Strength Index |
Overbought/oversold indicator (0~100). Wilder RSI 14-period calculation. Below 30 = oversold, above 70 = overbought. Used for MR entry filter and partial_tp secondary exit. Example: RSI = 22, RSI Entry = 30 → RSI ≤ 30 met → MR LONG one entry condition passed |
| BB Bollinger Bands |
Moving average ± standard deviation band. SMA20 ± BB Sigma × σ (standard deviation). MR entry signal when leaving the top/bottom. The middle band (SMA20) is the MR profit target. Example: SMA20 = 41,000 / σ = 800 / Sigma = 2.0 → Upper = 42,600, Lower = 39,400, Mid = 41,000 |
| Donchian Channel |
The highest/lowest price channel of recent N peak. Based on 20 bags. The closing price broke through the upper channel → LONG, and broke through the lower channel → SHORT. Conditions for entry into TF strategy. Example: Highest price of the last 20 bars = 43,100, current bar closing price = 43,250 → Break through the top of Donchian → Condition met |
| CI Choppiness Index |
Sideways/trend indicator (1~100). Higher values indicate choppiness, lower values indicate trend. If it is above 61.8, it is judged as a sideways trend and TF entry is blocked. Applies only when CI Filter is ON. Example: CI = 68 → sideways section → If CI Filter is ON, TF entry is skipped |
| Volume MA |
Volume moving average (20-week SMA). Among the TF entry conditions, a rapid increase in trading volume filter. To enter, the current bar trading volume must be > Volume MA × Vol Mul. Example: Volume MA = 500 BTC / Vol Mult = 1.5 → 750 The trading volume must be over BTC to meet the condition. |
Setting parameters (Parameters)
| terminology | Description and Examples |
|---|---|
| Decision TF |
Candlestick timeframe for judging entry signals. Only closed candles are used for signals. The shorter the signal frequency ↑ the noise ↑. Example: 15m → Check signal with completion bar every 15 minutes |
| Trailing TF |
Timeframe for calculating Trailing Stop ATR. Trailing will respond quickly if set shorter than Decision TF. Example: Decision TF = 15m / Execute TF = 5m / Trailing TF = 5m → Stop loss update with 5-minute bar ATR |
| ATR Mult |
ATR multiple — determines stop loss. Stop Loss = Entry ATR × ATR Mult. If it is low, the stop loss will be narrow (frequent stop loss), if it is high, the stop loss will be wide (large losses at once). Example: ATR = 120, ATR Mult = 2.0 → Stop loss = 240 USDT (entry price ± 240) |
| Trigger R |
(TF) Trailing activation distance multiplier. Trailing begins only when the price moves to the advantage of Trigger R When it is low, fast trailing is active. Example: Stop Loss = 240, Trigger R = 1.5 → Start trailing when profits exceed 360 USDT |
| BB Sigma |
(MR) Bollinger Band standard deviation multiple. The higher it is, the wider the band width is, reducing the frequency of entry. Default 2.0. Example: Sigma = 2.0 → SMA20 ± 2σ / Sigma = 1.5 → Narrower band, higher entry opportunities. |
| Vol Mult / RSI Entry |
Dual parameters with different meaning depending on the strategy. • TF: Vol Mult — Volume surge multiplier (Volume > MA × Vol Mult) • MR: RSI Entry — Oversold/Overbought baseline (LONG: RSI ≤ this value) Example: TF Vol Mult = 1.5 / MR RSI Entry = 30 |
| ADX Min / ADX Max |
Dual parameters with different meaning depending on the strategy. • TF ADX Min: Lower limit of trend strength. ADX < If this value does not enter • MR ADX Max: Upper limit of trend strength. ADX > Do not enter at this value (trend market blocking) Example: TF ADX Min = 25 / MR ADX Max = 20 |
| Risk % |
Maximum allowable loss percentage per position. Calculate the quantity so that only Risk% of the balance is lost when one position is stopped. Example: Balance 1,000 USDT / Risk% = 0.5% → Maximum loss for one position 5 USDT |
| Max Position % |
1 position notional upper limit ratio. Balance × Max Position% × Leverage is the maximum order possible. Use a smaller value compared to the risk standard quantity. Example: Balance 1,000 / Max Position% = 15% / Leverage 5 → Notional upper limit = 750 USDT |
| Leverage |
Futures leverage multiple. Position size multiple over margin. Both profits and losses are multiplied by multiples. Automatically set to the exchange upon entry. Example: 5x leverage / margin 100 USDT → Notional 500 USDT positions available |
| Top N |
The top N stocks with 24-hour trading volume are selected for scanning. Automatically renews every 4 hours. The more, the greater the opportunity·API load increases. Example: Top N = 30 → Scan entry signals only for USDT futures items ranked 1st to 30th by trading volume |
Strategy & Regime
| terminology | Description and Examples |
|---|---|
| Regime |
Market status classification. Classified into 4 levels QUIET / NORMAL / TREND / PANIC by ATR%. Strategies and parameters are automatically switched depending on the regime. Example: ATR% = 5.2% → TREND regime → Apply TF strategy |
| Trend Following (TF) |
Trend following strategy. A strategy to follow the trend by entering the breakout point where the up/down trend begins. Used in the NORMAL·TREND·PANIC regime. Key point: Breakout entry → Follow the trend until the end with a trailing stop |
| Mean Reversion (MR) |
Mean reversion strategy. A strategy that enters when the price deviates significantly from the average (BB middle band) and hopes to return to the average. Used in the QUIET regime. Key point: Breakout below BB + Oversold (RSI) → Entry into LONG → Profit when BB Mid returns |
| Closed Candle |
Completed rods — excluding rods that are still in progress. When judging signals in live trading, only the previous completed bar is used, excluding the currently in progress bar (incomplete). Reason: The price of the ongoing bar keeps changing, so the signal changes frequently → Prevents false signals |
Position Close and Risk (Exit & Risk)
| terminology | Description and Examples |
|---|---|
| Stop Loss |
Stop loss. Calculated upon entry. Entry price ± ATR × ATR Mult. Automatic position close when the price reaches this point. Example: LONG entry price 42,000 / stop loss 240 → stop loss = 41,760 |
| Trailing Stop |
Moving Stop Loss — Follow the stop loss price at the profit zone. Activated after reaching Trigger R. Highest price (LONG) - Stop loss is updated with stop loss. Follow the trend further while protecting your profits. Example: Highest price 43,200 / Stop loss 240 → Trailing stop = 42,960 (Stop loss updated) |
| partial_tp |
Partial profit mode. When 1R (profit equivalent to stop loss) is achieved, 50% of the position is closed first and the remaining 50% continues trailing. Example: Stop loss 240 → Profit 240 USDT Position Close of half, trailing the rest |
| fast_exit |
Fast full-capacity mode. Close the entire amount as soon as the 1R goal is achieved. Confirm profit without following the trend further. Mainly used in the PANIC (sudden change) regime — Prioritizes quick profit confirmation over large trends |
| BB Mid (Exit) |
MR-only wing mode. Set the target price as the mid-BB band (SMA20) at the time of entry. When the price reaches that level, the entire amount is profited. Even if the actual BB Mid moves while held, the target price is fixed. Example: Upon entry, BB Mid = 41,000 → When the price reaches 41,000, all LONG is closed. |
| Time Exit |
Forced position close over time. After 72 hours from opening a position, it is closed at the market price regardless of strategy or profit. Purpose: To prevent situations where capital is tied up due to long-term failure of MR |
| Emergency Close |
Emergency full position close button. Immediate position close of all futures positions on the exchange at market price (Reduce-only). For manual intervention in situations of sudden drops or surges. Caution: Slippage may occur. Additional losses are possible when profits and losses have already occurred. |
| Reduce-only |
Position Close-only order flag. Orders with this flag set are executed only in the direction of reducing the position, not increasing it. Prevents accidental opening of opposing positions. Emergency Close, next-day order, automatically applied to server STOP_MARKET |
| STOP_MARKET Server Stop |
Stop loss order registered on Binance servers. When the specified price is reached, the exchange automatically closes at the market price. workingType=MARK_PRICE Use to prevent unreasonable closing due to Last Price spike. reduceOnly=true Therefore, only the remaining position is closed.Double safety net with stop loss running even when the bot is offline. Automatically canceled upon local position close |
| Notional |
Position nominal amount. Quantity × current price. Actual position size, not margin. Example: 0.05 BTC |
| Mark Price |
Position Close standard price. Fair prices provided by Binance. It may be different from the general trade price (Last Price). This program determines stop loss based on Mark Price. Reason: Last Price has temporary spikes, preventing unreasonable position close with Mark Price. |
| Position Close |
Forced position close (roll).) If the margin falls below the maintenance margin, the exchange is forced to close the position. This program's stop loss is preemptively closed before forced position close occurs. Prevention: Lower leverage and limit Max Position% to reduce position close risk |
Backtest Performance Metrics
| terminology | Description and Examples |
|---|---|
| PF Profit Factor |
Profitability ratio = total profit ÷ total loss. 1.0 = break even, less than 1.0 = loss, 1.3 or more is excellent. Example: Total profit 1,300 USDT / Total loss 1,000 USDT → PF = 1.3 |
| MDD Max Drawdown |
Maximum drop — USDT Absolute value and % of high point displayed together. The lower the better. Be careful when exceeding 20%. Example: High balance 1,200 USDT → Low balance 900 USDT → MDD =-300.00 (25.00%) % calculation criteria: Not the entire high point, but the previous high point (running peak) at the time of occurrence of MDD Contrast. For example, even if a higher high was formed after MDD, it does not affect the % calculation — because the “actual drop rate at the time” is meaningful. |
| Win Rate |
Profit Trade Ratio. The percentage of total trades that ended in profit. It is meaningful only when viewed together with PF. Even if the win rate is low, if the PF is high, the structure is large profit and small loss. Example: Win Rate 40% + PF 2.0 → Structure to win by quality (trend following model) |
| Net PnL |
Net Profit and Loss — Final profit or loss including fees. A positive number is a valid strategy. Example: Total trading profit +800 USDT / Total loss -600 USDT / Fee -50 USDT → Net PnL = +150 USDT |
| Score |
Sweep ranking overall score. Normalized PF × 0.45 + Net PnL × 0.30 + Trades × 0.25. Criteria for selecting the top 10 within the regime. If the number of trades is too small, the score may be low even if the PF is high. |
| INSUFFICIENT |
Insufficient number of trades. As a result of the backtest, if the number of trades is less than 10, the statistical reliability is low and this indicator is warned. Solution: Increase period, increase Top N, or relax parameters |
| Cartesian Product |
Product of all combinations. If you enter 3 values for parameter A and 2 values for parameter B, all 3 × 2 = 6 combinations will be tested. Example: ADX [20,25,30] × ATR Mult [1.5,2.0] = 6 combination sweeps |
| Out-of-Sample |
Validation period not used for optimization. Re-verify the parameters found in sweep through validation in another period (OOS) to check for overfitting. Example: Sweep period 2025.01~03 → Validation OOS with validation period 2025.04~06 |
Infrastructure and API (Infrastructure)
| terminology | Description and Examples |
|---|---|
| WebSocket (WS) |
Real-time two-way connection protocol. Like REST, the server pushes data without making a request every time. Used to receive real-time prices. Advantages: Compared to REST, API significantly reduces the number of calls and reduces latency. |
| REST API |
Request-response method HTTP API. Data is received only when requested by the client. Used for order execution, balance lookup, and candle data download. When WS is broken, REST automatically acts as a price fallback |
| UDS User Data Stream |
WebSocket dedicated to account events. Receive account-related events in real time, such as closing, position change, and balance change. A Listen Key is required and automatically renews every 30 minutes (keepalive). Advantage: REST position status can be updated immediately upon execution without polling |
| Listen Key |
UDS authentication token. One-time key required when subscribing to User Data Stream. Valid for 60 minutes, renewed with keepalive requests every 30 minutes. When it expires, the UDS connection is disconnected, so the program automatically maintains keepalive |
| bookTicker |
Real-time priority quote stream. Immediately sent whenever the highest priority buy/sell price changes. Pricing WebSocket's subscription channel. This program only subscribes to the bookTicker of the held position items (active-position only) |
| REST Fallback/min |
Auxiliary means of querying prices with REST instead of WS. Automatically switches when WS is connected but no data comes. This can be checked with the REST Fallback counter on the API monitor. 0 in normal WS state, increases in WS SILENT state |
| Testnet |
Binance Test Environment. A simulated trading environment where no real funds are exchanged. Select API in the settings window, and the testnet API key needs to be issued separately from the live trading. It is recommended that you first verify it on Testnet before switching to live tradings. |
| USDT-M Futures |
USDT based perpetual futures. Binance USDⓈ-M perpetual futures market. Both margin and profit/loss are settled as USDT. What this program deals with. Different from Coin-M (COIN-M) futures — this program does not support COIN-M |
| state/ folder |
Position state persistence storage. Saved with atomic write and automatically restored upon restart. • open_positions.json— Position information such as entry price, stop loss price, strategy, etc. server_stop_order_id·server_stop_price·server_stop_status Fields are also saved and the server stop state is restored after restart.• reentry_cooldowns.json— Re-entry blocking cooldown after a position closes. The cooldown is maintained even after restarting, preventing immediate re-entry into the same symbol immediately after a position closes. When restoring [REENTRY] Cooldown Restore: ['BTCUSDT'] (up to N seconds until expiration) log outputIf the file is damaged, position and cooldown cannot be restored — regular backups are recommended. |
overall architecture
The program operates divided into GUI, data collection, cache, backtest engine, live trading engine, and order execution layer. The core goal is to keep the stock selection, indicator calculation, entry/position close logic of real trading and backtesting as the same as possible, while improving the repeat execution speed with cache.
architecture diagram
PySide6 GUI
│
├─ Trading Tab
│ ├─ AutoTradeThread
│ ├─ Price WebSocket
│ ├─ User Data Stream
│ └─ Order / Position Manager
│
├─ Backtest Sweep
│ └─ BacktestThread
│
├─ Backtest Validation
│ └─ BacktestThread
│
└─ Walk-forward
└─ WalkForwardThread
Binance REST / WebSocket
│
├─ Public Market Data
│ └─ Candle Cache
│ └─ Historical Build
│ └─ Indicator Cache
│ └─ market_data Memory Cache
│ └─ Backtest / Validation / Walk-forward
│
└─ Private Account Data
├─ UserDataStream
├─ Position State Store
└─ Order Engine
main components
| component | role | Notes |
|---|---|---|
| GUI | Trading, sweep, validation, walk-forward settings and result display | Based on PySide6 |
| AutoTradeThread | Real-time entry scanning, position management, and position close processing | Live trading engine |
| BacktestThread | Run sweep and validation backtests | Use the same strategy conditions as actual trading logic |
| WalkForwardThread | Repeat IS optimization and OOS verification | For verification of over-optimization |
| Candle Cache | Store and reuse candle data locally | Incremental updates after initial deployment |
| Historical Build | Create internal market_data structure by reading cache candles | OHLCV DataFrame creation steps |
| Indicator Cache | Reuse calculation results such as EMA, ATR, ADX, RSI, CI, etc. | Improved speed of iterative backtesting |
| Memory Cache | Store market_data with the same data conditions in memory | Reuse even when changing strategy parameters |
data flow
Data comes from REST and WebSocket, passes through cache and memory structures, and is then delivered to the strategy engine. Real trading and backtesting differ only in the timing of execution, and are designed to use the same indicators and conditions as much as possible.
Live trading data flow
Price WebSocket
│
▼
Global Price Cache
│
▼
Position Monitor / Trailing Stop
│
▼
Order Engine
│
▼
Binance Futures
User Data Stream
│
▼
Balance / Position / Order Event
│
▼
Dashboard / Position State Store
Backtest data flow
Binance REST or Local Candle Cache
│
▼
OHLCV DataFrame
│
▼
Historical Build
│
▼
Indicator Cache
│
▼
market_data
│
▼
Dynamic Top N Universe
│
▼
Strategy Signal
│
▼
Virtual Position/Exit Simulation
│
▼
PnL / MDD / PF / Trade Log
Where data is used
| data | Where to use | explanation |
|---|---|---|
| OHLCV | Backtest / Validation / Walk-forward | Used for candle-based indicator calculations and entry/exit simulations |
| quote_volume | Dynamic Top N | Calculate past 24-hour trading volume ranking every 4 hours |
| WebSocket Price | Trading | Real-time trailing stop, current price display, position monitoring |
| User Data Event | Trading / Dashboard | Real-time reflection of trades, position changes, and balance changes |
| Trade CSV | Analysis/Verification | Analysis of live trading results and use as future AI analysis data |
cache structure
Cathy is Disk files (retained across restarts) class Memory during execution (maintained for one backtest) It consists of: Each layer divides roles to minimize API calls and disk I/O.
Cache hierarchy
── Disk (remains after restart) ──────────────────────────────
1. manifest.json candle_cache/manifest.json
first/last open_time index by symbol (65KB level)
Used to immediately determine cache freshness without calling API
2. Candle Cache (parquet) candle_cache/{SYMBOL}/{interval}.parquet
Actual OHLCV candle data (100~200KB per symbol)
CacheUpdateThread only incrementally adds new candles every 5 minutes
── Memory (maintained while running one backtest) ──────────────────────────
3. manifest_cache Load entire manifest.json when backtest starts
O(1) freshness check for each symbol → Determine whether to skip API
Only memory is updated during download, saved once to disk when pass ends
4. market_data {symbol: {entry/execute/trailing: DataFrame}}
Keep parquet read results in memory
Reuse when parameter combination changes within the same execution (when TF and period are the same)
5. Indicator Cache {symbol: DataFrame with EMA/ADX/ATR/RSI/CI}
_precompute_indicators() result
Shared by all parameter combinations within the same run
market_data reuse conditions
When changing parameter combinations within the same backtest run, whether or not OHLCV data (market_data) can be reused is determined according to the conditions below.
| Changed Items | market_data reuse | explanation |
|---|---|---|
| ADX | Shared | Only the strategy conditions change and the OHLCV data is the same |
| ATR Mult | Shared | Only the stop loss calculation value has changed. |
| Volume Mult | Shared | Only the entry filter threshold has changed. |
| Trigger R | Shared | Only the criteria for trailing activation have changed. |
| Risk % | Shared | Only the position quantity calculation has changed. |
| Exit Mode | Shared | Only the Exit logic has changed. |
| Regime ON/OFF | Shared | Only changes whether signal is used or not |
| Top N | Shared | Dynamic Top N list is recalculated but OHLCV is the same |
| Market Universe | rebuild | CRYPTO/TRADFI/ALL Universe has changed |
| Decision TF | rebuild | The entry judgment candle itself changes. |
| Execute TF | rebuild | Actual entry timing candle is different |
| Trailing TF | rebuild | ATR Trailing calculation candle has changed |
| period | rebuild | Required candle range varies |
| Run a new backtest | rebuild | Memory cache is not shared between executions. However, candle files (parquet) are reused. |
Dynamic Top N Algorithm
Dynamic Top N is a function to reduce the difference in stock selection between actual trading and backtesting. Rather than using a fixed Top N list for the entire period, the Top N is re-selected every 4 hours based on trading volume over the past 24 hours.
basic concepts
Every 4 hours: 1. Sum of quote_volume for the previous 24 hours for each item 2. Sort by trading volume in descending order 3. Designate the top N as the active Universe for that 4-hour period. 4. Continue to manage existing positions 5. New entries are limited to stocks included in the Top N at the time.
Why Prepare Full Universe Data?
In long-term backtesting, it is impossible to know in advance which stock will enter the Top N due to a surge in trading volume at a specific point in time. Therefore, to maintain the accuracy of Dynamic Top N, the Top N for each 4-hour bucket must be calculated based on the volume data of the entire universe.
2-pass download and ever-active
Only 4h candles are used to calculate trading volume rankings, and strategy TFs (15m/5m, etc.) are downloaded only for symbols that have entered Top N at least once (ever-active). Since the 4h candle is built in advance by the Cache Manager in the background, when running Sweep, Pass 1 mostly performs only cache reads. This drastically reduces the strategic TF download range from full Universe (~500 units) to ever-active (~100 units).
Pass 1: Entire Universe (~500 pieces) × 4h candles
→ 4h cache is pre-built in the background at startup
→ When running Sweep, only parquet is read in the manifest fresh section without API.
→ Dynamic Top N calculation based on 4h vol_data
→ ever_active = Set of symbols included in Top N in any one bucket
Pass 2: ever_active (~100) × Decision / Execute / Trailing TF
→ Configure market_data to be used for actual strategy simulation
※ If ever_active is empty (Pass 1 failure, etc.), "[WARN] Dynamic TopN empty; fallback to static TopN"
Automatically switches to Static Top N with logs.
| method | merit | disadvantage | accuracy |
|---|---|---|---|
| Static Top N | speed | Lack of reflection of changes in trading volume within the period | May differ from live trading |
| Dynamic Top N | Similar to the update method for real-time trade items | Increased data preparation volume over long periods of time | height |
Behavior when changing Top N
If you change the Top N value from 50 to 100, the OHLCV data will be reused, and only the active stock list for each 4-hour bucket will be recalculated. Therefore, Historical Build can be reused if the Market, Period, and Timeframe are the same.
How the backtest engine works
The backtest engine operates in the following order: data preparation, indicator calculation, Dynamic Top N generation, signal search, virtual execution, position management, and result aggregation.
execution order
- 1Set period
Determine the test period based on Recent Days or Date Range. An additional warm-up section ahead is secured to stabilize the surface. - 2manifest preload
Load manifest.json into memory. Afterwards, the freshness check for each symbol operates in O(1) and immediately decides whether to skip the API call. - 3Pass 1 — 4h volume cache load
Read the entire Universe (~500) × 4h candles. The 4h candle is pre-updated in the background at startup, and if the manifest is fresh, only the parquet is read without the API call. Only the missing sections are downloaded and the results are collected as vol_data. - 4Dynamic Top N generation / ever-active calculation
Based on vol_data, we build a Top N list for each 4h bucket and derive ever-active (a set of symbols included in Top N at least once during the entire period). - 5Pass 2 — Download Strategy TF
Only ever-active symbols (~100) read Decision / Execute / Trailing TF candles. Also, when the manifest is fresh, API is 0 times. Collect the results as market_data. - 6Indicator calculation
Calculate EMA, ADX, ATR, RSI, CI, etc. once per symbol. Sweep passes only OHLCV through the process boundary and calculates it independently when initializing each worker process (reduces pickle transmission). Walk-forward is calculated once in the parent process and then reused by the entire window. - 7signal search
Create entry candidates by checking the conditions: Regime, Strategy, ADX, Volume/RSI, Donchian/BB. - 8Virtual execution and position management
Simulate positions by reflecting Risk %, Max Position %, Max Long/Short, Leverage, commission, and slippage. - 9Results Aggregation
Calculate Net PnL, PF, Win Rate, MDD, Trades, Daily PnL, and performance by regime.
Sweep / Validation / Walk-forward difference
| mode | purpose | data download | Parameter execution |
|---|---|---|---|
| Sweep | Search for optimal parameters by regime | 2-pass (4h all + 3TF ever-active) | All combination grid search, compare results in table |
| Validation | Detailed verification of single parameter combinations | Same 2-pass | Run once, output detailed results for each regime |
| Walk-forward | IS/OOS similarity verification of single validation setting × N window | Same 2-pass (once for the entire period) | When running, fix the validation settings and apply the same to IS·OOS of each window. Data is reused by all windows |
fastening model
Backtesting creates virtual positions without placing live orders. We calculate results close to live trading by reflecting fees and slippage.
| Metric | reflection method |
|---|---|
| charge | Fee rates applied to entry and exit respectively |
| Sleepy | Conservative reflection of entry/exit prices in bps units |
| leverage | Reflected in notional calculation and Max Position limit |
| Risk % | Calculate position quantity based on stop loss |
| Simultaneous position limits | Max Long / Max Short number limit applied |
| Simultaneous SL/TP touch within the same rod | When the high price touches TP and the low price touches SL at the same time on the same candle. SL priority processing. Since the tightening order within the rod cannot be known with just OHLC, a conservative assumption is applied. Results may be slightly lower compared to live trading |
Performance Optimization
Backtest speed is Download API → Read SSD (parquet) → Calculate indicator → Execute strategy combination They are divided in order. It is a structure that minimizes each step with cache and skip logic.
Speed by execution situation
| situation | main task | speed characteristics |
|---|---|---|
| First run (no cache) | Download full Universe candle API + save parquet | Takes longest (moisture) |
| Backtest after building the cache | Check manifest → API 0 times → Read parquet → Calculate indicator | SSD read only (~10 seconds) |
| Change parameters within the same run | Reuse market_data + Indicator Cache, re-evaluate only strategy conditions | Fastest (in seconds) |
| TF/Period/Market Change | parquet reread + market_data reconstruction | Read SSD (~10 seconds) |
| Backtest after restarting the program | Check manifest → API 0 times → Read parquet (if there is cache) | SSD read only |
List of optimization techniques
| techniques | effect |
|---|---|
| CacheUpdateThread every 5 minutes | Cache is always kept fresh before running backtests |
| manifest preload | Load manifest once when starting backtest → O(1) freshness check for each symbol |
| Manifest-based API skip | When refreshing the cache, API is called 0 times, and only parquet is read (Pass 1 × 500 times saved) |
| 2-pass download | The entire universe is only once for 4h, and the strategy TF is ever-active (~100) |
| manifest batch save | Save by symbol → Batch save up to 2 times when pass ends |
| Temporary file organization episode 1 | Clean up the .tmp file only once at the start of the backtest (prevent repeated calls) |
| Indicator Cache | Calculate EMA/ATR/ADX/RSI/CI once per symbol, shared by all parameter combinations |
| Sweep worker-side metric calculation | Only OHLCV sends process boundaries → Each worker calculates independently when initialized. Reduces pickle transmission by not copying a large DataFrame containing indicator columns N times. |
| Dynamic Top N Recalculation Separation | When Top N changes, OHLCV is reused and only the active Universe is recalculated. |
Key log interpretation
[Pass 1/2] Download 4h Candles for Volume Ranking: N Symbols
→ Start reading the entire Universe × 4h candle
zXQPH0000QXZ 0 times if → manifest fresh, only read parquet
[Pass 2/2] Download ever-active N symbol strategy TF
Read only the symbols in the TopN → at least once Strategy TF
VOL N/M → {sym} Pass 1 Status
STRAT N/M {sym} → Pass 2 Progress Status
[WF-VOL N/M]/[WF-STRAT N/M]
→ Walk-forward 2-pass progress status