Tradovate: each login's calls go to the hosts its organization is served from
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>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
10da0ca83e
commit
7fb9ddbd96
@@ -4,6 +4,7 @@ import { getTradableFirms } from '@/lib/firm-catalog';
|
||||
import { getAccountConfig } from '@/lib/account-type-resolver';
|
||||
import { combineCmeSessions, computeDayPlan, resolveEffectiveConfig, currentTradeDateCT } from '@/lib/trading-logic';
|
||||
import axios from '@/lib/http-client';
|
||||
import { SHARED_DEMO_HOST, SHARED_DEMO_REPORTING_HOST } from '@/lib/tradovate-helpers';
|
||||
|
||||
/**
|
||||
* Per-account snapshot of everything computeDayPlan sees, plus the book-balance
|
||||
@@ -152,13 +153,16 @@ export async function PATCH(req: Request) {
|
||||
return NextResponse.json({ error: 'no token for firmId ' + firmId }, { status: 400 });
|
||||
}
|
||||
const headers = { Authorization: `Bearer ${client.accessInfo.accessToken}` };
|
||||
// The firm's own hosts when its login named them (Lucid's).
|
||||
const serviceHost: string = client.serviceHost?.() ?? SHARED_DEMO_HOST;
|
||||
const reportingHost: string = client.reportingHost?.() ?? SHARED_DEMO_REPORTING_HOST;
|
||||
|
||||
// Full report cycle
|
||||
if (payload.action === 'report') {
|
||||
const { account, startDate, endDate, name: reportName = 'Fills' } = payload;
|
||||
try {
|
||||
let reportData = (await axios.post(
|
||||
'https://rpt-demo.tradovateapi.com/v1/reports/requestreport',
|
||||
`https://${reportingHost}/v1/reports/requestreport`,
|
||||
{
|
||||
name: reportName, representationType: 'json', timezone: -300,
|
||||
params: [
|
||||
@@ -178,7 +182,7 @@ export async function PATCH(req: Request) {
|
||||
const wait: number = Math.max(1, reportData['p-time'] ?? 1);
|
||||
await new Promise((r) => setTimeout(r, wait * 1000));
|
||||
reportData = (await axios.get(
|
||||
'https://rpt-demo.tradovateapi.com/v1/reports/getreport',
|
||||
`https://${reportingHost}/v1/reports/getreport`,
|
||||
{ params: { 'p-ticket': ticket }, headers }
|
||||
)).data;
|
||||
attempts++;
|
||||
@@ -207,7 +211,7 @@ export async function PATCH(req: Request) {
|
||||
|
||||
// Generic proxy
|
||||
const { path, url: rawUrl, method = 'GET', body: reqBody } = payload;
|
||||
const url = rawUrl ?? `https://demo.tradovateapi.com/v1/${path}`;
|
||||
const url = rawUrl ?? `https://${serviceHost}/v1/${path}`;
|
||||
try {
|
||||
const res = method === 'POST'
|
||||
? await axios.post(url, reqBody, { headers })
|
||||
|
||||
Reference in New Issue
Block a user