What's in a genome

A genome is the settings card behind each strategy. Here is every setting, in plain words.

The idea

Every strategy in this project is a genome: a fixed card of 21 settings. Some are numbers (how many stocks to hold, how often to trade). Some are choices from a short list (which ranking rule to use). A bot reads its card and follows it. That is all a bot is. All trading here uses paper money, never real money.

Evolution only changes the values on the card. It copies a card, nudges some numbers, flips some choices, or mixes two cards. It never writes code. The program that turns a card into trades is fixed and was written by people.

How a genome becomes trades each day

How a genome turns into trades each dayEight steps, top to bottom: data up to today's close, regime check, pick the pool, rank by the rule, take the top N, size the positions, orders fill at the next open with costs, then exits and the kill switch.1Data up to today's closePrices and volume through today.Nothing from tomorrow or later.2Regime checkIs the index above its N-day average?Settings: regime.*. Off means always yes.3Pick the poolStocks, sector funds or broad-asset funds.Setting: selection.pool.4Rank by the ruleMomentum, trend, pullback, low volatilityor reversal, plus optional filters.5Take the top NKeep the best few that pass the rule.Setting: selection.top_n.6Size the positionsEqual or by calmness; core share set aside.Caps: 20% per stock, 40% per sector fund.7Orders fill at the next open, with costsTomorrow's opening price, nudged against usby a cost: 0.02% funds, 0.05% big-index stocks.8Exits and the kill switchStops and hold limits sell a position.Down 35% from its peak: the bot stops.

Read it top to bottom. Costs are small: 0.02% per trade for funds, 0.05% for stocks in the S&P 500 and Nasdaq-100, 0.20% for small-cap stocks.

Core (1 setting)

How much money simply owns the index fund.

SettingRange or optionsUnitWhat it doesHigh valueLow value
Index-fund core
core.pct
0 to 100percent of moneyThe share of paper money kept in the arena's index fund (SPY for S&P 500, QQQ for Nasdaq-100, IWM for small caps). The rest is the strategy money. At 100 the strategy settings do nothing.Closer to simply owning the index. Results track the market more and the strategy less.The strategy drives the result. At 0 there is no index fund.

Market filter (regime) (4 settings)

An optional switch that moves money to a safe place when the market looks weak.

SettingRange or optionsUnitWhat it doesHigh valueLow value
Market filter
regime.enabled
yes or noyes or noSwitches the market filter on. Each day the bot compares the index fund's closing price with its recent average. If the price is below the average, the market counts as weak and money moves to the safe haven. When the filter flips, the bot rebalances at once instead of waiting for the next rebalance day.Yes: the filter is active.No: the filter is ignored, so its average length and the core setting below do nothing.
Filter length
regime.ma_days
20 to 250trading daysHow many trading days go into the index's average price. A moving average is the plain average of the last N closing prices.A slow filter. It ignores short dips and reacts late.A fast filter. It reacts quickly but flips more often, so it trades more.
Safe haven
regime.safe_haven
cash, bonds, golda choiceWhere money goes when the market looks weak: cash (BIL, a cash-like fund), bonds (IEF) or gold (GLD). The same choice is used by the hold_safe rule, even when the filter is off.n/a (a choice)n/a (a choice)
Filter moves the core
regime.apply_to_core
yes or noyes or noWhen the market looks weak, also move the index-fund core to the safe haven. If no, only the strategy money moves and the core stays in the index.Yes: everything moves to the safe haven.No: the core stays invested through weak markets.

Selection (9 settings)

What the strategy money buys, and how candidates are ranked.

