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:
Brandon Li
2026-11-01 18:12:21 -06:00
co-authored by Claude Opus 5.5
parent 10da0ca83e
commit 7fb9ddbd96
9 changed files with 151 additions and 44 deletions
+5 -2
View File
@@ -14,6 +14,7 @@
import axios from './http-client';
import { errorMessage } from './platform-client';
import { SHARED_DEMO_HOST } from './tradovate-helpers';
interface ContractInfo {
id: number;
@@ -163,11 +164,13 @@ async function findHighestVolumeContract(
* For each symbol:
* 1. Fetch {PRODUCT}=F from Yahoo to learn the exchange suffix
* 2. Probe near-month Yahoo tickers and pick the highest-volume contract
* 3. Look up the chosen name on Tradovate to get the contract ID
* 3. Look up the chosen name on Tradovate to get the contract ID — on
* `host`, the token's own (TradovateClient.serviceHost())
*/
export async function resolveContracts(
symbols: string[],
accessToken: string,
host: string = SHARED_DEMO_HOST,
): Promise<Record<string, ResolvedContract | null>> {
const headers = { Authorization: `Bearer ${accessToken}` };
const results: Record<string, ResolvedContract | null> = {};
@@ -189,7 +192,7 @@ export async function resolveContracts(
try {
const res = await axios.get(
`https://demo.tradovateapi.com/v1/contract/suggest?t=${encodeURIComponent(chosenName ?? sym)}&l=10`,
`https://${host}/v1/contract/suggest?t=${encodeURIComponent(chosenName ?? sym)}&l=10`,
{ headers }
);
const contracts: ContractInfo[] = res.data ?? [];