Open a section from the left

Research grid, backtest, and strategy instances

FactorLab sweeps a fixed grid of factor kind, window, and horizon over a quote tape. sweep covers kinds 2, 4, 5, 6, 7, and 8, windows 4/8/16/32/64, and horizons 1/4/16, which is 90 rows; pass a buffer of at least kMaxRows (96) and it returns the row count. eval_combo evaluates one combination. Each LabRow carries n, ic_ppm, rank_ic_ppm, hit_ppm, top_ppm, bottom_ppm, turnover_ppm, icir_milli, and score_ppm; the ICIR splits [t_begin,t_end) into eight segments and divides the mean segment rank IC by its deviation. sort orders by score and then by absolute rank IC, both descending. pick takes the 75th percentile of |factor| (at least 1) as the threshold and the sign of the rank IC, and fills LabPick with sign, threshold_ppm, trigger, and ready.

Backtester<Cap> replays one instrument from ticks. run(tape, n, cfg, out) reads every tick into the factor engine and evaluates every stride ticks. The target is sign * factor: at or above threshold_ppm it is +qty, at or below the negative it is -qty, otherwise flat. A buy pays ask + slip_ticks * tick, a sell receives bid - slip_ticks * tick, and a side without a valid touch skips that rebalance. Fees are notional * fee_ppm / 1e6, rounded up and raised to min_fee. BtMetrics reports points, trades, round_trips, wins, gross_pnl, fees, net_pnl, turnover, return_ppm, annual_ppm, sharpe_ppm, max_dd_ppm, win_ppm, exposure_ppm, final_equity, peak_equity, and span_us. curve copies the sampled equity and drawdown points in time order, at most Cap. Invalid parameters (window outside 2..256, qty <= 0, cash <= 0) or fewer than two usable samples return false.

StrategyRegistry holds eight strategy instances. A StratSpec names an id, account, instrument, factor kind and window, sign, threshold, quantity, cooldown, and mode; a slot moves Idle -> Running -> Paused -> Running and to Stopped, with Failed as the error state. submit pushes a StratCmd into a fixed 32-entry SPSC ring from the HTTP side, take drains it on the trading side, and apply returns the slot or -1 with a reason in the row note. Add rejects a duplicate id or a full table; a command carrying the other mode's env is refused. publish and read move a StratRow through a seqlock, so readers never see a torn row. save writes the configuration for a worker or shutdown path; the trading thread never touches a file. The SimNow example wraps the cold path in examples/simnow/jobs.hpp: one worker thread, an eight-entry request ring, seqlock-published results, and a deterministic synthetic tape when the tape file is missing.