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:
Brandon Li
2026-09-26 16:04:15 -05:00
co-authored by Claude Opus 5.5
parent 49c4725e0c
commit 28f465508d
18 changed files with 3962 additions and 534 deletions
+47 -4
View File
@@ -1,7 +1,8 @@
# AutoFirmer
Automated futures trading dashboard for prop firm accounts via Tradovate and
TopstepX (ProjectX Gateway).
Automated trading dashboard for prop firm accounts via Tradovate and TopstepX
(ProjectX Gateway) for CME futures, and DXtrade for 24/7 crypto/CFD firms
(Tradeify247).
---
@@ -73,7 +74,7 @@ On first run, the SQLite database (`autotrader.sqlite`) is created automatically
Firms and their account types live on the master dashboard, not here — every
machine pulls the same catalog so they cannot drift apart. This machine only
stores the Tradovate login for each firm.
stores the platform login for each firm.
1. On the **master dashboard**, open **Firms**, add the firm, and give it one
account type per prefix + account size combination (profit target,
@@ -86,7 +87,10 @@ stores the Tradovate login for each firm.
**TopstepX** on the master asks for an API key instead (generated in the
TopstepX platform under Settings → API); the username is optional to store
but the ProjectX login needs it before the firm can connect, so add it when
you have it. Password is unused on TopstepX
you have it. Password is unused on TopstepX. A **DXtrade** firm asks for
its DXtrade username and password (the ones behind the key icon on the
firm's dashboard, not the dashboard login); the server URL and login domain
come from the master
4. Accounts populate once the firm connects. Each is matched to an account type
by its name prefix *and* its size, so a new account shows as **Unassigned**
until its opening funding transaction has been fetched. Use the **Account
@@ -94,6 +98,45 @@ stores the Tradovate login for each firm.
---
## DXtrade firms (Tradeify247)
A DXtrade firm is set up on the master's **Firms** page like any other, plus:
- **Server URL** (`https://dx.tradeify247.co/dxsca-web`) and **login domain**
(usually `default`). Changing the URL re-keys the firm's accounts.
- **Commission %** of notional per side (Tradeify: `0.04`). The engine prices
every fee off the fill with it.
- **Trades every day** — weekends and CME holidays included. Such a firm runs
in its own scheduler *lane*: its own trading hours (closed only around the
daily roll), its own wait-until-flat gate and its own batches, so a
multi-hour crypto position never holds up the futures open.
- **Symbol map** — which DXtrade symbols each CME root may trade as. A `*` row
covers every root (drain and extra-day legs trade `MNQ`, so map it or use
`*`). When a root lists several, the cheapest tradable one right now wins:
spread plus both commissions, divided by its recent hourly volatility.
- **Target hold hours** — size each leg's notional so its expected hold is
about this long (0 = the symbol map's fixed notional per $1,000 of leg), and
**financing %/day** if the firm charges swap.
Per account type: **Daily loss limit** (Tradeify: 3% of size — every leg then
carries a stop that keeps the firm's day inside it, less a 10% reserve and
fees) and **Max notional**.
Before the scheduler trades a DXtrade firm, run the smoke test against a real
login (with this instance's client for the firm disconnected):
```bash
DX_BASE=https://dx.tradeify247.co/dxsca-web DX_USER=… DX_PASS=… DX_SYMBOLS=BTC/USD,ETH/USD node scripts/dxtrade-smoke.mjs
```
It is read-only unless `DX_CONFIRM=yes DX_ACCOUNT=<code>` are set too, which
adds one minimum-size live round trip.
`npm run check` runs the pure-logic checks (fees, stops, sizing, trading
hours, the instrument selector).
---
## The master dashboard
Set **Instance Name** and **Dashboard URL** on the Settings page and this