DXtrade platform for Tradeify247: percent fees, hard daily-loss stops, volatility sizing, every-day lanes
- DXtrade client (lib/dxtrade-class.ts): REST session login with lockout-safe backoff, 60s sync of accounts/metrics/positions/orders/transfers, history and fund transactions from cash transactions, day-start balance at the 22:00 UTC reset, CLOSE-by-positionCode exits (native OCO group, else a stop-first emulated pair), a cross-account hedge guard, stray-order reaper. - Instrument selector: the firm's symbol map lists candidate symbols per CME root; the cheapest tradable one per unit of recent hourly volatility wins (spread + 2x commission [+ financing] / sigma). - Fees: a firm's commission % of notional prices every fee off the fill; the take-profit is solved in closed form so the leg nets its target. - Hard daily loss limit per account type: every leg carries a stop keeping the firm's day inside the limit less a 10% reserve and both fees (rounded in); a green day never widens it; no room or a refused bracket flattens. - Notional sizing where the platform prices positions: target-hold volatility sizing or the symbol map's fixed notional, under a per-type notional cap. - Every-day firms trade weekends/holidays; the scheduler runs lanes (futures, one per DXtrade firm) with their own hours, flat gate, mutex and batches. - The catalog sync skips platforms this build doesn't know instead of treating them as Tradovate. One shared fireLeg replaces the duplicated batch/copy code. - npm run check: fee/stop/sizing/hours/selector checks; scripts/dxtrade-smoke.mjs confirms the API against a real login before trading. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
49c4725e0c
commit
28f465508d
@@ -1,3 +1,5 @@
|
||||
import type { FirmPlatform } from './lib/master-protocol';
|
||||
|
||||
export interface AccountConfig {
|
||||
/** Master's account type id — what a manual assignment pins to. */
|
||||
id: string;
|
||||
@@ -27,6 +29,13 @@ export interface AccountConfig {
|
||||
payoutCap?: number;
|
||||
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. */
|
||||
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;
|
||||
}
|
||||
|
||||
export interface FirmConfig {
|
||||
@@ -35,12 +44,12 @@ export interface FirmConfig {
|
||||
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';
|
||||
platform: FirmPlatform;
|
||||
/** Blank when this machine has no credentials for the firm. */
|
||||
username: string;
|
||||
/** 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. */
|
||||
/** True once the platform's credentials are stored locally — a username +
|
||||
* password (Tradovate, DXTrade) 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
|
||||
@@ -76,10 +85,15 @@ export interface AccountState {
|
||||
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.
|
||||
* null = the next trade rides stopless (options off, big non-first day,
|
||||
* or a make-back day after a loss). */
|
||||
/** Dollars of price movement the next trade may lose before its stop
|
||||
* fires — the tighter of the obfuscation stop and the hard daily-loss
|
||||
* stop, before fees. null = the next trade rides stopless (options off,
|
||||
* big non-first day, or a make-back day after a loss, with no daily
|
||||
* loss limit). */
|
||||
nextStop: number | null;
|
||||
/** What the firm's day may still lose before a hard daily-loss breach.
|
||||
* null = no daily loss limit (or its day-start balance isn't known yet). */
|
||||
dllRoom: number | null;
|
||||
/** 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. */
|
||||
|
||||
Reference in New Issue
Block a user