Legs: cheapest symbol that reaches the target hold, last stands, a reserve that grows with size

- A batch sizes its leg on every mapped candidate, each at the leverage
  the broker states for it, and trades the cheapest (spread, commissions,
  expected swap) that reaches the target hold — else the quickest. The
  dashboard ranks the same way from a half-hourly candidate survey.
- Last stand: when a daily-loss stop-out would leave the account within
  15% of that loss above its max-drawdown floor (the account type's static
  max loss, or the broker's liquidation floor), the leg carries no
  daily-loss stop and is sized against the firm's own breach.
- The daily-loss reserve is 10% of the limit or 0.1% of the position,
  whichever is more, since a stop's slippage grows with the position.
- The account type's max notional is gone: the broker's margin rates cap
  each symbol. planLegSize holds the one sizing rule fireLeg, the pick and
  the dashboard share.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brandon Li
2026-09-26 18:26:12 -05:00
co-authored by Claude Opus 5.5
parent a2d9df5ba4
commit a2cd3a94c9
12 changed files with 477 additions and 172 deletions
+7 -4
View File
@@ -10,7 +10,7 @@ export interface AccountConfig {
minDayPnL: number;
minTradingDays: number;
accountSize: number;
maxLoss: number; // 0 = no limit; positive = account is "Dead" when loss exceeds this
maxLoss: number; // static max drawdown below the starting size (0 = none); with a hard daily loss, decides last stands
maxPositionSize: number; // 0 = no limit; positive = max contracts per trade
targetSameEquity: boolean; // if true, reduce profitTarget by priorProfit after withdrawal
splitEnabled: boolean; // false = big days trade as one unsplit leg instead of random ≥$500 pieces
@@ -30,10 +30,8 @@ export interface AccountConfig {
profitSplit?: number;
trailingDrawdown?: number;
/** Hard daily loss limit in dollars (0/absent = none): every leg carries a
* stop that keeps the firm's day inside it, less a 10% reserve and fees. */
* stop that keeps the firm's day inside it, less a reserve and fees. */
dailyLossLimit?: number;
/** Cap on one position's notional in dollars (0/absent = none). */
maxNotional?: number;
/** The firm trades every calendar day, weekends and CME holidays included. */
tradesEveryDay?: boolean;
}
@@ -107,7 +105,12 @@ export interface AccountState {
swapReserve: number;
/** The broker's leverage on the symbol (5 = 5:1); null when unstated. */
leverage: number | null;
/** Expected spread, commissions and swap for the leg. */
cost: number;
} | null;
/** The next leg rides without a daily-loss stop: a stop-out would leave
* the account too close to its max-drawdown floor to trade on. */
lastStand: boolean;
/** Actual profit target to hit — max(stage profit target, consistency realTarget = maxDay/consistency). */
effectiveProfitTarget: number | null;
/** Current cycle daily P&L — used for target calculations. */