Basic Example

import {
  createClientConfig,
  limitOrder,
  PushClient,
  QuoteClient,
  TradeClient,
} from '@tigeropenapi/tigeropen';

async function main(): Promise<void> {
  const config = createClientConfig();
  const quote = QuoteClient.fromConfig(config);
  const trade = TradeClient.fromConfig(config, config.account, config.secretKey);

  const states = await quote.getMarketState('US');
  const positions = await trade.getPositions({ market: 'US' });
  const request = limitOrder(config.account, 'AAPL', 'STK', 'BUY', 1, 150);
  const preview = await trade.previewOrder(request);

  const push = new PushClient(config);
  push.setCallbacks({ onError: console.error });
  console.log(states, positions, preview?.isPass, push.state);
}

void main();

This example previews but does not submit an order. Read Orders and Trading Rules before live trading.


Did this page help you?