This is an autonomous quantitative research loop where the LLM evolves a
multi-strategy 1x crypto futures portfolio (up to 3 active strategies,
long & short enabled, leverage strictly locked to 1.0x) that can:
- trade both long and short (
can_short = True) on Binance USDT-M perpetual futures with real historical funding rates (equivalent to unleveraged spot long + 1x shorting) - combine signals across multiple timeframes (
1hbase +4h+1d) - reference multiple assets (5-pair universe:
BTC/USDT:USDT,ETH/USDT:USDT,SOL/USDT:USDT,BNB/USDT:USDT,AVAX/USDT:USDT) - declare their own asset basket (
pair_basket) - evaluate automatically across the configured training regimes
(
bull_2021,winter_2022,recovery_23_25,full_5ybeforesplit_date) while keeping the post-split_datewindow untouched for human OOS evaluation - use dynamic position sizing via
custom_stake_amount - optimize both single-strategy risk quality AND combined cross-strategy
portfolio synergy (
PORTFOLIO_SUMMARY)
Spot-only (long-only) strategies are structurally forced to either sit in cash
or catch dead-cat bounces during protracted bear regimes (winter_2022 and
2026 bear OOS). Meanwhile, keeping train and test windows separated by a clean
cutoff makes out-of-sample generalization directly measurable.
v0.5.2 upgrades the scaffold on top of v0.5.1's true daily MTM oracle:
- 1× Unleveraged Futures Long/Short:
config.jsonswitches to Binance USDT-M perpetuals (trading_mode: "futures",margin_mode: "isolated"), whilerun.pylocksMAX_LEVERAGE = 1.0.- Strategies may set
can_short = True, emitenter_short/exit_short, and MUST keepleverage(...) -> 1.0.run.pyenforcesMAX_LEVERAGEon every trade and rejects any strategy exceeding1.0x. - Real historical 8h funding payments are automatically settled by FreqTrade
and included in each trade's
profit_abs;run.pyprints asides:line (long=N (+X%) short=M (+Y%) funding=+Z USDT (max_lev=1.00x), where positive funding = net received and negative = net paid).
- Centralized Bench Constants & Train/Test Split:
- Humans configure
BENCH_FEE,MAX_LEVERAGE,DATA_TIMERANGE, andSPLIT_DATEas top-level constants inrun.pybefore starting a run (single source of truth; immutable during the run). uv run run.pyevaluates strictly on the training split (< SPLIT_DATE).uv run run.py --oosevaluates on the out-of-sample test split (>= SPLIT_DATE) and is reserved strictly for post-run human evaluation — never run--oosduring the research loop.
- Humans configure
- True Daily Mark-to-Market (MTM) Equity Curves (v0.5.1+): every open long
or short position at end-of-day UTC (
open_day <= d < close_day) is valued at the pair's1dUTC close price, fee-inclusive (matching FreqTrade'sLocalTrade.calculate_profitmark-to-liquidation convention, including multi-order DCA / partial exits). Closed trades transition seamlessly to exactprofit_abs(including funding) onclose_day, preserving the exact telescoping return identity(1 + r).prod() == final_eq / start_eq.max_drawdown_pctexposes bothmtm_ddandft_realized_dd.
-
True Daily MTM Equity-Curve Portfolio Analytics (per strategy & regime)
-
daily_sharpe&daily_sortino: annualized ($\sqrt{365}$ ) from the reconstructed daily equity curve — directly apples-to-apples withbah_sharpe, withdaily_sortinoavoiding unfair penalties on upside breakout volatility. -
Tail & Underwater Pain:
cagr_pct,calmar,ulcer_index,martin_ratio($\text{CAGR} / \text{UlcerIndex}$ ), andmax_dd_days(longest underwater streak). -
Benchmark OLS Decomposition vs Equal-Weight BaH:
alpha_ann_pct(annualized Jensen's$\alpha$ ),beta(passive market exposure), andinfo_ratio. Separates real timing/selection alpha from "holding 10% passive crypto beta". -
Capital Utilization & Breadth:
avg_pos_pct,time_in_market_pct(exact merged interval fraction with$\ge 1$ open trade),capital_util_pct, andeffective_pairs($1 / \sum w_i^2$ inverse HHI of per-pair$|\text{PnL}|$ ).
-
-
Calibrated Multi-Objective Gates (per strategy
SUMMARY)-
regime_return_gate: regime-conditional return bar:- Bull / Recovery windows (
bah_profit_pct >= 0, < 4y):profit >= +10% - Full 5y window (
>= 4y):profit >= +20% - Bear / Winter windows (
bah_profit_pct < 0, e.g.winter_2022): capital preservationprofit >= -2.0%AND strictly beatingbah_profit_pct
- Bull / Recovery windows (
-
exposure_gate:worst_avg_pos_pct >= 5.0%across ALL traded regimes ANDfull_time_in_market_pct >= 2.0%(blocks both tiny-stake Sharpe gaming and 2-trades-in-5-years cash-sitting). -
pareto_dominated_by(3D + Kill-Aware): checks 3D dominance on(robust_sharpe, full_cagr_pct, worst_dd_pct)and distinguishes live dominators from archived/killed strategies (none_active).
-
-
Cross-Strategy
PORTFOLIO_SUMMARY(Portfolio Manager Layer)- Combines all active strategies (
$1..3$ slots) into an equal-weight daily-rebalanced portfolio (PORTFOLIO_EQ) across all common regimes: -
portfolio_robust_sharpe&portfolio_robust_sortino: worst-regime daily Sharpe / Sortino of the combined lineup (co-headline metric!). -
diversification_gain:portfolio_robust_sharpe - mean(individual robust_sharpe)— directly rewards combining low-correlation paradigms. -
Correlation Diagnostics &
diversification_gate:pairwise_daily_corrandpairwise_tail_corr(correlation on loss days), gated atmax_pairwise_corr < 0.60. -
Leave-One-Out Marginal Contribution:
marginal_robust_sharpeandmarginal_full_sharpeper strategy ([ACCRETIVE]vs[DILUTIVE]). A modest standalone strategy that hedges winter drawdowns for the rest of the portfolio shows up immediately as[ACCRETIVE].
- Combines all active strategies (
To set up a new experiment:
- Agree on (or create) a run branch: e.g.
git checkout -b autoresearch/<tag>if not already on an experiment branch. - Read the in-scope files:
README.md— project historyconfig.json— fixed FreqTrade exchange/market config (5futures pairs,1hbase, isolated margin, dry-run wallet). Do not modify.prepare.py— data check/download. Do not modify.run.py— the v0.5.2 daily MTM 1× futures portfolio oracle (defines bench constantsBENCH_FEE,MAX_LEVERAGE,DATA_TIMERANGE,SPLIT_DATE). Do not modify.user_data/strategies/_template.py.example— strategy skeleton.versions/0.5.0/retrospective.md— key findings from prior runs.
- Verify data exists: Check that the 25 futures feather files exist under
user_data/data/futures/({BTC,ETH,SOL,BNB,AVAX}_USDT_USDT-{1h,4h,1d}-futures.feather, plus-1h-mark.featherand-1h-funding_rate.feather). - Initialize
results.tsv(if it doesn't already exist) with the 10-column tab-separated header:Do NOT commitcommit event strategy_name robust_sharpe robust_sortino cagr_pct max_dd alpha_pct marginal_sharpe noteresults.tsv— it is gitignored so history survivesgit reset. - Create 2–3 starting strategies under
user_data/strategies/<YourName>.py:- Class name MUST match filename stem.
- Fill all 6 docstring metadata fields (
Paradigm,Hypothesis,Parent,Created,Status,Uses MTF). - Set
can_short = Trueif the strategy trades short (or both sides) and implementdef leverage(...) -> float: return 1.0. - Each starter MUST target a genuinely orthogonal paradigm (e.g.
long/short mean-reversion + MTF trend/breakout + bear-regime short or
volatility/funding-aware rebound) so
PORTFOLIO_SUMMARYstarts with lowpairwise_daily_corrand positivediversification_gain. - Leave
test_timerangesunset (so all strategies inherit the active training split's canonical regimes and align inPORTFOLIO_SUMMARY).
- Confirm and go (if running interactively with a human; if launched in autonomous/non-interactive mode, proceed directly into the experiment loop without pausing!).
- Create, modify (
evolve), copy (fork), or delete (git rm,kill) strategy.pyfiles underuser_data/strategies/(not prefixed with_). - Trade long, short, or both (
can_short = True) at1.0xleverage.
- Modify
prepare.py,run.py,config.json, or_template.py.example. - Run
uv run run.py --oos— the test split (>= SPLIT_DATE) is strictly reserved for post-run human OOS evaluation. Always run plainuv run run.py > run.log 2>&1. - Use leverage above
MAX_LEVERAGE(1.0x) —run.pyenforces this and rejects> 1.0xtrades as an error. - Add new Python dependencies or call
freqtradeCLI directly — always runuv run run.py. - Exceed 3 active strategies at any time.
- Request timeframes other than
1h,4h,1dor pairs outside the 5-pair futures whitelist (BTC/USDT:USDT,ETH/USDT:USDT,SOL/USDT:USDT,BNB/USDT:USDT,AVAX/USDT:USDT).
- Multi-timeframe & Cross-Asset (
@informative):@informative("4h")/@informative("1d")merges look-ahead-safe columns (rsi_4h,ema200_1d).@informative("1h", "BTC/USDT:USDT")merges cross-pair columns asbtc_usdt_<col>_1h(note: pass"BTC/USDT:USDT"in the decorator, while FreqTrade drops:USDTin the merged column prefix!). Remember to setstartup_candle_counthigh enough for slow higher-TF indicators.
- 1× Long & Short (
can_short = True):- Emit
enter_long/exit_longand/orenter_short/exit_shortinpopulate_entry_trend/populate_exit_trend. - Always keep
def leverage(...) -> float: return 1.0. - Monitor the
sides:line inrun.pyoutput (long,short, netfundingPnL in USDT) to verify both sides and funding drag/carry behave as hypothesized.
- Emit
- Dynamic Position Sizing (
custom_stake_amount):- Scale
proposed_stakewithin[min_stake, max_stake]for volatility targeting, conviction weighting, or regime sizing. - Lesson from v0.4.1: multiplicative sizing composition works when signals are independent/positively correlated, and inverse-amplifies when negatively correlated!
- Scale
- Strategy-Declared Basket (
pair_basket):- Optional subset of the 5 futures pairs (must include
:USDT, e.g.pair_basket = ["BNB/USDT:USDT"]or alts-only). You can also build per-pair-conditional paradigms inside one strategy usingmetadata["pair"].
- Optional subset of the 5 futures pairs (must include
-
Hard cap — max 3 active strategies in
user_data/strategies/. -
Stagnation gate — max 3 consecutive
stablerounds: if a strategy sitsstablefor 3 consecutive rounds, round 4 MUSTevolve,fork, orkillit. - Every round touches
$\ge 1$ strategy.
Quick scan of strategy summaries + portfolio rollup:
awk '/timerange_label: *(SUMMARY|PORTFOLIO_SUMMARY)/,/^$/' run.logFull blocks (including per-regime bull_2021 / winter_2022 / recovery_23_25 / full_5y and sides: long/short/funding breakdown):
awk '/^---$/,/^$/' run.log-
Portfolio Level (
PORTFOLIO_SUMMARY) — Primary Optimization Target:-
portfolio_robust_sharpe&portfolio_robust_sortino: push BOTH up! -
diversification_gain: positive means your strategies genuinely complement each other across regimes. -
pairwise_daily_corr&pairwise_tail_corr: keepmax_corr < 0.60(diversification_gate: PASS). High tail correlation means two strategies bleed on the exact same days. -
marginal_contributions: check whether each slot is[ACCRETIVE]or[DILUTIVE]onmarginal_robust_sharpeandmarginal_full_sharpe.
-
-
Strategy Level (
SUMMARY):-
robust_sharpe&robust_sortino(worst-regime daily Sharpe/Sortino). -
full_cagr_pct,full_calmar,full_martin_ratio(CAGR / Ulcer Index). -
full_alpha_ann_pct&beta: verify positive$\alpha$ rather than disguised low-$\beta$ passive exposure. - Gates:
regime_return_gate,exposure_gate,pareto_dominated_by.
-
After each round, append:
- One row per active/killed strategy (
create | evolve | stable | fork | kill) - One
portfoliorow (event = portfolio,strategy_name = PORTFOLIO_EQ) recording the combined lineup's metrics (robust_sharpe = portfolio_robust_sharpe,robust_sortino = portfolio_robust_sortino,cagr_pct = portfolio_full_cagr_pct,max_dd = portfolio_worst_dd_pct,alpha_pct = portfolio_alpha_ann_pct,marginal_sharpe = diversification_gain).
10 tab-separated columns:
commit event strategy_name robust_sharpe robust_sortino cagr_pct max_dd alpha_pct marginal_sharpe note
For kill rows, use - for numeric columns and explain why it was killed in
note. Always write rich, analytical notes citing regime dispersion,
- Inspect state: read tail of
results.tsv, check active strategies, stagnation counts, gates, and which slot is[DILUTIVE]or bottleneckingportfolio_robust_sharpe. - Formulate a sharp hypothesis and choose this round's action (
create,evolve,fork,kill, or combination within the 3-slot cap). - Edit strategy code under
user_data/strategies/. - Commit:
git commit -am "<concise round summary>" - Run oracle:
uv run run.py > run.log 2>&1 - Inspect results: check for
status: ERRORfirst; read per-regime blocks,SUMMARY, andPORTFOLIO_SUMMARY. - Append rows to
results.tsv(all strategies +PORTFOLIO_EQrow). - Keep or rollback: if an evolution degraded both standalone
robust_sharpeANDportfolio_robust_sharpe(and wasn't an informative stepping stone), revert that change (git checkout HEAD~1 -- user_data/strategies/<File>.pyorgit reset --hard HEAD~1if the whole round regressed —results.tsvstays intact because it is gitignored!). - Repeat continuously without stopping to ask the human!
Keep / evolve a strategy when:
- It is
[ACCRETIVE]toportfolio_robust_sharpe(ormarginal_full_sharpewith positiverobust_sharpe), ANDdiversification_gatepasses (corr < 0.60). -
robust_sharpe > 0across all 4 regimes (or rapidly trending toward> 0within 1–2 evolutions) with strongrobust_sortinoandmartin_ratio. -
regime_return_gateandexposure_gatePASS (or you have a concrete next evolution aimed at clearing the failing gate). - Positive annualized
$\alpha$ (full_alpha_ann_pct > 0).
Kill / replace a strategy when:
robust_sharpe < 0persistently after targeted fixes (structural winter bleed).- Strongly correlated (
corr >= 0.60) with a superior active strategy AND[DILUTIVE]on marginal portfolio Sharpe. - Dominated on 3D
(robust_sharpe, cagr_pct, max_dd)by an active strategy in the same paradigm. - Stagnant for 3 rounds with no untested mechanism left.
Never use exit_profit_only=True, micro-ROI clipping (minimal_roi < 1% to
compress return variance), or sub-5% stake shrinking. Under v0.5.1's daily MTM
oracle, hold-and-pray (stoploss = -0.99) floating drawdowns are directly
exposed in mtm_dd, ulcer_index, beta, and pairwise_tail_corr — check
mtm_dd vs ft_realized_dd alongside alpha_ann_pct, cagr_pct,
exposure_gate, and regime_return_gate: real improvements lift risk-adjusted
return AND economic return/portfolio synergy together.