Skip to content

Place Trades

Once a user has a connected brokerage, you can launch the trade modal with details of any order prefilled. With just 1 click, users can execute the trade on their brokerage.

How It Works

  1. Your server requests an authenticated trade session URL.
  2. Your client-side app opens the trade modal via the SDK.
  3. You pass a trade configuration (simple or options/multi-leg).
  4. The user reviews and sends the order to their brokerage.

Server-side: Request a Trade Session URL

Call Trade It's API server-side to get a url to the trade portal. The URL is pre-authenticated so the user does not need to log in.

Request

http
POST <api endpoint>/api/session/url
Content-Type: application/json
Authorization: Bearer <user's trade it access token>

{
  "target": "trade"
}

Response

json
{
  "url": "https://tradeit.app/t/[ticker]?token=ti:...&embedded=1",
  "expiresAt": "2026-02-27T19:35:12.000Z",
  "feature": "trade",
  "placeholder": "[ticker]"
}

Trade It returns an authenticated trade URL template.

Client-side: Open the Trade Modal (Simple Trade)

tsx
import { useState } from 'react';
import {
  OrderType,
  TradeAction,
  TradeItModal,
  TradeType,
  TradeUnit,
} from '@trade-it/react';

function BuyButton() {
  const [open, setOpen] = useState(false);
  const [tradeUrl, setTradeUrl] = useState<string | null>(null);

  async function openTrade() {
    const res = await fetch('/your-server/tradeit/trade');
    const data = await res.json();
    setTradeUrl(data.url);
    setOpen(true);
  }

  return (
    <>
      <button onClick={openTrade}>Buy/Sell</button>
      {tradeUrl && (
        <TradeItModal
          open={open}
          onOpenChange={setOpen}
          launch={{
            mode: 'trade',
            url: tradeUrl,
            config: {
              tradeType: TradeType.Simple,
              ticker: 'AAPL',
              action: TradeAction.Buy,
              amount: 100,
              unit: TradeUnit.Dollars,
              orderType: OrderType.Market,
            },
          }}
        />
      )}
    </>
  );
}

Note: The same modal supports options orders too. Pass a multi-leg config and Trade It opens directly into the options workflow with details prefilled.

Examples

Use these examples of common scenarios as jumping off point.

Example 1: Buy in Dollars

Buy shares of an asset.

tsx
tradeIt.openTrade({
  launch: {
    mode: 'trade',
    url: tradeUrl,
    config: {
      tradeType: TradeType.Simple,
      ticker: 'AAPL',
      action: TradeAction.Buy,
      amount: 100,
      unit: TradeUnit.Dollars,
      orderType: OrderType.Market,
    },
  },
});
Buy order screen inside the Trade It trade modal
Buy $100 of Apple stock.

Example 2: Sell in Shares with Stop-Limit

Sell shares while setting both stop and limit prices.

tsx
tradeIt.openTrade({
  launch: {
    mode: 'trade',
    url: tradeUrl,
    config: {
      tradeType: TradeType.Simple,
      ticker: 'AAPL',
      action: TradeAction.Sell,
      amount: 10,
      unit: TradeUnit.Shares,
      orderType: OrderType.StopLimit,
      stopPrice: 260,
      limitPrice: 250,
    },
  },
});
Sell order screen inside the Trade It trade modal
Sell 10 shares of Apple with stop and limit prices set.

Example 3: Multi-Leg Options

Open an options strategy with prefilled legs.

tsx
tradeIt.openTrade({
  launch: {
    mode: 'trade',
    url: tradeUrl,
    config: {
      tradeType: TradeType.MultiLeg,
      ticker: 'MSFT',
      orderType: OrderType.Market,
      timeInForce: TimeInForce.GoodTillCanceled,
      legs: [
        {
          type: LegType.Option,
          action: TradeAction.Sell,
          positionEffect: PositionEffect.Open,
          occ: '270617C00390000',
          quantity: 5,
        },
        {
          type: LegType.Option,
          action: TradeAction.Buy,
          positionEffect: PositionEffect.Open,
          occ: '270617C00420000',
          quantity: 5,
        },
      ],
    },
  },
});
Multi-leg options order screen inside the Trade It trade modal
Open a Microsoft debit spread with prefilled legs.

Config Parameters (launch.config)

Configure a particular trade using the parameters below:

See all enum values on SDK Enums Reference.

FieldMeaningType / EnumUsed InDefaultNotes
tickerAsset symbolstringsimple optionsRequired. Example: AAPL, BTC-USD
tradeTypeTrade typeTradeTypesimple optionsTradeType.SimpleUse TradeType.MultiLeg for options/multi-leg
actionBuy or sellTradeActionsimpleTradeAction.BuySimple trades only
amountTrade amountnumbersimple100Interpreted by unit
unitAmount unitTradeUnitsimpleTradeUnit.DollarsDollars or Shares
orderTypeOrder typeOrderTypesimple optionsOrderType.Marketmarket, limit, stop, stop_limit
limitPriceLimit pricenumbersimple optionsUsed for limit / stop_limit
stopPriceStop trigger pricenumbersimple optionsUsed for stop / stop_limit
timeInForceOrder durationTimeInForcesimple optionsTimeInForce.DayDay, GoodTillCanceled, ImmediateOrCancel, FillOrKill
legsOptions leg payloadTradeItMultiLegTradeLegConfig[]optionsRequired for options/multi-leg trades
legs[].typeLeg typeLegTypeoptionsOption or Equity
legs[].actionLeg actionTradeActionoptionsBuy or Sell
legs[].positionEffectPosition effectPositionEffect | nulloptionsnullUsually Open / Close; null for equity legs
legs[].occOCC contract stringstring | nulloptionsRequired for option legs
legs[].quantityLeg quantitynumberoptions1Contracts for options, shares for equity legs