Trading

Place multi-leg option order

post
https://api.snaptrade.com/api/v1/accounts/{accountId}/trading/options

Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support

Execute an API Request

Path
accountIdstring (format: uuid)required

Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade.

Query
userIdstringrequired

SnapTrade User ID. This is chosen by the API partner and can be any string that is a) unique to the user, and b) immutable for the user. It is recommended to NOT use email addresses for this property because they are usually not immutable.

userSecretstringrequired

SnapTrade User Secret. This is a randomly generated string and should be stored securely. If compromised, please rotate it via the rotate user secret endpoint.

Request Body
order_typestringrequired

The type of order to place.

time_in_forcestringrequired

The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. Here are the supported values:

  • Day - Day. The order is valid only for the trading day on which it is placed.
  • GTC - Good Til Canceled. The order is valid until it is executed or canceled.
  • FOK - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely.
  • IOC - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled.
limit_pricestring (format: decimal) or null

The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT.

stop_pricestring (format: decimal) or null

The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT.

legsarray of objectsrequired
object 1
instrumentobjectrequired
symbolstringrequired

The security's trading ticker symbol. This currently supports stock symbols and Options symbols in the 21 character OCC format. For example AAPL 131124C00240000 represents a call option on AAPL expiring on 2024-11-13 with a strike price of $240. For more information on the OCC format, see here

instrument_typestringrequired

The instrument's type

actionstringrequired

The action describes the intent and side of a trade. For equities, this is either BUY or SELL. For options, this is one of BUY_TO_OPEN, BUY_TO_CLOSE, SELL_TO_OPEN, SELL_TO_CLOSE.

unitsintegerrequired

The quantity to trade. For options this represents the number of contracts. For equity this represents the number of shares.

Authorization
Request
Installation
$
npm install snaptrade-typescript-sdk
1
import { Snaptrade } from "snaptrade-typescript-sdk";
2
3
const snaptrade = new Snaptrade({
4
clientId: "PARTNER_CLIENT_ID",
5
consumerKey: "CONSUMER_KEY",
6
});
7
8
const response =
9
await snaptrade.trading.placeMlegOrder({
10
accountId:
11
"917c8734-8470-4a3e-a18f-57c3f2ee6631",
12
userId: "snaptrade-user-123",
13
userSecret:
14
"adf2aa34-8219-40f7-a6b3-60156985cc61",
15
order_type: "MARKET",
16
time_in_force: "Day",
17
legs: [
18
{
19
instrument: {
20
symbol: "PBI 250718C00006000",
21
instrument_type: "INSTRUMENT_TYPE",
22
},
23
action: "BUY_TO_OPEN",
24
units: 1,
25
},
26
],
27
});
28
console.log(response.data);

Response fields

object
brokerage_order_idstring

Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system.

