Skip to content

v1.0.0 — NexusTrade TypeScript SDK

Choose a tag to compare

@austin-starks austin-starks released this 27 Jul 14:56

Author NexusTrade trading strategies in typed TypeScript and backtest them on
the engine that runs them live.

npm install nexustrade
import {
  NexusTradeClient, always, backtest, buy, portfolio, stockAsset, strategy,
} from "nexustrade";

const client = new NexusTradeClient();

const book = portfolio("Example", [
  strategy("Buy SPY", always(), buy(stockAsset("SPY"), 100)),
]);

const operation = await client.createBacktest(
  backtest(book, { startDate: "2024-01-01", endDate: "2024-12-31" }),
  { idempotencyKey: "example-v1" },
);
console.log((await client.waitForBacktest(operation.id as string)).result);

What's in it

170+ generated builders. Indicators, conditions, and actions are generated
from the same specification the engine executes, so a book is structurally
valid before it leaves the process — and fully typed, so your editor completes
the whole surface.

Backtests, optimizations, and walk-forward studies. Every job kind reports
the same {id, kind, status, result?, error?} envelope, so one poller serves
all of them. Submissions are idempotent — a retry with the same key returns the
original operation instead of launching a second paid job.

Agent runs. Iterate a run and answer it when it blocks for plan approval,
action approval, or input.

Lake SQL. Read-only SQL over the market-data catalog, returned as Parquet.

Your own data. Create a custom data source, seed it, and grow it without
leaving the SDK:

const series = await client.createCustomIndicator(
  {
    name: "WSB NVDA Mentions",
    scope: "asset",
    points: [{ timestamp: "2024-04-01", value: 152, ticker: "NVDA" }],
  },
  { idempotencyKey: "wsb-mentions-v1" },
);
gt(CustomIndicator(stockAsset("NVDA"), String(series.customIndicatorId)), 100);

Point batches are unlimited in size. A batch that fits the request is sent with
it; a larger one is uploaded to storage and validated server-side, and the
returned indicator reflects what landed either way. An upload interrupted after
its bytes arrive resumes at polling rather than re-sending. Recurring
collection appends to the same series with appendCustomIndicatorPoints.

Notes

Zero runtime dependencies. ESM and CommonJS builds ship together, with types.
Node 18+.

Requires an API key from https://nexustrade.io/developers, read from
NEXUSTRADE_API_KEY / NEXUSTRADE_API_BASE_URL or a local .env.