Add full Next.js autotrader app with SQLite persistence and live Tradovate data

- SQLite DB (better-sqlite3) with firms, account_configs, firm_fees, instruments tables
- REST API routes: firms CRUD, account configs CRUD, state, accounts, instruments
- Live Tradovate WebSocket client: login, sync, positions, auto-liq thresholds
- Dashboard (app/page.tsx): per-firm account list with balance, day P&L, days traded,
  target progress, and Dead/Inactive/Flat status based on Tradovate auto-liq floors
- Account detail page: objectives progress, daily P&L chart, consistency tracking
- Per-firm settings page: account configs and instrument fee management
- Dead detection uses trailingMaxDrawdownLimit - trailingMaxDrawdown from
  userAccountAutoLiqs; filters Tradovate sentinel value (999999999 = no limit)
- FIFO P&L engine with commission accounting for daily P&L history
- Removed manual maxLoss fallback in favour of live Tradovate auto-liq data

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Senofy
2026-03-08 15:03:21 -05:00
co-authored by Claude Sonnet 4.6
parent a9b6acd479
commit dd18f91584
22 changed files with 2218 additions and 112 deletions
+13
View File
@@ -0,0 +1,13 @@
import { NextResponse } from 'next/server';
import { setInstrumentEnabled } from '@/lib/db';
export async function PATCH(
request: Request,
{ params }: { params: Promise<{ symbol: string }> }
) {
const { symbol } = await params;
const body = await request.json();
const ok = setInstrumentEnabled(symbol, !!body.enabled);
if (!ok) return NextResponse.json({ error: 'Not found' }, { status: 404 });
return NextResponse.json({ symbol, enabled: !!body.enabled });
}
+6
View File
@@ -0,0 +1,6 @@
import { NextResponse } from 'next/server';
import { getInstruments } from '@/lib/db';
export function GET() {
return NextResponse.json(getInstruments());
}