Examples

Runnable scripts ship in the npm tarball under node_modules/@tria-sdk/api-trading/examples/. Copy one out, fill in your env vars, and run it directly.

ScriptDemonstrates
place-order.tsPlace + cancel an HL limit order; cloid generation.
cancel-order.tsCancel by clientOrderId; idempotency on the second cancel.
subscribe-fills.tsLive HL fill stream + the onConnection lifecycle hook.
multi-venue.tsFan-out fills from HL + Decibel into one position-tracking loop via the normalized Fill shape.
market-data.tsEnd-to-end pre-trade flow: markets(), top-of-book + candles, round price to tick, place + cancel, account snapshot.
subscribe-orders-and-account.tsLive order lifecycle + account snapshot streams together; clean unsubscribe on SIGINT.
batch-modify-tpsl.tsplaceBatch (IOC + 2 GTCs in one signed action), attachTpSl, modifyOrder, cleanup close.

Run one

# Run straight from the installed package:
npx tsx node_modules/@tria-sdk/api-trading/examples/place-order.ts

Or copy a script into your project and adapt it:

cp node_modules/@tria-sdk/api-trading/examples/place-order.ts ./my-first-bot.ts
# ...edit, then:
npx tsx my-first-bot.ts

Each script reads its credentials from TRIA_TRADE_* env vars — see Credentials to mint them, then source your .env before running:

set -a; source ./tria.env; set +a
npx tsx node_modules/@tria-sdk/api-trading/examples/market-data.ts

Was this page helpful?