SettingRange or optionsUnitWhat it doesHigh valueLow value
Pool
selection.pool
stocks, sectors, assetsa choiceWhat the strategy money can buy. stocks: the arena's stocks that were index members on that day. sectors: the 11 sector funds. assets: SPY, QQQ, IWM, EFA, EEM, IEF, TLT, GLD and BIL (stock, bond, gold and cash funds). One stock may hold at most 20% of the account, one sector fund 40%.n/a (a choice)n/a (a choice)
Ranking rule
selection.rule
momentum, trend, pullback, low_volatility, reversal, hold_safea choiceHow candidates are ranked. momentum: biggest gain over the lookback, and the gain must be above zero. trend: furthest above the slow average. pullback: above the slow average and up over the lookback, ranked by how far the price sits below the fast average. low_volatility: the smoothest day-to-day prices. reversal: biggest loss over the lookback. hold_safe: no ranking; the strategy money sits in the safe haven.n/a (a choice)n/a (a choice)
Lookback
selection.lookback_days
3 to 300trading daysHow far back the rule looks to measure gain or loss (momentum, pullback, reversal) or the size of daily swings (low_volatility). The trend and hold_safe rules ignore it. 21 trading days is about a month, 252 about a year.Looks at slow, long trends.Looks at recent moves, which are noisier.
Skip recent days
selection.skip_days
0 to 30trading daysIgnores the most recent N days when measuring the gain or loss. Textbook 12-1 momentum skips the last month (21 days). Used by momentum, pullback and reversal; low_volatility and trend do not skip.Skips more recent history.0 means nothing is skipped.
Fast average
selection.sma_fast
3 to 100trading daysThe short moving average. Only the pullback rule uses it: it wants stocks that have dipped below this average. It must be smaller than the slow average.A less sensitive 'dip' measure.A very sensitive 'dip' measure.
Slow average
selection.sma_slow
10 to 250trading daysThe long moving average. Used by the trend rule, the pullback rule and the trend filter. Every genome also waits until it has this many days of history before it can pick anything.A slower definition of an uptrend.A quicker definition of an uptrend.
Trend filter
selection.trend_filter
yes or noyes or noOnly buy candidates whose price is above their slow average, whatever the ranking rule says.Yes: fewer, stronger-looking candidates.No: no extra check.
Volume filter
selection.min_volume_rank
0 to 0.95fraction of poolStocks pool only. Ranks stocks by average daily trading volume over the last 20 days and skips those below this fraction. 0.5 skips the least-traded half.Only heavily traded stocks qualify.0 means no volume filter.
How many to hold
selection.top_n
1 to 25positionsHow many of the best-ranked candidates to hold. Fewer may qualify, and then it holds fewer. With stocks, no single stock gets more than about 19% (a 20% cap with a little headroom), so below five names some money stays in cash.More names, spread more thinly.Fewer names, bigger bets.

Rebalance (1 setting)

How often the bot trades toward its picks.

SettingRange or optionsUnitWhat it doesHigh valueLow value
Rebalance every
rebalance.every_days
1 to 63trading daysTrading days between rebalances, when the bot recomputes its picks and trades toward them. 5 is about weekly and 21 about monthly. Exits and market-filter flips can still trade in between. Trades smaller than 1% of the account are skipped.Fewer trades and lower costs, but slower to react.More trades, more costs, faster reactions.

Sizing (2 settings)

How the strategy money is split among the picks.

SettingRange or optionsUnitWhat it doesHigh valueLow value
Sizing
sizing.method
equal, inverse_vola choiceequal: every pick gets the same amount. inverse_vol: each pick gets an amount in proportion to one divided by its recent volatility, so calmer holdings get more.n/a (a choice)n/a (a choice)
Volatility window
sizing.vol_lookback_days
10 to 252trading daysDays of price history used to measure volatility for inverse_vol sizing. Ignored with equal sizing, though the bot still waits for this much history before it starts.A steadier, slower volatility estimate.A jumpier estimate that follows recent swings.

Exits (4 settings)

Rules that sell a stock before the next rebalance. Each is off when set to 0. They apply to stocks and funds the strategy picked, never to the index-fund core or the safe haven.

SettingRange or optionsUnitWhat it doesHigh valueLow value
Stop-loss
exit.stop_loss_pct
0 to 50 (0 = off)percentSells a stock that closes this far below the price paid. The order fills at the next open. The stock can be bought again at a later rebalance.A loose stop: it takes bigger losses before selling.A tight stop: it sells on small dips. 0 means no stop-loss.
Trailing stop
exit.trailing_stop_pct
0 to 50 (0 = off)percentSells a stock that closes this far below its highest close since it was bought.A loose stop that gives back more gains.A tight stop. 0 means off.
Take-profit
exit.take_profit_pct
0 to 300 (0 = off)percentSells a stock that closes this far above the price paid, locking in the gain.Lets winners run further.Sells winners early. 0 means off.
Max hold
exit.max_hold_days
0 to 500 (0 = off)trading daysSells a stock after it has been held this many trading days.Holds for a long time.Forces turnover. 0 means off.

What evolution can and can't change

Evolution can

  • Change any number, within its fixed range.
  • Switch between the listed options, such as ranking rules or safe havens.
  • Turn an exit rule on or off by setting it to 0.
  • Mix two parent cards, taking each whole group from one parent or the other.

Evolution cannot

  • Write or change code, or invent a new ranking rule.
  • Change the position caps, trading costs, the 35% kill switch or the next-open fills.
  • Choose the market. The arena (S&P 500, Nasdaq-100 or small caps) is set by where the bot is evolved.
  • See future prices, borrow money or sell short.