snaptrade-typescript-sdk 10.0.18 → 11.0.0-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -383
- package/dist/browser.umd.js +2 -2
- package/dist/index.cjs +3295 -1850
- package/dist/index.d.cts +1328 -1275
- package/dist/index.d.mts +1328 -1275
- package/dist/index.d.ts +1328 -1275
- package/dist/index.mjs +3293 -1851
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
Connect brokerage accounts to your app for live positions and trading
|
|
8
8
|
|
|
9
|
-
[](https://www.npmjs.com/package/snaptrade-typescript-sdk/v/11.0.0-canary.1)
|
|
10
10
|
[](https://snaptrade.com/)
|
|
11
11
|
|
|
12
12
|
</div>
|
|
@@ -124,15 +124,15 @@ yarn add snaptrade-typescript-sdk
|
|
|
124
124
|
## Getting Started<a id="getting-started"></a>
|
|
125
125
|
|
|
126
126
|
```typescript
|
|
127
|
-
const { Snaptrade } = require("snaptrade-typescript-sdk");
|
|
128
|
-
const { randomUUID } = require("crypto");
|
|
129
|
-
const readline = require("readline");
|
|
127
|
+
const { Snaptrade, SnaptradeAuth } = require("snaptrade-typescript-sdk");
|
|
130
128
|
|
|
131
129
|
async function main() {
|
|
132
130
|
// 1) Initialize a client with your clientID and consumerKey.
|
|
133
131
|
const snaptrade = new Snaptrade({
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
auth: SnaptradeAuth.commercialApiKey({
|
|
133
|
+
consumerKey: process.env.SNAPTRADE_CONSUMER_KEY,
|
|
134
|
+
clientId: process.env.SNAPTRADE_CLIENT_ID,
|
|
135
|
+
}),
|
|
136
136
|
});
|
|
137
137
|
|
|
138
138
|
// 2) Check that the client is able to make a request to the API server.
|
|
@@ -140,51 +140,32 @@ async function main() {
|
|
|
140
140
|
console.log("status:", status.data);
|
|
141
141
|
|
|
142
142
|
// 3) Create a new user on SnapTrade
|
|
143
|
-
const userId =
|
|
144
|
-
const
|
|
143
|
+
const userId = uuid();
|
|
144
|
+
const { userSecret } = (
|
|
145
145
|
await snaptrade.authentication.registerSnapTradeUser({
|
|
146
146
|
userId,
|
|
147
147
|
})
|
|
148
148
|
).data;
|
|
149
|
-
console.log("registerResponse:", registerResponse);
|
|
150
149
|
|
|
151
150
|
// Note: A user secret is only generated once. It's required to access
|
|
152
151
|
// resources for certain endpoints.
|
|
153
|
-
|
|
152
|
+
console.log("userSecret:", userSecret);
|
|
154
153
|
|
|
155
154
|
// 4) Get a redirect URI. Users will need this to connect
|
|
156
|
-
|
|
157
|
-
const redirectURI = (
|
|
155
|
+
const data = (
|
|
158
156
|
await snaptrade.authentication.loginSnapTradeUser({ userId, userSecret })
|
|
159
157
|
).data;
|
|
160
|
-
|
|
158
|
+
if (!("redirectURI" in data)) throw Error("Should have gotten redirect URI");
|
|
159
|
+
console.log("redirectURI:", data.redirectURI);
|
|
161
160
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
// 5) Get a list of connections
|
|
167
|
-
const connections = (
|
|
168
|
-
await snaptrade.connections.listBrokerageAuthorizations({
|
|
161
|
+
// 5) Obtaining account holdings data
|
|
162
|
+
const holdings = (
|
|
163
|
+
await snaptrade.accountInformation.getAllUserHoldings({
|
|
169
164
|
userId,
|
|
170
165
|
userSecret,
|
|
171
166
|
})
|
|
172
167
|
).data;
|
|
173
|
-
console.log("
|
|
174
|
-
|
|
175
|
-
// 6) Get a list of accounts for the first connection, if available
|
|
176
|
-
if (!Array.isArray(connections) || connections.length === 0) {
|
|
177
|
-
console.log("No brokerage connections found for the user.");
|
|
178
|
-
} else {
|
|
179
|
-
const accounts = (
|
|
180
|
-
await snaptrade.connections.listBrokerageAuthorizationAccounts({
|
|
181
|
-
authorizationId: connections[0].id,
|
|
182
|
-
userId,
|
|
183
|
-
userSecret,
|
|
184
|
-
})
|
|
185
|
-
).data;
|
|
186
|
-
console.log("accounts:", accounts);
|
|
187
|
-
}
|
|
168
|
+
console.log("holdings:", holdings);
|
|
188
169
|
|
|
189
170
|
// 6) Deleting a user
|
|
190
171
|
const deleteResponse = (
|
|
@@ -193,17 +174,26 @@ async function main() {
|
|
|
193
174
|
console.log("deleteResponse:", deleteResponse);
|
|
194
175
|
}
|
|
195
176
|
|
|
196
|
-
function
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
177
|
+
// Should be replaced with function to get user ID
|
|
178
|
+
function getUserId() {
|
|
179
|
+
var d = new Date().getTime(); //Timestamp
|
|
180
|
+
var d2 =
|
|
181
|
+
(typeof performance !== "undefined" &&
|
|
182
|
+
performance.now &&
|
|
183
|
+
performance.now() * 1000) ||
|
|
184
|
+
0; //Time in microseconds since page-load or 0 if unsupported
|
|
185
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
|
|
186
|
+
var r = Math.random() * 16; //random number between 0 and 16
|
|
187
|
+
if (d > 0) {
|
|
188
|
+
//Use timestamp until depleted
|
|
189
|
+
r = (d + r) % 16 | 0;
|
|
190
|
+
d = Math.floor(d / 16);
|
|
191
|
+
} else {
|
|
192
|
+
//Use microseconds since page-load if supported
|
|
193
|
+
r = (d2 + r) % 16 | 0;
|
|
194
|
+
d2 = Math.floor(d2 / 16);
|
|
195
|
+
}
|
|
196
|
+
return (c === "x" ? r : (r & 0x3) | 0x8).toString(16);
|
|
207
197
|
});
|
|
208
198
|
}
|
|
209
199
|
|
|
@@ -232,11 +222,9 @@ If the connection has become disabled, it can no longer access the latest data f
|
|
|
232
222
|
const getAccountActivitiesResponse =
|
|
233
223
|
await snaptrade.accountInformation.getAccountActivities({
|
|
234
224
|
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
235
|
-
startDate: "2022-01-
|
|
236
|
-
endDate: "2022-01-
|
|
225
|
+
startDate: "2022-01-24T00:00:00.000Z",
|
|
226
|
+
endDate: "2022-01-24T00:00:00.000Z",
|
|
237
227
|
type: "BUY,SELL,DIVIDEND",
|
|
238
|
-
userId: "snaptrade-user-123",
|
|
239
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
240
228
|
});
|
|
241
229
|
```
|
|
242
230
|
|
|
@@ -244,10 +232,6 @@ const getAccountActivitiesResponse =
|
|
|
244
232
|
|
|
245
233
|
##### accountId: `string`<a id="accountid-string"></a>
|
|
246
234
|
|
|
247
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
248
|
-
|
|
249
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
250
|
-
|
|
251
235
|
##### startDate: `string | Date`<a id="startdate-string--date"></a>
|
|
252
236
|
|
|
253
237
|
The start date (inclusive) of the transaction history to retrieve. If not provided, the default is the first transaction known to SnapTrade based on `trade_date`.
|
|
@@ -266,7 +250,7 @@ An integer that specifies the maximum number of transactions to return. Default
|
|
|
266
250
|
|
|
267
251
|
##### type: `string`<a id="type-string"></a>
|
|
268
252
|
|
|
269
|
-
Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `TAX` - A tax related fee. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another. - `SPLIT` - A stock share split.
|
|
253
|
+
Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `STOCK_DIVIDEND` - A type of dividend where a company distributes shares instead of cash - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `TAX` - A tax related fee. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another. - `SPLIT` - A stock share split.
|
|
270
254
|
|
|
271
255
|
#### 🔄 Return<a id="🔄-return"></a>
|
|
272
256
|
|
|
@@ -291,18 +275,12 @@ An experimental endpoint that returns estimated historical total account value f
|
|
|
291
275
|
```typescript
|
|
292
276
|
const getAccountBalanceHistoryResponse =
|
|
293
277
|
await snaptrade.accountInformation.getAccountBalanceHistory({
|
|
294
|
-
userId: "snaptrade-user-123",
|
|
295
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
296
278
|
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
297
279
|
});
|
|
298
280
|
```
|
|
299
281
|
|
|
300
282
|
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
|
301
283
|
|
|
302
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
303
|
-
|
|
304
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
305
|
-
|
|
306
284
|
##### accountId: `string`<a id="accountid-string"></a>
|
|
307
285
|
|
|
308
286
|
#### 🔄 Return<a id="🔄-return"></a>
|
|
@@ -334,18 +312,12 @@ If the connection has become disabled, it can no longer access the latest data f
|
|
|
334
312
|
```typescript
|
|
335
313
|
const getAllAccountPositionsResponse =
|
|
336
314
|
await snaptrade.accountInformation.getAllAccountPositions({
|
|
337
|
-
userId: "snaptrade-user-123",
|
|
338
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
339
315
|
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
340
316
|
});
|
|
341
317
|
```
|
|
342
318
|
|
|
343
319
|
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
|
344
320
|
|
|
345
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
346
|
-
|
|
347
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
348
|
-
|
|
349
321
|
##### accountId: `string`<a id="accountid-string"></a>
|
|
350
322
|
|
|
351
323
|
#### 🔄 Return<a id="🔄-return"></a>
|
|
@@ -377,18 +349,12 @@ account.
|
|
|
377
349
|
```typescript
|
|
378
350
|
const getAllUserHoldingsResponse =
|
|
379
351
|
await snaptrade.accountInformation.getAllUserHoldings({
|
|
380
|
-
userId: "snaptrade-user-123",
|
|
381
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
382
352
|
brokerageAuthorizations: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
383
353
|
});
|
|
384
354
|
```
|
|
385
355
|
|
|
386
356
|
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
|
387
357
|
|
|
388
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
389
|
-
|
|
390
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
391
|
-
|
|
392
358
|
##### brokerageAuthorizations: `string`<a id="brokerageauthorizations-string"></a>
|
|
393
359
|
|
|
394
360
|
Optional. Comma separated list of authorization IDs (only use if filtering is needed on one or more authorizations).
|
|
@@ -422,18 +388,12 @@ If the connection has become disabled, it can no longer access the latest data f
|
|
|
422
388
|
```typescript
|
|
423
389
|
const getUserAccountBalanceResponse =
|
|
424
390
|
await snaptrade.accountInformation.getUserAccountBalance({
|
|
425
|
-
userId: "snaptrade-user-123",
|
|
426
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
427
391
|
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
428
392
|
});
|
|
429
393
|
```
|
|
430
394
|
|
|
431
395
|
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
|
432
396
|
|
|
433
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
434
|
-
|
|
435
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
436
|
-
|
|
437
397
|
##### accountId: `string`<a id="accountid-string"></a>
|
|
438
398
|
|
|
439
399
|
#### 🔄 Return<a id="🔄-return"></a>
|
|
@@ -465,18 +425,12 @@ If the connection has become disabled, it can no longer access the latest data f
|
|
|
465
425
|
```typescript
|
|
466
426
|
const getUserAccountDetailsResponse =
|
|
467
427
|
await snaptrade.accountInformation.getUserAccountDetails({
|
|
468
|
-
userId: "snaptrade-user-123",
|
|
469
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
470
428
|
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
471
429
|
});
|
|
472
430
|
```
|
|
473
431
|
|
|
474
432
|
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
|
475
433
|
|
|
476
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
477
|
-
|
|
478
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
479
|
-
|
|
480
434
|
##### accountId: `string`<a id="accountid-string"></a>
|
|
481
435
|
|
|
482
436
|
#### 🔄 Return<a id="🔄-return"></a>
|
|
@@ -509,8 +463,6 @@ This endpoint only returns orders placed through SnapTrade. In other words, orde
|
|
|
509
463
|
const getUserAccountOrderDetailResponse =
|
|
510
464
|
await snaptrade.accountInformation.getUserAccountOrderDetail({
|
|
511
465
|
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
512
|
-
userId: "snaptrade-user-123",
|
|
513
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
514
466
|
brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e",
|
|
515
467
|
});
|
|
516
468
|
```
|
|
@@ -523,10 +475,6 @@ Order ID returned by brokerage. This is the unique identifier for the order in t
|
|
|
523
475
|
|
|
524
476
|
##### accountId: `string`<a id="accountid-string"></a>
|
|
525
477
|
|
|
526
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
527
|
-
|
|
528
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
529
|
-
|
|
530
478
|
#### 🔄 Return<a id="🔄-return"></a>
|
|
531
479
|
|
|
532
480
|
[AccountOrderRecord](./models/account-order-record.ts)
|
|
@@ -556,8 +504,6 @@ If the connection has become disabled, it can no longer access the latest data f
|
|
|
556
504
|
```typescript
|
|
557
505
|
const getUserAccountOrdersResponse =
|
|
558
506
|
await snaptrade.accountInformation.getUserAccountOrders({
|
|
559
|
-
userId: "snaptrade-user-123",
|
|
560
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
561
507
|
state: "all",
|
|
562
508
|
days: 30,
|
|
563
509
|
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
@@ -566,10 +512,6 @@ const getUserAccountOrdersResponse =
|
|
|
566
512
|
|
|
567
513
|
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
|
568
514
|
|
|
569
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
570
|
-
|
|
571
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
572
|
-
|
|
573
515
|
##### accountId: `string`<a id="accountid-string"></a>
|
|
574
516
|
|
|
575
517
|
##### state: `'all' | 'open' | 'executed'`<a id="state-all--open--executed"></a>
|
|
@@ -612,18 +554,12 @@ If the connection has become disabled, it can no longer access the latest data f
|
|
|
612
554
|
```typescript
|
|
613
555
|
const getUserAccountPositionsResponse =
|
|
614
556
|
await snaptrade.accountInformation.getUserAccountPositions({
|
|
615
|
-
userId: "snaptrade-user-123",
|
|
616
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
617
557
|
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
618
558
|
});
|
|
619
559
|
```
|
|
620
560
|
|
|
621
561
|
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
|
622
562
|
|
|
623
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
624
|
-
|
|
625
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
626
|
-
|
|
627
563
|
##### accountId: `string`<a id="accountid-string"></a>
|
|
628
564
|
|
|
629
565
|
#### 🔄 Return<a id="🔄-return"></a>
|
|
@@ -652,18 +588,12 @@ By default only returns executed orders, but that can be changed by setting *onl
|
|
|
652
588
|
```typescript
|
|
653
589
|
const getUserAccountRecentOrdersResponse =
|
|
654
590
|
await snaptrade.accountInformation.getUserAccountRecentOrders({
|
|
655
|
-
userId: "snaptrade-user-123",
|
|
656
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
657
591
|
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
658
592
|
});
|
|
659
593
|
```
|
|
660
594
|
|
|
661
595
|
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
|
662
596
|
|
|
663
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
664
|
-
|
|
665
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
666
|
-
|
|
667
597
|
##### accountId: `string`<a id="accountid-string"></a>
|
|
668
598
|
|
|
669
599
|
##### onlyExecuted: `boolean`<a id="onlyexecuted-boolean"></a>
|
|
@@ -693,8 +623,6 @@ Returns a list of rate of return percents for a given account.
|
|
|
693
623
|
```typescript
|
|
694
624
|
const getUserAccountReturnRatesResponse =
|
|
695
625
|
await snaptrade.accountInformation.getUserAccountReturnRates({
|
|
696
|
-
userId: "snaptrade-user-123",
|
|
697
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
698
626
|
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
699
627
|
timeframes: "ALL,1Y",
|
|
700
628
|
});
|
|
@@ -702,10 +630,6 @@ const getUserAccountReturnRatesResponse =
|
|
|
702
630
|
|
|
703
631
|
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
|
704
632
|
|
|
705
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
706
|
-
|
|
707
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
708
|
-
|
|
709
633
|
##### accountId: `string`<a id="accountid-string"></a>
|
|
710
634
|
|
|
711
635
|
##### timeframes: `string`<a id="timeframes-string"></a>
|
|
@@ -744,8 +668,6 @@ If the connection has become disabled, it can no longer access the latest data f
|
|
|
744
668
|
const getUserHoldingsResponse =
|
|
745
669
|
await snaptrade.accountInformation.getUserHoldings({
|
|
746
670
|
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
747
|
-
userId: "snaptrade-user-123",
|
|
748
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
749
671
|
});
|
|
750
672
|
```
|
|
751
673
|
|
|
@@ -753,10 +675,6 @@ const getUserHoldingsResponse =
|
|
|
753
675
|
|
|
754
676
|
##### accountId: `string`<a id="accountid-string"></a>
|
|
755
677
|
|
|
756
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
757
|
-
|
|
758
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
759
|
-
|
|
760
678
|
#### 🔄 Return<a id="🔄-return"></a>
|
|
761
679
|
|
|
762
680
|
[AccountHoldingsAccount](./models/account-holdings-account.ts)
|
|
@@ -781,18 +699,9 @@ This endpoint returns Daily data regardless of the customer's plan. Daily data i
|
|
|
781
699
|
|
|
782
700
|
```typescript
|
|
783
701
|
const listUserAccountsResponse =
|
|
784
|
-
await snaptrade.accountInformation.listUserAccounts(
|
|
785
|
-
userId: "snaptrade-user-123",
|
|
786
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
787
|
-
});
|
|
702
|
+
await snaptrade.accountInformation.listUserAccounts();
|
|
788
703
|
```
|
|
789
704
|
|
|
790
|
-
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
|
791
|
-
|
|
792
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
793
|
-
|
|
794
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
795
|
-
|
|
796
705
|
#### 🔄 Return<a id="🔄-return"></a>
|
|
797
706
|
|
|
798
707
|
[Account](./models/account.ts)
|
|
@@ -815,18 +724,12 @@ Updates various properties of a specified account.
|
|
|
815
724
|
```typescript
|
|
816
725
|
const updateUserAccountResponse =
|
|
817
726
|
await snaptrade.accountInformation.updateUserAccount({
|
|
818
|
-
userId: "snaptrade-user-123",
|
|
819
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
820
727
|
accountId: "accountId_example",
|
|
821
728
|
});
|
|
822
729
|
```
|
|
823
730
|
|
|
824
731
|
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
|
825
732
|
|
|
826
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
827
|
-
|
|
828
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
829
|
-
|
|
830
733
|
##### accountId: `string`<a id="accountid-string"></a>
|
|
831
734
|
|
|
832
735
|
The ID of the account to update.
|
|
@@ -875,15 +778,9 @@ Deletes a registered user and all associated data. This action is irreversible.
|
|
|
875
778
|
|
|
876
779
|
```typescript
|
|
877
780
|
const deleteSnapTradeUserResponse =
|
|
878
|
-
await snaptrade.authentication.deleteSnapTradeUser(
|
|
879
|
-
userId: "snaptrade-user-123",
|
|
880
|
-
});
|
|
781
|
+
await snaptrade.authentication.deleteSnapTradeUser();
|
|
881
782
|
```
|
|
882
783
|
|
|
883
|
-
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
|
884
|
-
|
|
885
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
886
|
-
|
|
887
784
|
#### 🔄 Return<a id="🔄-return"></a>
|
|
888
785
|
|
|
889
786
|
[DeleteUserResponse](./models/delete-user-response.ts)
|
|
@@ -929,8 +826,6 @@ Please note that the returned URL expires in 5 minutes.
|
|
|
929
826
|
```typescript
|
|
930
827
|
const loginSnapTradeUserResponse =
|
|
931
828
|
await snaptrade.authentication.loginSnapTradeUser({
|
|
932
|
-
userId: "snaptrade-user-123",
|
|
933
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
934
829
|
broker: "ALPACA",
|
|
935
830
|
immediateRedirect: true,
|
|
936
831
|
customRedirect: "https://snaptrade.com",
|
|
@@ -944,10 +839,6 @@ const loginSnapTradeUserResponse =
|
|
|
944
839
|
|
|
945
840
|
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
|
946
841
|
|
|
947
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
948
|
-
|
|
949
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
950
|
-
|
|
951
842
|
##### broker: `string`<a id="broker-string"></a>
|
|
952
843
|
|
|
953
844
|
Slug of the brokerage to connect the user to. See [the integrations page](https://support.snaptrade.com/brokerages) for a list of supported brokerages and their slugs.
|
|
@@ -966,7 +857,7 @@ The UUID of the brokerage connection to be reconnected. This parameter should be
|
|
|
966
857
|
|
|
967
858
|
##### connectionType: `string`<a id="connectiontype-string"></a>
|
|
968
859
|
|
|
969
|
-
Determines connection permissions (default: read) - `read`: Data access only. - `trade`: Data and trading access. - `trade-if-available`: Attempts to establish a trading connection if the brokerage supports it, otherwise falls back to read-only access automatically.
|
|
860
|
+
Determines connection permissions (default: read) - `read`: Data access only. - `trade`: Data and trading access. - `trade-if-available`: Attempts to establish a trading connection if the brokerage supports it, otherwise falls back to read-only access automatically.
|
|
970
861
|
|
|
971
862
|
##### showCloseButton: `boolean`<a id="showclosebutton-boolean"></a>
|
|
972
863
|
|
|
@@ -1074,8 +965,6 @@ Deletes the SnapTrade connection specified by the ID. This will also remove the
|
|
|
1074
965
|
```typescript
|
|
1075
966
|
const deleteConnectionResponse = await snaptrade.connections.deleteConnection({
|
|
1076
967
|
connectionId: "87b24961-b51e-4db8-9226-f198f6518a89",
|
|
1077
|
-
userId: "snaptrade-user-123",
|
|
1078
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
1079
968
|
});
|
|
1080
969
|
```
|
|
1081
970
|
|
|
@@ -1083,10 +972,6 @@ const deleteConnectionResponse = await snaptrade.connections.deleteConnection({
|
|
|
1083
972
|
|
|
1084
973
|
##### connectionId: `string`<a id="connectionid-string"></a>
|
|
1085
974
|
|
|
1086
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
1087
|
-
|
|
1088
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
1089
|
-
|
|
1090
975
|
#### 🔄 Return<a id="🔄-return"></a>
|
|
1091
976
|
|
|
1092
977
|
[DeleteConnectionConfirmation](./models/delete-connection-confirmation.ts)
|
|
@@ -1110,8 +995,6 @@ Returns a single connection for the specified ID.
|
|
|
1110
995
|
const detailBrokerageAuthorizationResponse =
|
|
1111
996
|
await snaptrade.connections.detailBrokerageAuthorization({
|
|
1112
997
|
authorizationId: "87b24961-b51e-4db8-9226-f198f6518a89",
|
|
1113
|
-
userId: "snaptrade-user-123",
|
|
1114
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
1115
998
|
});
|
|
1116
999
|
```
|
|
1117
1000
|
|
|
@@ -1119,10 +1002,6 @@ const detailBrokerageAuthorizationResponse =
|
|
|
1119
1002
|
|
|
1120
1003
|
##### authorizationId: `string`<a id="authorizationid-string"></a>
|
|
1121
1004
|
|
|
1122
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
1123
|
-
|
|
1124
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
1125
|
-
|
|
1126
1005
|
#### 🔄 Return<a id="🔄-return"></a>
|
|
1127
1006
|
|
|
1128
1007
|
[BrokerageAuthorization](./models/brokerage-authorization.ts)
|
|
@@ -1150,8 +1029,6 @@ This endpoint is available on test keys. If you would like it enabled on product
|
|
|
1150
1029
|
const disableBrokerageAuthorizationResponse =
|
|
1151
1030
|
await snaptrade.connections.disableBrokerageAuthorization({
|
|
1152
1031
|
authorizationId: "87b24961-b51e-4db8-9226-f198f6518a89",
|
|
1153
|
-
userId: "snaptrade-user-123",
|
|
1154
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
1155
1032
|
});
|
|
1156
1033
|
```
|
|
1157
1034
|
|
|
@@ -1159,10 +1036,6 @@ const disableBrokerageAuthorizationResponse =
|
|
|
1159
1036
|
|
|
1160
1037
|
##### authorizationId: `string`<a id="authorizationid-string"></a>
|
|
1161
1038
|
|
|
1162
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
1163
|
-
|
|
1164
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
1165
|
-
|
|
1166
1039
|
#### 🔄 Return<a id="🔄-return"></a>
|
|
1167
1040
|
|
|
1168
1041
|
[BrokerageAuthorizationDisabledConfirmation](./models/brokerage-authorization-disabled-confirmation.ts)
|
|
@@ -1193,8 +1066,6 @@ Check your API key on the [Customer Dashboard billing page](https://dashboard.sn
|
|
|
1193
1066
|
const listBrokerageAuthorizationAccountsResponse =
|
|
1194
1067
|
await snaptrade.connections.listBrokerageAuthorizationAccounts({
|
|
1195
1068
|
authorizationId: "87b24961-b51e-4db8-9226-f198f6518a89",
|
|
1196
|
-
userId: "snaptrade-user-123",
|
|
1197
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
1198
1069
|
});
|
|
1199
1070
|
```
|
|
1200
1071
|
|
|
@@ -1202,10 +1073,6 @@ const listBrokerageAuthorizationAccountsResponse =
|
|
|
1202
1073
|
|
|
1203
1074
|
##### authorizationId: `string`<a id="authorizationid-string"></a>
|
|
1204
1075
|
|
|
1205
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
1206
|
-
|
|
1207
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
1208
|
-
|
|
1209
1076
|
#### 🔄 Return<a id="🔄-return"></a>
|
|
1210
1077
|
|
|
1211
1078
|
[Account](./models/account.ts)
|
|
@@ -1232,18 +1099,9 @@ SnapTrade performs de-duping on connections for a given user. If the user has an
|
|
|
1232
1099
|
|
|
1233
1100
|
```typescript
|
|
1234
1101
|
const listBrokerageAuthorizationsResponse =
|
|
1235
|
-
await snaptrade.connections.listBrokerageAuthorizations(
|
|
1236
|
-
userId: "snaptrade-user-123",
|
|
1237
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
1238
|
-
});
|
|
1102
|
+
await snaptrade.connections.listBrokerageAuthorizations();
|
|
1239
1103
|
```
|
|
1240
1104
|
|
|
1241
|
-
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
|
1242
|
-
|
|
1243
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
1244
|
-
|
|
1245
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
1246
|
-
|
|
1247
1105
|
#### 🔄 Return<a id="🔄-return"></a>
|
|
1248
1106
|
|
|
1249
1107
|
[BrokerageAuthorization](./models/brokerage-authorization.ts)
|
|
@@ -1272,8 +1130,6 @@ This endpoint will also trigger a transaction sync for the past day if one has n
|
|
|
1272
1130
|
const refreshBrokerageAuthorizationResponse =
|
|
1273
1131
|
await snaptrade.connections.refreshBrokerageAuthorization({
|
|
1274
1132
|
authorizationId: "87b24961-b51e-4db8-9226-f198f6518a89",
|
|
1275
|
-
userId: "snaptrade-user-123",
|
|
1276
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
1277
1133
|
});
|
|
1278
1134
|
```
|
|
1279
1135
|
|
|
@@ -1281,10 +1137,6 @@ const refreshBrokerageAuthorizationResponse =
|
|
|
1281
1137
|
|
|
1282
1138
|
##### authorizationId: `string`<a id="authorizationid-string"></a>
|
|
1283
1139
|
|
|
1284
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
1285
|
-
|
|
1286
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
1287
|
-
|
|
1288
1140
|
#### 🔄 Return<a id="🔄-return"></a>
|
|
1289
1141
|
|
|
1290
1142
|
[BrokerageAuthorizationRefreshConfirmation](./models/brokerage-authorization-refresh-confirmation.ts)
|
|
@@ -1308,8 +1160,6 @@ Deletes the SnapTrade connection specified by the ID. This will also remove the
|
|
|
1308
1160
|
const removeBrokerageAuthorizationResponse =
|
|
1309
1161
|
await snaptrade.connections.removeBrokerageAuthorization({
|
|
1310
1162
|
authorizationId: "87b24961-b51e-4db8-9226-f198f6518a89",
|
|
1311
|
-
userId: "snaptrade-user-123",
|
|
1312
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
1313
1163
|
});
|
|
1314
1164
|
```
|
|
1315
1165
|
|
|
@@ -1317,10 +1167,6 @@ const removeBrokerageAuthorizationResponse =
|
|
|
1317
1167
|
|
|
1318
1168
|
##### authorizationId: `string`<a id="authorizationid-string"></a>
|
|
1319
1169
|
|
|
1320
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
1321
|
-
|
|
1322
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
1323
|
-
|
|
1324
1170
|
#### 🌐 Endpoint<a id="🌐-endpoint"></a>
|
|
1325
1171
|
|
|
1326
1172
|
`/authorizations/{authorizationId}` `DELETE`
|
|
@@ -1339,8 +1185,6 @@ Returns a list of rate of return percents for a given connection.
|
|
|
1339
1185
|
|
|
1340
1186
|
```typescript
|
|
1341
1187
|
const returnRatesResponse = await snaptrade.connections.returnRates({
|
|
1342
|
-
userId: "snaptrade-user-123",
|
|
1343
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
1344
1188
|
authorizationId: "87b24961-b51e-4db8-9226-f198f6518a89",
|
|
1345
1189
|
timeframes: "ALL,1Y",
|
|
1346
1190
|
});
|
|
@@ -1348,10 +1192,6 @@ const returnRatesResponse = await snaptrade.connections.returnRates({
|
|
|
1348
1192
|
|
|
1349
1193
|
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
|
1350
1194
|
|
|
1351
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
1352
|
-
|
|
1353
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
1354
|
-
|
|
1355
1195
|
##### authorizationId: `string`<a id="authorizationid-string"></a>
|
|
1356
1196
|
|
|
1357
1197
|
##### timeframes: `string`<a id="timeframes-string"></a>
|
|
@@ -1380,8 +1220,6 @@ Returns a list of session events associated with a user.
|
|
|
1380
1220
|
```typescript
|
|
1381
1221
|
const sessionEventsResponse = await snaptrade.connections.sessionEvents({
|
|
1382
1222
|
partnerClientId: "SNAPTRADETEST",
|
|
1383
|
-
userId:
|
|
1384
|
-
"917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2",
|
|
1385
1223
|
sessionId:
|
|
1386
1224
|
"917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2",
|
|
1387
1225
|
});
|
|
@@ -1391,10 +1229,6 @@ const sessionEventsResponse = await snaptrade.connections.sessionEvents({
|
|
|
1391
1229
|
|
|
1392
1230
|
##### partnerClientId: `string`<a id="partnerclientid-string"></a>
|
|
1393
1231
|
|
|
1394
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
1395
|
-
|
|
1396
|
-
Optional comma separated list of user IDs used to filter the request on specific users
|
|
1397
|
-
|
|
1398
1232
|
##### sessionId: `string`<a id="sessionid-string"></a>
|
|
1399
1233
|
|
|
1400
1234
|
Optional comma separated list of session IDs used to filter the request on specific users
|
|
@@ -1423,8 +1257,6 @@ Trigger a transactions sync for all accounts under this connection. Updates will
|
|
|
1423
1257
|
const syncBrokerageAuthorizationTransactionsResponse =
|
|
1424
1258
|
await snaptrade.connections.syncBrokerageAuthorizationTransactions({
|
|
1425
1259
|
authorizationId: "87b24961-b51e-4db8-9226-f198f6518a89",
|
|
1426
|
-
userId: "snaptrade-user-123",
|
|
1427
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
1428
1260
|
});
|
|
1429
1261
|
```
|
|
1430
1262
|
|
|
@@ -1432,10 +1264,6 @@ const syncBrokerageAuthorizationTransactionsResponse =
|
|
|
1432
1264
|
|
|
1433
1265
|
##### authorizationId: `string`<a id="authorizationid-string"></a>
|
|
1434
1266
|
|
|
1435
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
1436
|
-
|
|
1437
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
1438
|
-
|
|
1439
1267
|
#### 🔄 Return<a id="🔄-return"></a>
|
|
1440
1268
|
|
|
1441
1269
|
[BrokerageAuthorizationTransactionsSyncConfirmation](./models/brokerage-authorization-transactions-sync-confirmation.ts)
|
|
@@ -1460,8 +1288,6 @@ This endpoint requires `userId` and `userSecret` in addition to the partner sign
|
|
|
1460
1288
|
```typescript
|
|
1461
1289
|
const addSubscriptionResponse =
|
|
1462
1290
|
await snaptrade.experimentalEndpoints.addSubscription({
|
|
1463
|
-
userId: "snaptrade-user-123",
|
|
1464
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
1465
1291
|
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
1466
1292
|
check_interval_seconds: 300,
|
|
1467
1293
|
});
|
|
@@ -1477,10 +1303,6 @@ Unique identifier for the connected brokerage account. This is the UUID used to
|
|
|
1477
1303
|
|
|
1478
1304
|
How often the subscribed account should be checked for new trades. Must match an active Trade Detection plan.
|
|
1479
1305
|
|
|
1480
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
1481
|
-
|
|
1482
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
1483
|
-
|
|
1484
1306
|
#### 🔄 Return<a id="🔄-return"></a>
|
|
1485
1307
|
|
|
1486
1308
|
[TradeDetectionSubscription](./models/trade-detection-subscription.ts)
|
|
@@ -1547,8 +1369,6 @@ const getUserAccountOrderDetailV2Response =
|
|
|
1547
1369
|
await snaptrade.experimentalEndpoints.getUserAccountOrderDetailV2({
|
|
1548
1370
|
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
1549
1371
|
brokerageOrderId: "66a033fa-da74-4fcf-b527-feefdec9257e",
|
|
1550
|
-
userId: "snaptrade-user-123",
|
|
1551
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
1552
1372
|
});
|
|
1553
1373
|
```
|
|
1554
1374
|
|
|
@@ -1558,10 +1378,6 @@ const getUserAccountOrderDetailV2Response =
|
|
|
1558
1378
|
|
|
1559
1379
|
##### brokerageOrderId: `string`<a id="brokerageorderid-string"></a>
|
|
1560
1380
|
|
|
1561
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
1562
|
-
|
|
1563
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
1564
|
-
|
|
1565
1381
|
#### 🔄 Return<a id="🔄-return"></a>
|
|
1566
1382
|
|
|
1567
1383
|
[AccountOrderRecordV2](./models/account-order-record-v2.ts)
|
|
@@ -1589,8 +1405,6 @@ If the connection has become disabled, it can no longer access the latest data f
|
|
|
1589
1405
|
```typescript
|
|
1590
1406
|
const getUserAccountOrdersV2Response =
|
|
1591
1407
|
await snaptrade.experimentalEndpoints.getUserAccountOrdersV2({
|
|
1592
|
-
userId: "snaptrade-user-123",
|
|
1593
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
1594
1408
|
state: "all",
|
|
1595
1409
|
days: 30,
|
|
1596
1410
|
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
@@ -1599,10 +1413,6 @@ const getUserAccountOrdersV2Response =
|
|
|
1599
1413
|
|
|
1600
1414
|
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
|
1601
1415
|
|
|
1602
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
1603
|
-
|
|
1604
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
1605
|
-
|
|
1606
1416
|
##### accountId: `string`<a id="accountid-string"></a>
|
|
1607
1417
|
|
|
1608
1418
|
##### state: `'all' | 'open' | 'executed'`<a id="state-all--open--executed"></a>
|
|
@@ -1640,18 +1450,12 @@ By default only returns executed orders, but that can be changed by setting *onl
|
|
|
1640
1450
|
```typescript
|
|
1641
1451
|
const getUserAccountRecentOrdersV2Response =
|
|
1642
1452
|
await snaptrade.experimentalEndpoints.getUserAccountRecentOrdersV2({
|
|
1643
|
-
userId: "snaptrade-user-123",
|
|
1644
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
1645
1453
|
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
1646
1454
|
});
|
|
1647
1455
|
```
|
|
1648
1456
|
|
|
1649
1457
|
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
|
1650
1458
|
|
|
1651
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
1652
|
-
|
|
1653
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
1654
|
-
|
|
1655
1459
|
##### accountId: `string`<a id="accountid-string"></a>
|
|
1656
1460
|
|
|
1657
1461
|
##### onlyExecuted: `boolean`<a id="onlyexecuted-boolean"></a>
|
|
@@ -1711,18 +1515,12 @@ Check your API key on the [Customer Dashboard billing page](https://dashboard.sn
|
|
|
1711
1515
|
|
|
1712
1516
|
```typescript
|
|
1713
1517
|
const listOptionHoldingsResponse = await snaptrade.options.listOptionHoldings({
|
|
1714
|
-
userId: "snaptrade-user-123",
|
|
1715
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
1716
1518
|
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
1717
1519
|
});
|
|
1718
1520
|
```
|
|
1719
1521
|
|
|
1720
1522
|
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
|
1721
1523
|
|
|
1722
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
1723
|
-
|
|
1724
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
1725
|
-
|
|
1726
1524
|
##### accountId: `string`<a id="accountid-string"></a>
|
|
1727
1525
|
|
|
1728
1526
|
#### 🔄 Return<a id="🔄-return"></a>
|
|
@@ -2054,8 +1852,6 @@ The search results are further limited to the symbols supported by the brokerage
|
|
|
2054
1852
|
```typescript
|
|
2055
1853
|
const symbolSearchUserAccountResponse =
|
|
2056
1854
|
await snaptrade.referenceData.symbolSearchUserAccount({
|
|
2057
|
-
userId: "snaptrade-user-123",
|
|
2058
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
2059
1855
|
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
2060
1856
|
substring: "AAPL",
|
|
2061
1857
|
});
|
|
@@ -2063,10 +1859,6 @@ const symbolSearchUserAccountResponse =
|
|
|
2063
1859
|
|
|
2064
1860
|
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
|
2065
1861
|
|
|
2066
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
2067
|
-
|
|
2068
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
2069
|
-
|
|
2070
1862
|
##### accountId: `string`<a id="accountid-string"></a>
|
|
2071
1863
|
|
|
2072
1864
|
##### substring: `string`<a id="substring-string"></a>
|
|
@@ -2095,8 +1887,6 @@ Cancels an order in the specified account. Accepts order IDs for all asset types
|
|
|
2095
1887
|
|
|
2096
1888
|
```typescript
|
|
2097
1889
|
const cancelOrderResponse = await snaptrade.trading.cancelOrder({
|
|
2098
|
-
userId: "snaptrade-user-123",
|
|
2099
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
2100
1890
|
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
2101
1891
|
brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e",
|
|
2102
1892
|
});
|
|
@@ -2108,10 +1898,6 @@ const cancelOrderResponse = await snaptrade.trading.cancelOrder({
|
|
|
2108
1898
|
|
|
2109
1899
|
Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system.
|
|
2110
1900
|
|
|
2111
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
2112
|
-
|
|
2113
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
2114
|
-
|
|
2115
1901
|
##### accountId: `string`<a id="accountid-string"></a>
|
|
2116
1902
|
|
|
2117
1903
|
#### 🔄 Return<a id="🔄-return"></a>
|
|
@@ -2139,8 +1925,6 @@ Attempts to cancel an open order with the brokerage. If the order is no longer c
|
|
|
2139
1925
|
```typescript
|
|
2140
1926
|
const cancelUserAccountOrderResponse =
|
|
2141
1927
|
await snaptrade.trading.cancelUserAccountOrder({
|
|
2142
|
-
userId: "snaptrade-user-123",
|
|
2143
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
2144
1928
|
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
2145
1929
|
brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e",
|
|
2146
1930
|
});
|
|
@@ -2152,10 +1936,6 @@ const cancelUserAccountOrderResponse =
|
|
|
2152
1936
|
|
|
2153
1937
|
Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system.
|
|
2154
1938
|
|
|
2155
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
2156
|
-
|
|
2157
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
2158
|
-
|
|
2159
1939
|
##### accountId: `string`<a id="accountid-string"></a>
|
|
2160
1940
|
|
|
2161
1941
|
#### 🔄 Return<a id="🔄-return"></a>
|
|
@@ -2181,8 +1961,6 @@ Gets a quote for the specified account.
|
|
|
2181
1961
|
```typescript
|
|
2182
1962
|
const getCryptocurrencyPairQuoteResponse =
|
|
2183
1963
|
await snaptrade.trading.getCryptocurrencyPairQuote({
|
|
2184
|
-
userId: "snaptrade-user-123",
|
|
2185
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
2186
1964
|
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
2187
1965
|
instrumentSymbol: "BTC-USD",
|
|
2188
1966
|
});
|
|
@@ -2190,10 +1968,6 @@ const getCryptocurrencyPairQuoteResponse =
|
|
|
2190
1968
|
|
|
2191
1969
|
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
|
2192
1970
|
|
|
2193
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
2194
|
-
|
|
2195
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
2196
|
-
|
|
2197
1971
|
##### accountId: `string`<a id="accountid-string"></a>
|
|
2198
1972
|
|
|
2199
1973
|
##### instrumentSymbol: `string`<a id="instrumentsymbol-string"></a>
|
|
@@ -2221,8 +1995,6 @@ Only supported for certain enabled brokerages. Please refer to the [brokerage tr
|
|
|
2221
1995
|
|
|
2222
1996
|
```typescript
|
|
2223
1997
|
const getOptionImpactResponse = await snaptrade.trading.getOptionImpact({
|
|
2224
|
-
userId: "snaptrade-user-123",
|
|
2225
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
2226
1998
|
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
2227
1999
|
order_type: "MARKET",
|
|
2228
2000
|
time_in_force: "Day",
|
|
@@ -2250,14 +2022,10 @@ The type of order to place.
|
|
|
2250
2022
|
|
|
2251
2023
|
##### time_in_force: [`TimeInForceStrict`](./models/time-in-force-strict.ts)<a id="time_in_force-timeinforcestrictmodelstime-in-force-strictts"></a>
|
|
2252
2024
|
|
|
2253
|
-
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.
|
|
2025
|
+
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.
|
|
2254
2026
|
|
|
2255
2027
|
##### legs: [`MlegLeg`](./models/mleg-leg.ts)[]<a id="legs-mleglegmodelsmleg-legts"></a>
|
|
2256
2028
|
|
|
2257
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
2258
|
-
|
|
2259
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
2260
|
-
|
|
2261
2029
|
##### accountId: `string`<a id="accountid-string"></a>
|
|
2262
2030
|
|
|
2263
2031
|
##### limit_price: `string`<a id="limit_price-string"></a>
|
|
@@ -2291,8 +2059,6 @@ Simulates an order and its impact on the account. This endpoint does not place t
|
|
|
2291
2059
|
|
|
2292
2060
|
```typescript
|
|
2293
2061
|
const getOrderImpactResponse = await snaptrade.trading.getOrderImpact({
|
|
2294
|
-
userId: "snaptrade-user-123",
|
|
2295
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
2296
2062
|
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
2297
2063
|
action: "BUY",
|
|
2298
2064
|
universal_symbol_id: "2bcd7cc3-e922-4976-bce1-9858296801c3",
|
|
@@ -2320,15 +2086,11 @@ Unique identifier for the symbol within SnapTrade. This is the ID used to refere
|
|
|
2320
2086
|
|
|
2321
2087
|
##### order_type: [`OrderTypeStrict`](./models/order-type-strict.ts)<a id="order_type-ordertypestrictmodelsorder-type-strictts"></a>
|
|
2322
2088
|
|
|
2323
|
-
The type of order to place. - For `Limit` and `StopLimit` orders, the `price` field is required. - For `Stop` and `StopLimit` orders, the `stop` field is required.
|
|
2089
|
+
The type of order to place. - For `Limit` and `StopLimit` orders, the `price` field is required. - For `Stop` and `StopLimit` orders, the `stop` field is required.
|
|
2324
2090
|
|
|
2325
2091
|
##### time_in_force: [`TimeInForceStrict`](./models/time-in-force-strict.ts)<a id="time_in_force-timeinforcestrictmodelstime-in-force-strictts"></a>
|
|
2326
2092
|
|
|
2327
|
-
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.
|
|
2328
|
-
|
|
2329
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
2330
|
-
|
|
2331
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
2093
|
+
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.
|
|
2332
2094
|
|
|
2333
2095
|
##### price: `number`<a id="price-number"></a>
|
|
2334
2096
|
|
|
@@ -2366,8 +2128,6 @@ Returns a quote for a single option contract. The option contract is specified u
|
|
|
2366
2128
|
```typescript
|
|
2367
2129
|
const getUserAccountOptionQuotesResponse =
|
|
2368
2130
|
await snaptrade.trading.getUserAccountOptionQuotes({
|
|
2369
|
-
userId: "snaptrade-user-123",
|
|
2370
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
2371
2131
|
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
2372
2132
|
symbol: "AAPL 251219C00150000",
|
|
2373
2133
|
});
|
|
@@ -2375,10 +2135,6 @@ const getUserAccountOptionQuotesResponse =
|
|
|
2375
2135
|
|
|
2376
2136
|
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
|
2377
2137
|
|
|
2378
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
2379
|
-
|
|
2380
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
2381
|
-
|
|
2382
2138
|
##### accountId: `string`<a id="accountid-string"></a>
|
|
2383
2139
|
|
|
2384
2140
|
##### symbol: `string`<a id="symbol-string"></a>
|
|
@@ -2416,8 +2172,6 @@ This endpoint is disabled for free plans by default. Please contact support to e
|
|
|
2416
2172
|
```typescript
|
|
2417
2173
|
const getUserAccountQuotesResponse =
|
|
2418
2174
|
await snaptrade.trading.getUserAccountQuotes({
|
|
2419
|
-
userId: "snaptrade-user-123",
|
|
2420
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
2421
2175
|
symbols: "symbols_example",
|
|
2422
2176
|
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
2423
2177
|
});
|
|
@@ -2425,10 +2179,6 @@ const getUserAccountQuotesResponse =
|
|
|
2425
2179
|
|
|
2426
2180
|
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
|
2427
2181
|
|
|
2428
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
2429
|
-
|
|
2430
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
2431
|
-
|
|
2432
2182
|
##### symbols: `string`<a id="symbols-string"></a>
|
|
2433
2183
|
|
|
2434
2184
|
List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator. Maximum of 10 values allowed
|
|
@@ -2465,8 +2215,6 @@ use. Only supported on certain brokerages
|
|
|
2465
2215
|
```typescript
|
|
2466
2216
|
const placeBracketOrderResponse = await snaptrade.trading.placeBracketOrder({
|
|
2467
2217
|
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
2468
|
-
userId: "snaptrade-user-123",
|
|
2469
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
2470
2218
|
action: "BUY",
|
|
2471
2219
|
instrument: {
|
|
2472
2220
|
symbol: "AAPL",
|
|
@@ -2497,11 +2245,11 @@ The action describes the intent or side of a trade. This is either `BUY` or `SEL
|
|
|
2497
2245
|
|
|
2498
2246
|
##### order_type: [`OrderTypeStrict`](./models/order-type-strict.ts)<a id="order_type-ordertypestrictmodelsorder-type-strictts"></a>
|
|
2499
2247
|
|
|
2500
|
-
The type of order to place. - For `Limit` and `StopLimit` orders, the `price` field is required. - For `Stop` and `StopLimit` orders, the `stop` field is required.
|
|
2248
|
+
The type of order to place. - For `Limit` and `StopLimit` orders, the `price` field is required. - For `Stop` and `StopLimit` orders, the `stop` field is required.
|
|
2501
2249
|
|
|
2502
2250
|
##### time_in_force: [`TimeInForceStrict`](./models/time-in-force-strict.ts)<a id="time_in_force-timeinforcestrictmodelstime-in-force-strictts"></a>
|
|
2503
2251
|
|
|
2504
|
-
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.
|
|
2252
|
+
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.
|
|
2505
2253
|
|
|
2506
2254
|
##### stop_loss: [`StopLoss`](./models/stop-loss.ts)<a id="stop_loss-stoplossmodelsstop-lossts"></a>
|
|
2507
2255
|
|
|
@@ -2511,10 +2259,6 @@ The Time in Force type for the order. This field indicates how long the order wi
|
|
|
2511
2259
|
|
|
2512
2260
|
The ID of the account to execute the trade on.
|
|
2513
2261
|
|
|
2514
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
2515
|
-
|
|
2516
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
2517
|
-
|
|
2518
2262
|
##### price: `number`<a id="price-number"></a>
|
|
2519
2263
|
|
|
2520
2264
|
The limit price for `Limit` and `StopLimit` orders.
|
|
@@ -2556,8 +2300,6 @@ Please refer to the [brokerage trading support page](https://support.snaptrade.c
|
|
|
2556
2300
|
```typescript
|
|
2557
2301
|
const placeComplexOrderResponse = await snaptrade.trading.placeComplexOrder({
|
|
2558
2302
|
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
2559
|
-
userId: "snaptrade-user-123",
|
|
2560
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
2561
2303
|
type: "OTO",
|
|
2562
2304
|
orders: [
|
|
2563
2305
|
{
|
|
@@ -2582,20 +2324,16 @@ const placeComplexOrderResponse = await snaptrade.trading.placeComplexOrder({
|
|
|
2582
2324
|
|
|
2583
2325
|
##### type: `string`<a id="type-string"></a>
|
|
2584
2326
|
|
|
2585
|
-
The complex order type. - `OCO`: One Cancels the Other — two peer orders. - `OTO`: One Triggers the Other — a trigger order and a conditional order. - `OTOCO`: One Triggers a One Cancels the Other — a trigger order and two peer orders.
|
|
2327
|
+
The complex order type. - `OCO`: One Cancels the Other — two peer orders. - `OTO`: One Triggers the Other — a trigger order and a conditional order. - `OTOCO`: One Triggers a One Cancels the Other — a trigger order and two peer orders.
|
|
2586
2328
|
|
|
2587
2329
|
##### orders: [`ComplexOrderLeg`](./models/complex-order-leg.ts)[]<a id="orders-complexorderlegmodelscomplex-order-legts"></a>
|
|
2588
2330
|
|
|
2589
|
-
The orders that make up the complex order. Required counts and roles per type: - `OCO`: exactly 2 orders, both `PEER` - `OTO`: exactly 2 orders, one `TRIGGER` and one `CONDITIONAL` - `OTOCO`: exactly 3 orders, one `TRIGGER` and two `PEER`
|
|
2331
|
+
The orders that make up the complex order. Required counts and roles per type: - `OCO`: exactly 2 orders, both `PEER` - `OTO`: exactly 2 orders, one `TRIGGER` and one `CONDITIONAL` - `OTOCO`: exactly 3 orders, one `TRIGGER` and two `PEER`
|
|
2590
2332
|
|
|
2591
2333
|
##### accountId: `string`<a id="accountid-string"></a>
|
|
2592
2334
|
|
|
2593
2335
|
The ID of the account to execute the trade on.
|
|
2594
2336
|
|
|
2595
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
2596
|
-
|
|
2597
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
2598
|
-
|
|
2599
2337
|
##### client_order_id: [`string`](./models/model-string.ts)<a id="client_order_id-stringmodelsmodel-stringts"></a>
|
|
2600
2338
|
|
|
2601
2339
|
#### 🔄 Return<a id="🔄-return"></a>
|
|
@@ -2621,8 +2359,6 @@ This endpoint does not compute the impact to the account balance from the order
|
|
|
2621
2359
|
|
|
2622
2360
|
```typescript
|
|
2623
2361
|
const placeCryptoOrderResponse = await snaptrade.trading.placeCryptoOrder({
|
|
2624
|
-
userId: "snaptrade-user-123",
|
|
2625
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
2626
2362
|
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
2627
2363
|
instrument: {
|
|
2628
2364
|
symbol: "BTC",
|
|
@@ -2635,7 +2371,7 @@ const placeCryptoOrderResponse = await snaptrade.trading.placeCryptoOrder({
|
|
|
2635
2371
|
limit_price: "123.45",
|
|
2636
2372
|
stop_price: "123.45",
|
|
2637
2373
|
post_only: false,
|
|
2638
|
-
expiration_date: "2024-01-01T00:00:
|
|
2374
|
+
expiration_date: "2024-01-01T00:00:00.000Z",
|
|
2639
2375
|
});
|
|
2640
2376
|
```
|
|
2641
2377
|
|
|
@@ -2653,16 +2389,12 @@ The type of order to place.
|
|
|
2653
2389
|
|
|
2654
2390
|
##### time_in_force: `string`<a id="time_in_force-string"></a>
|
|
2655
2391
|
|
|
2656
|
-
The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. - `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. - `GTD` - Good Til Date. The order is valid until the specified date.
|
|
2392
|
+
The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. - `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. - `GTD` - Good Til Date. The order is valid until the specified date.
|
|
2657
2393
|
|
|
2658
2394
|
##### amount: `string`<a id="amount-string"></a>
|
|
2659
2395
|
|
|
2660
2396
|
The amount of the base currency to buy or sell.
|
|
2661
2397
|
|
|
2662
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
2663
|
-
|
|
2664
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
2665
|
-
|
|
2666
2398
|
##### accountId: `string`<a id="accountid-string"></a>
|
|
2667
2399
|
|
|
2668
2400
|
##### limit_price: `string`<a id="limit_price-string"></a>
|
|
@@ -2675,7 +2407,7 @@ The stop price. Required if the order type is `STOP_LOSS_MARKET`, `STOP_LOSS_LIM
|
|
|
2675
2407
|
|
|
2676
2408
|
##### post_only: `boolean`<a id="post_only-boolean"></a>
|
|
2677
2409
|
|
|
2678
|
-
Valid and required only for order type `LIMIT`. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees.
|
|
2410
|
+
Valid and required only for order type `LIMIT`. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees.
|
|
2679
2411
|
|
|
2680
2412
|
##### expiration_date: `string`<a id="expiration_date-string"></a>
|
|
2681
2413
|
|
|
@@ -2707,8 +2439,6 @@ It's recommended to trigger a manual refresh of the account after placing an ord
|
|
|
2707
2439
|
|
|
2708
2440
|
```typescript
|
|
2709
2441
|
const placeForceOrderResponse = await snaptrade.trading.placeForceOrder({
|
|
2710
|
-
userId: "snaptrade-user-123",
|
|
2711
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
2712
2442
|
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
2713
2443
|
action: "BUY",
|
|
2714
2444
|
universal_symbol_id: "2bcd7cc3-e922-4976-bce1-9858296801c3",
|
|
@@ -2736,15 +2466,11 @@ The action describes the intent or side of a trade. This is either `BUY` or `SEL
|
|
|
2736
2466
|
|
|
2737
2467
|
##### order_type: [`OrderTypeStrict`](./models/order-type-strict.ts)<a id="order_type-ordertypestrictmodelsorder-type-strictts"></a>
|
|
2738
2468
|
|
|
2739
|
-
The type of order to place. - For `Limit` and `StopLimit` orders, the `price` field is required. - For `Stop` and `StopLimit` orders, the `stop` field is required.
|
|
2469
|
+
The type of order to place. - For `Limit` and `StopLimit` orders, the `price` field is required. - For `Stop` and `StopLimit` orders, the `stop` field is required.
|
|
2740
2470
|
|
|
2741
2471
|
##### time_in_force: [`ManualTradePlaceTimeInForceStrict`](./models/manual-trade-place-time-in-force-strict.ts)<a id="time_in_force-manualtradeplacetimeinforcestrictmodelsmanual-trade-place-time-in-force-strictts"></a>
|
|
2742
2472
|
|
|
2743
|
-
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. - `GTD` - Good Til Date. The order is valid until `expiry_date`, which is required. Not available for market orders. GTD orders are only available on certain brokerages. Visit https://support.snaptrade.com/brokerages for brokerage support.
|
|
2744
|
-
|
|
2745
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
2746
|
-
|
|
2747
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
2473
|
+
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. - `GTD` - Good Til Date. The order is valid until `expiry_date`, which is required. Not available for market orders. GTD orders are only available on certain brokerages. Visit https://support.snaptrade.com/brokerages for brokerage support.
|
|
2748
2474
|
|
|
2749
2475
|
##### universal_symbol_id: [`string`](./models/model-string.ts)<a id="universal_symbol_id-stringmodelsmodel-stringts"></a>
|
|
2750
2476
|
|
|
@@ -2756,7 +2482,7 @@ The security\\\'s trading ticker symbol. If \\\'symbol\\\' is provided, then \\\
|
|
|
2756
2482
|
|
|
2757
2483
|
##### trading_session: [`TradingSession`](./models/trading-session.ts)<a id="trading_session-tradingsessionmodelstrading-sessionts"></a>
|
|
2758
2484
|
|
|
2759
|
-
The trading session for the order. This field indicates which market session the order will be placed in. This is only available for certain brokerages. Defaults to REGULAR. Here are the supported values: - `REGULAR` - Regular trading hours. - `EXTENDED` - Extended trading hours.
|
|
2485
|
+
The trading session for the order. This field indicates which market session the order will be placed in. This is only available for certain brokerages. Defaults to REGULAR. Here are the supported values: - `REGULAR` - Regular trading hours. - `EXTENDED` - Extended trading hours.
|
|
2760
2486
|
|
|
2761
2487
|
##### expiry_date: `string`<a id="expiry_date-string"></a>
|
|
2762
2488
|
|
|
@@ -2800,8 +2526,6 @@ Places a multi-leg option order. Only supported on certain option trading broker
|
|
|
2800
2526
|
|
|
2801
2527
|
```typescript
|
|
2802
2528
|
const placeMlegOrderResponse = await snaptrade.trading.placeMlegOrder({
|
|
2803
|
-
userId: "snaptrade-user-123",
|
|
2804
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
2805
2529
|
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
2806
2530
|
order_type: "MARKET",
|
|
2807
2531
|
time_in_force: "Day",
|
|
@@ -2829,14 +2553,10 @@ The type of order to place.
|
|
|
2829
2553
|
|
|
2830
2554
|
##### time_in_force: [`TimeInForceStrict`](./models/time-in-force-strict.ts)<a id="time_in_force-timeinforcestrictmodelstime-in-force-strictts"></a>
|
|
2831
2555
|
|
|
2832
|
-
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.
|
|
2556
|
+
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.
|
|
2833
2557
|
|
|
2834
2558
|
##### legs: [`MlegLeg`](./models/mleg-leg.ts)[]<a id="legs-mleglegmodelsmleg-legts"></a>
|
|
2835
2559
|
|
|
2836
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
2837
|
-
|
|
2838
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
2839
|
-
|
|
2840
2560
|
##### accountId: `string`<a id="accountid-string"></a>
|
|
2841
2561
|
|
|
2842
2562
|
##### limit_price: `string`<a id="limit_price-string"></a>
|
|
@@ -2874,8 +2594,6 @@ It's recommended to trigger a manual refresh of the account after placing an ord
|
|
|
2874
2594
|
```typescript
|
|
2875
2595
|
const placeOrderResponse = await snaptrade.trading.placeOrder({
|
|
2876
2596
|
tradeId: "139e307a-82f7-4402-b39e-4da7baa87758",
|
|
2877
|
-
userId: "snaptrade-user-123",
|
|
2878
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
2879
2597
|
wait_to_confirm: true,
|
|
2880
2598
|
});
|
|
2881
2599
|
```
|
|
@@ -2886,10 +2604,6 @@ const placeOrderResponse = await snaptrade.trading.placeOrder({
|
|
|
2886
2604
|
|
|
2887
2605
|
Obtained from calling the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact)
|
|
2888
2606
|
|
|
2889
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
2890
|
-
|
|
2891
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
2892
|
-
|
|
2893
2607
|
##### wait_to_confirm: `boolean`<a id="wait_to_confirm-boolean"></a>
|
|
2894
2608
|
|
|
2895
2609
|
Optional, defaults to true. Determines if a wait is performed to check on order status. If false, latency will be reduced but orders returned will be more likely to be of status `PENDING` as we will not wait to check on the status before responding to the request.
|
|
@@ -2916,8 +2630,6 @@ Previews an order using the specified account.
|
|
|
2916
2630
|
|
|
2917
2631
|
```typescript
|
|
2918
2632
|
const previewCryptoOrderResponse = await snaptrade.trading.previewCryptoOrder({
|
|
2919
|
-
userId: "snaptrade-user-123",
|
|
2920
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
2921
2633
|
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
2922
2634
|
instrument: {
|
|
2923
2635
|
symbol: "BTC",
|
|
@@ -2930,7 +2642,7 @@ const previewCryptoOrderResponse = await snaptrade.trading.previewCryptoOrder({
|
|
|
2930
2642
|
limit_price: "123.45",
|
|
2931
2643
|
stop_price: "123.45",
|
|
2932
2644
|
post_only: false,
|
|
2933
|
-
expiration_date: "2024-01-01T00:00:
|
|
2645
|
+
expiration_date: "2024-01-01T00:00:00.000Z",
|
|
2934
2646
|
});
|
|
2935
2647
|
```
|
|
2936
2648
|
|
|
@@ -2948,16 +2660,12 @@ The type of order to place.
|
|
|
2948
2660
|
|
|
2949
2661
|
##### time_in_force: `string`<a id="time_in_force-string"></a>
|
|
2950
2662
|
|
|
2951
|
-
The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. - `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. - `GTD` - Good Til Date. The order is valid until the specified date.
|
|
2663
|
+
The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. - `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. - `GTD` - Good Til Date. The order is valid until the specified date.
|
|
2952
2664
|
|
|
2953
2665
|
##### amount: `string`<a id="amount-string"></a>
|
|
2954
2666
|
|
|
2955
2667
|
The amount of the base currency to buy or sell.
|
|
2956
2668
|
|
|
2957
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
2958
|
-
|
|
2959
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
2960
|
-
|
|
2961
2669
|
##### accountId: `string`<a id="accountid-string"></a>
|
|
2962
2670
|
|
|
2963
2671
|
##### limit_price: `string`<a id="limit_price-string"></a>
|
|
@@ -2970,7 +2678,7 @@ The stop price. Required if the order type is `STOP_LOSS_MARKET`, `STOP_LOSS_LIM
|
|
|
2970
2678
|
|
|
2971
2679
|
##### post_only: `boolean`<a id="post_only-boolean"></a>
|
|
2972
2680
|
|
|
2973
|
-
Valid and required only for order type `LIMIT`. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees.
|
|
2681
|
+
Valid and required only for order type `LIMIT`. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees.
|
|
2974
2682
|
|
|
2975
2683
|
##### expiration_date: `string`<a id="expiration_date-string"></a>
|
|
2976
2684
|
|
|
@@ -3001,8 +2709,6 @@ returned in the response going forward. Only supported on some brokerages
|
|
|
3001
2709
|
```typescript
|
|
3002
2710
|
const replaceOrderResponse = await snaptrade.trading.replaceOrder({
|
|
3003
2711
|
accountId: "2bcd7cc3-e922-4976-bce1-9858296801c3",
|
|
3004
|
-
userId: "snaptrade-user-123",
|
|
3005
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
3006
2712
|
brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e",
|
|
3007
2713
|
action: "BUY",
|
|
3008
2714
|
order_type: "Market",
|
|
@@ -3026,20 +2732,16 @@ The action describes the intent or side of a trade. This is either `BUY` or `SEL
|
|
|
3026
2732
|
|
|
3027
2733
|
##### order_type: [`OrderTypeStrict`](./models/order-type-strict.ts)<a id="order_type-ordertypestrictmodelsorder-type-strictts"></a>
|
|
3028
2734
|
|
|
3029
|
-
The type of order to place. - For `Limit` and `StopLimit` orders, the `price` field is required. - For `Stop` and `StopLimit` orders, the `stop` field is required.
|
|
2735
|
+
The type of order to place. - For `Limit` and `StopLimit` orders, the `price` field is required. - For `Stop` and `StopLimit` orders, the `stop` field is required.
|
|
3030
2736
|
|
|
3031
2737
|
##### time_in_force: [`TimeInForceStrict`](./models/time-in-force-strict.ts)<a id="time_in_force-timeinforcestrictmodelstime-in-force-strictts"></a>
|
|
3032
2738
|
|
|
3033
|
-
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.
|
|
2739
|
+
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.
|
|
3034
2740
|
|
|
3035
2741
|
##### accountId: `string`<a id="accountid-string"></a>
|
|
3036
2742
|
|
|
3037
2743
|
The ID of the account to execute the trade on.
|
|
3038
2744
|
|
|
3039
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
3040
|
-
|
|
3041
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
3042
|
-
|
|
3043
2745
|
##### price: `number`<a id="price-number"></a>
|
|
3044
2746
|
|
|
3045
2747
|
The limit price for `Limit` and `StopLimit` orders.
|
|
@@ -3077,8 +2779,6 @@ Searches cryptocurrency pairs instruments accessible to the specified account. B
|
|
|
3077
2779
|
```typescript
|
|
3078
2780
|
const searchCryptocurrencyPairInstrumentsResponse =
|
|
3079
2781
|
await snaptrade.trading.searchCryptocurrencyPairInstruments({
|
|
3080
|
-
userId: "snaptrade-user-123",
|
|
3081
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
3082
2782
|
accountId: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
3083
2783
|
base: "BTC",
|
|
3084
2784
|
quote: "USD",
|
|
@@ -3087,10 +2787,6 @@ const searchCryptocurrencyPairInstrumentsResponse =
|
|
|
3087
2787
|
|
|
3088
2788
|
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
|
3089
2789
|
|
|
3090
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
3091
|
-
|
|
3092
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
3093
|
-
|
|
3094
2790
|
##### accountId: `string`<a id="accountid-string"></a>
|
|
3095
2791
|
|
|
3096
2792
|
##### base: `string`<a id="base-string"></a>
|
|
@@ -3129,24 +2825,18 @@ This endpoint returns Daily data. Daily data is cached and refreshed once a day.
|
|
|
3129
2825
|
```typescript
|
|
3130
2826
|
const getActivitiesResponse =
|
|
3131
2827
|
await snaptrade.transactionsAndReporting.getActivities({
|
|
3132
|
-
startDate: "2022-01-
|
|
3133
|
-
endDate: "2022-01-
|
|
2828
|
+
startDate: "2022-01-24T00:00:00.000Z",
|
|
2829
|
+
endDate: "2022-01-24T00:00:00.000Z",
|
|
3134
2830
|
accounts:
|
|
3135
2831
|
"917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2",
|
|
3136
2832
|
brokerageAuthorizations:
|
|
3137
2833
|
"917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2",
|
|
3138
2834
|
type: "BUY,SELL,DIVIDEND",
|
|
3139
|
-
userId: "snaptrade-user-123",
|
|
3140
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
3141
2835
|
});
|
|
3142
2836
|
```
|
|
3143
2837
|
|
|
3144
2838
|
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
|
3145
2839
|
|
|
3146
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
3147
|
-
|
|
3148
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
3149
|
-
|
|
3150
2840
|
##### startDate: `string | Date`<a id="startdate-string--date"></a>
|
|
3151
2841
|
|
|
3152
2842
|
The start date (inclusive) of the transaction history to retrieve. If not provided, the default is the first transaction known to SnapTrade based on `trade_date`.
|
|
@@ -3165,7 +2855,7 @@ Optional comma separated list of SnapTrade Connection (Brokerage Authorization)
|
|
|
3165
2855
|
|
|
3166
2856
|
##### type: `string`<a id="type-string"></a>
|
|
3167
2857
|
|
|
3168
|
-
Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another
|
|
2858
|
+
Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - `BUY` - Asset bought. - `SELL` - Asset sold. - `DIVIDEND` - Dividend payout. - `CONTRIBUTION` - Cash contribution. - `WITHDRAWAL` - Cash withdrawal. - `REI` - Dividend reinvestment. - `INTEREST` - Interest deposited into the account. - `FEE` - Fee withdrawn from the account. - `OPTIONEXPIRATION` - Option expiration event. - `OPTIONASSIGNMENT` - Option assignment event. - `OPTIONEXERCISE` - Option exercise event. - `TRANSFER` - Transfer of assets from one account to another
|
|
3169
2859
|
|
|
3170
2860
|
#### 🔄 Return<a id="🔄-return"></a>
|
|
3171
2861
|
|
|
@@ -3190,14 +2880,12 @@ Returns performance information (contributions, dividends, rate of return, etc)
|
|
|
3190
2880
|
```typescript
|
|
3191
2881
|
const getReportingCustomRangeResponse =
|
|
3192
2882
|
await snaptrade.transactionsAndReporting.getReportingCustomRange({
|
|
3193
|
-
startDate: "2022-01-
|
|
3194
|
-
endDate: "2022-01-
|
|
2883
|
+
startDate: "2022-01-24T00:00:00.000Z",
|
|
2884
|
+
endDate: "2022-01-24T00:00:00.000Z",
|
|
3195
2885
|
accounts:
|
|
3196
2886
|
"917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2",
|
|
3197
2887
|
detailed: true,
|
|
3198
2888
|
frequency: "monthly",
|
|
3199
|
-
userId: "snaptrade-user-123",
|
|
3200
|
-
userSecret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
3201
2889
|
});
|
|
3202
2890
|
```
|
|
3203
2891
|
|
|
@@ -3207,10 +2895,6 @@ const getReportingCustomRangeResponse =
|
|
|
3207
2895
|
|
|
3208
2896
|
##### endDate: `string | Date`<a id="enddate-string--date"></a>
|
|
3209
2897
|
|
|
3210
|
-
##### userId: `string`<a id="userid-string"></a>
|
|
3211
|
-
|
|
3212
|
-
##### userSecret: `string`<a id="usersecret-string"></a>
|
|
3213
|
-
|
|
3214
2898
|
##### accounts: `string`<a id="accounts-string"></a>
|
|
3215
2899
|
|
|
3216
2900
|
Optional comma separated list of account IDs used to filter the request on specific accounts
|