Add TopstepX platform support, drain withdrawal stages, and perfect-path calendar projection

- TopstepXClient (ProjectX Gateway): API-key auth, SignalR user hub,
  Trade/search daily P&L, emulated OCO exits, books-invariant
  withdrawal detection for $0-start accounts
- Platform-aware client pool, credentials (api_key column), and
  credential form; $0-size account types match by prefix alone
- Drain stages: min-day ($5-$15 randomized) MNQ legs for the
  configured days, then wait for the 50% withdrawal; stage pills
  show 'Stage N – Drain'
- Account calendar projects the perfect path: future days book their
  planned targets, simulated 50% withdrawals, payout marker

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Brandon Li
2026-09-12 16:25:52 -05:00
co-authored by Claude Fable 5
parent 1bca441247
commit 50a5eb4713
21 changed files with 1854 additions and 142 deletions
+9 -3
View File
@@ -16,17 +16,21 @@ export interface AccountConfig {
firstDayStop: boolean; // first cycle day carries a $1,000 account stop - books red and ends
minDayStop: boolean; // min-day trades carry a 2x-target stop; next day after a loss rides stopless
combineCmeHolidays: boolean; // true = CME holiday sessions count with the next full trading day (Apex-style)
withdrawalStages: { profit: number; consistency: number; minTradingDays: number }[]; // per-stage fresh profit + consistency (empty = use base values)
withdrawalStages: { profit: number; consistency: number; minTradingDays: number; drain?: boolean; minDayPnL?: number }[]; // per-stage fresh profit + consistency (empty = use base values); drain = spam-withdraw stage
}
export interface FirmConfig {
/** Master's firm id (uuid). */
id: string;
firm: string;
/** Which platform the firm's accounts trade on — decides both which client
* drives it and which credential fields the dashboard asks for. */
platform: 'tradovate' | 'topstepx';
/** Blank when this machine has no credentials for the firm. */
username: string;
/** True once a Tradovate username and password are stored locally. Firms
* without them are shown greyed out with an inline credential form. */
/** True once the platform's credentials are stored locally — Tradovate
* username + password, or a TopstepX API key. Firms without them are
* shown greyed out with an inline credential form. */
hasCredentials: boolean;
bannedSymbols: string[];
/** The firm's account types, straight from the catalog. Doubles as the
@@ -54,6 +58,8 @@ export interface AccountState {
personalDll: boolean;
/** Current stage = 1 + number of withdrawals (negative fund transactions). Stage 1 = fresh account. */
stage: number;
/** True when the current stage is a drain stage (spam-withdraw mode). */
stageDrain: boolean;
/** Next trading day's target, computed server-side. null when account is dead or config is missing. */
dailyTarget: { amount: number; path: 'first_day' | 'normal_day' | 'reduced_day' } | null;
/** Dollars the next trade may lose before its obfuscation stop fires.