Lucid's users moved to their own Tradovate hosts (demo-api.lucid.ninjatrader.com, seen 2026-11-01). The login still answers on live.tradovateapi.com, but the shared demo socket drops a Lucid session right after its authorize (close 1006, no status), so every Lucid firm sat at "Connecting…" on every machine. The login answer now names the hosts (apiHosts, orgName "LucidTrading"), and the web trader follows them. A Tradovate client now opens its socket and makes its account, contract, fee and report calls on the hosts its own login names; a login without apiHosts, or with a value that isn't a plain host name, keeps demo.tradovateapi.com and rpt-demo.tradovateapi.com. A renewal answer without apiHosts keeps the login's. The shared contract cache still resolves with a client on the shared hosts when there is one; a client on its organization's own only stands in. Login, renewal and the quote feed are unchanged: Lucid's live and md hosts are the shared ones. The debug routes follow the same hosts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
41 lines
1.5 KiB
TypeScript
41 lines
1.5 KiB
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
import { contractLookupToken } from '@/lib/clients';
|
|
import { futuresRootsHere } from '@/lib/instruments';
|
|
import { resolveContracts, getAllCachedContracts } from '@/lib/contract-resolver';
|
|
|
|
/**
|
|
* GET /api/instruments/contracts
|
|
* Returns cached resolved contracts (fast, no external calls).
|
|
*/
|
|
export async function GET() {
|
|
return NextResponse.json(getAllCachedContracts());
|
|
}
|
|
|
|
/**
|
|
* POST /api/instruments/contracts
|
|
* Triggers a fresh resolve via Tradovate + Yahoo Finance.
|
|
* Body (optional): { symbols: string[] } — when provided, resolves only those symbols.
|
|
* Otherwise resolves every root this machine's futures firms list.
|
|
*/
|
|
export async function POST(req: NextRequest) {
|
|
try {
|
|
const lookup = contractLookupToken();
|
|
if (!lookup) {
|
|
return NextResponse.json({ error: 'No authenticated client available' }, { status: 503 });
|
|
}
|
|
|
|
const body = await req.json().catch(() => ({}));
|
|
const requestedSymbols: string[] | undefined = Array.isArray(body?.symbols) ? body.symbols : undefined;
|
|
|
|
const symbols = requestedSymbols?.length
|
|
? requestedSymbols
|
|
: futuresRootsHere();
|
|
|
|
const resolved = await resolveContracts(symbols, lookup.token, lookup.host);
|
|
return NextResponse.json(resolved);
|
|
} catch (err: any) {
|
|
console.error('[POST /api/instruments/contracts]', err);
|
|
return NextResponse.json({ error: err?.message ?? 'Resolve failed' }, { status: 500 });
|
|
}
|
|
}
|