ordersarray of objects
1
{
2
"brokerage_order_id": "66a033fa-da74-4fcf-b527-feefdec9257e",
3
"orders": [
4
{
5
"brokerage_order_id": "66a033fa-da74-4fcf-b527-feefdec9257e",
6
"status": "NONE",
7
"universal_symbol": {
8
"id": "2bcd7cc3-e922-4976-bce1-9858296801c3",
9
"symbol": "VAB.TO",
10
"raw_symbol": "VAB",
11
"description": "VANGUARD CDN AGGREGATE BOND INDEX ETF",
12
"currency": {
13
"id": "87b24961-b51e-4db8-9226-f198f6518a89",
14
"code": "USD",
15
"name": "US Dollar"
16
},
17
"exchange": {
18
"id": "2bcd7cc3-e922-4976-bce1-9858296801c3",
19
"code": "TSX",
20
"mic_code": "XTSE",
21
"name": "Toronto Stock Exchange",
22
"timezone": "America/New_York",
23
"start_time": "09:30:00",
24
"close_time": "16:00:00",
25
"suffix": ".TO"
26
},
27
"type": {
28
"id": "2bcd7cc3-e922-4976-bce1-9858296801c3",
29
"code": "cs",
30
"description": "Common Stock",
31
"is_supported": true
32
},
33
"figi_code": "BBG000B9XRY4",
34
"figi_instrument": {
35
"figi_code": "BBG000B9Y5X2",
36
"figi_share_class": "BBG001S5N8V8"
37
},
38
"currencies": [
39
{
40
"id": "87b24961-b51e-4db8-9226-f198f6518a89",
41
"code": "USD",
42
"name": "US Dollar"
43
}
44
]
45
},
46
"option_symbol": {
47
"id": "2bcd7cc3-e922-4976-bce1-9858296801c3",
48
"ticker": "AAPL 261218C00240000",
49
"option_type": "CALL",
50
"strike_price": 240,
51
"expiration_date": "2026-12-18",
52
"is_mini_option": false,
53
"underlying_symbol": {
54
"id": "2bcd7cc3-e922-4976-bce1-9858296801c3",
55
"symbol": "SPY",
56
"raw_symbol": "VAB",
57
"description": "SPDR S&P 500 ETF Trust",
58
"currency": {
59
"id": "87b24961-b51e-4db8-9226-f198f6518a89",
60
"code": "USD",
61
"name": "US Dollar"
62
},
63
"exchange": {
64
"id": "2bcd7cc3-e922-4976-bce1-9858296801c3",
65
"code": "ARCX",
66
"mic_code": "ARCA",
67
"name": "NYSE ARCA",
68
"timezone": "America/New_York",
69
"start_time": "09:30:00",
70
"close_time": "16:00:00",
71
"suffix": "None",
72
"allows_cryptocurrency_symbols": false
73
},
74
"type": {
75
"id": "2bcd7cc3-e922-4976-bce1-9858296801c3",
76
"code": "cs",
77
"description": "Common Stock",
78
"is_supported": true
79
},
80
"figi_code": "BBG000B9XRY4",
81
"figi_instrument": {
82
"figi_code": "BBG000B9Y5X2",
83
"figi_share_class": "BBG001S5N8V8"
84
},
85
"currencies": [
86
{
87
"id": "87b24961-b51e-4db8-9226-f198f6518a89",
88
"code": "USD",
89
"name": "US Dollar"
90
}
91
]
92
}
93
},
94
"quote_universal_symbol": {
95
"id": "2bcd7cc3-e922-4976-bce1-9858296801c3",
96
"symbol": "VAB.TO",
97
"raw_symbol": "VAB",
98
"description": "VANGUARD CDN AGGREGATE BOND INDEX ETF",
99
"currency": {
100
"id": "87b24961-b51e-4db8-9226-f198f6518a89",
101
"code": "USD",
102
"name": "US Dollar"
103
},
104
"exchange": {
105
"id": "2bcd7cc3-e922-4976-bce1-9858296801c3",
106
"code": "TSX",
107
"mic_code": "XTSE",
108
"name": "Toronto Stock Exchange",
109
"timezone": "America/New_York",
110
"start_time": "09:30:00",
111
"close_time": "16:00:00",
112
"suffix": ".TO"
113
},
114
"type": {
115
"id": "2bcd7cc3-e922-4976-bce1-9858296801c3",
116
"code": "cs",
117
"description": "Common Stock",
118
"is_supported": true
119
},
120
"figi_code": "BBG000B9XRY4",
121
"figi_instrument": {
122
"figi_code": "BBG000B9Y5X2",
123
"figi_share_class": "BBG001S5N8V8"
124
},
125
"currencies": [
126
{
127
"id": "87b24961-b51e-4db8-9226-f198f6518a89",
128
"code": "USD",
129
"name": "US Dollar"
130
}
131
]
132
},
133
"quote_currency": {
134
"id": "87b24961-b51e-4db8-9226-f198f6518a89",
135
"code": "USD",
136
"name": "US Dollar"
137
},
138
"action": "string",
139
"total_quantity": 100,
140
"open_quantity": 10,
141
"canceled_quantity": 10,
142
"filled_quantity": 80,
143
"execution_price": 12.34,
144
"limit_price": 12.34,
145
"stop_price": 12.5,
146
"order_type": "Market",
147
"time_in_force": "string",
148
"time_placed": "2024-07-30T22:51:49.746Z",
149
"time_updated": "2024-08-05T00:05:57.409Z",
150
"time_executed": "2024-08-05T00:05:57.409Z",
151
"expiry_date": "2024-08-05T00:05:57.409Z",
152
"symbol": "2bcd7cc3-e922-4976-bce1-9858296801c3",
153
"child_brokerage_order_ids": {
154
"take_profit_order_id": "12345678",
155
"stop_loss_order_id": "12345678"
156
}
157
}
158
]
159
}