topstepx-api 1.0.3 → 2.0.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/CHANGELOG.md +152 -0
- package/MIGRATION.md +515 -0
- package/README.md +221 -116
- package/dist/index.cjs +599 -92
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +346 -197
- package/dist/index.d.ts +346 -197
- package/dist/index.js +593 -85
- package/dist/index.js.map +1 -1
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ Get your API key from your TopstepX account settings.
|
|
|
31
31
|
## Quick Start
|
|
32
32
|
|
|
33
33
|
```typescript
|
|
34
|
-
import { TopstepXClient,
|
|
34
|
+
import { TopstepXClient, OrderTypeEnum, OrderSideEnum } from 'topstepx-api';
|
|
35
35
|
|
|
36
36
|
const client = new TopstepXClient({
|
|
37
37
|
username: process.env.TOPSTEP_USERNAME!,
|
|
@@ -41,15 +41,15 @@ const client = new TopstepXClient({
|
|
|
41
41
|
await client.connect();
|
|
42
42
|
|
|
43
43
|
// Get accounts
|
|
44
|
-
const
|
|
45
|
-
console.log('Accounts:', accounts);
|
|
44
|
+
const response = await client.accounts.search({ onlyActiveAccounts: true });
|
|
45
|
+
console.log('Accounts:', response.accounts);
|
|
46
46
|
|
|
47
47
|
// Place a market order
|
|
48
48
|
const order = await client.orders.place({
|
|
49
|
-
accountId: accounts[0].id,
|
|
49
|
+
accountId: response.accounts[0].id,
|
|
50
50
|
contractId: 'CON.F.US.ENQ.M25',
|
|
51
|
-
type:
|
|
52
|
-
side:
|
|
51
|
+
type: OrderTypeEnum.Market,
|
|
52
|
+
side: OrderSideEnum.Buy,
|
|
53
53
|
size: 1,
|
|
54
54
|
});
|
|
55
55
|
console.log('Order placed:', order.orderId);
|
|
@@ -106,12 +106,19 @@ Access via `client.accounts`
|
|
|
106
106
|
Search for accounts.
|
|
107
107
|
|
|
108
108
|
```typescript
|
|
109
|
-
const
|
|
109
|
+
const response = await client.accounts.search({
|
|
110
110
|
onlyActiveAccounts: boolean;
|
|
111
111
|
});
|
|
112
112
|
|
|
113
|
-
// Returns:
|
|
114
|
-
interface
|
|
113
|
+
// Returns: SearchAccountsResponseInterface
|
|
114
|
+
interface SearchAccountsResponseInterface {
|
|
115
|
+
accounts: AccountInterface[];
|
|
116
|
+
success: boolean;
|
|
117
|
+
errorCode: number;
|
|
118
|
+
errorMessage: string | null;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
interface AccountInterface {
|
|
115
122
|
id: number;
|
|
116
123
|
name: string;
|
|
117
124
|
canTrade: boolean;
|
|
@@ -130,13 +137,13 @@ Access via `client.orders`
|
|
|
130
137
|
Place a new order.
|
|
131
138
|
|
|
132
139
|
```typescript
|
|
133
|
-
import {
|
|
140
|
+
import { OrderTypeEnum, OrderSideEnum } from 'topstepx-api';
|
|
134
141
|
|
|
135
142
|
const result = await client.orders.place({
|
|
136
143
|
accountId: number;
|
|
137
144
|
contractId: string;
|
|
138
|
-
type:
|
|
139
|
-
side:
|
|
145
|
+
type: OrderTypeEnum; // Market, Limit, Stop, StopLimit
|
|
146
|
+
side: OrderSideEnum; // Buy, Sell
|
|
140
147
|
size: number;
|
|
141
148
|
limitPrice?: number; // Required for Limit/StopLimit
|
|
142
149
|
stopPrice?: number; // Required for Stop/StopLimit
|
|
@@ -145,7 +152,13 @@ const result = await client.orders.place({
|
|
|
145
152
|
linkedOrderId?: number; // Optional linked order (OCO)
|
|
146
153
|
});
|
|
147
154
|
|
|
148
|
-
// Returns:
|
|
155
|
+
// Returns: PlaceOrderResponseInterface
|
|
156
|
+
interface PlaceOrderResponseInterface {
|
|
157
|
+
orderId: number;
|
|
158
|
+
success: boolean;
|
|
159
|
+
errorCode: number;
|
|
160
|
+
errorMessage: string | null;
|
|
161
|
+
}
|
|
149
162
|
```
|
|
150
163
|
|
|
151
164
|
#### cancel
|
|
@@ -153,10 +166,17 @@ const result = await client.orders.place({
|
|
|
153
166
|
Cancel an existing order.
|
|
154
167
|
|
|
155
168
|
```typescript
|
|
156
|
-
await client.orders.cancel({
|
|
169
|
+
const response = await client.orders.cancel({
|
|
157
170
|
accountId: number;
|
|
158
171
|
orderId: number;
|
|
159
172
|
});
|
|
173
|
+
|
|
174
|
+
// Returns: CancelOrderResponseInterface
|
|
175
|
+
interface CancelOrderResponseInterface {
|
|
176
|
+
success: boolean;
|
|
177
|
+
errorCode: number;
|
|
178
|
+
errorMessage: string | null;
|
|
179
|
+
}
|
|
160
180
|
```
|
|
161
181
|
|
|
162
182
|
#### modify
|
|
@@ -164,7 +184,7 @@ await client.orders.cancel({
|
|
|
164
184
|
Modify an existing order.
|
|
165
185
|
|
|
166
186
|
```typescript
|
|
167
|
-
await client.orders.modify({
|
|
187
|
+
const response = await client.orders.modify({
|
|
168
188
|
accountId: number;
|
|
169
189
|
orderId: number;
|
|
170
190
|
size?: number;
|
|
@@ -172,6 +192,13 @@ await client.orders.modify({
|
|
|
172
192
|
stopPrice?: number;
|
|
173
193
|
trailPrice?: number;
|
|
174
194
|
});
|
|
195
|
+
|
|
196
|
+
// Returns: ModifyOrderResponseInterface
|
|
197
|
+
interface ModifyOrderResponseInterface {
|
|
198
|
+
success: boolean;
|
|
199
|
+
errorCode: number;
|
|
200
|
+
errorMessage: string | null;
|
|
201
|
+
}
|
|
175
202
|
```
|
|
176
203
|
|
|
177
204
|
#### search
|
|
@@ -179,22 +206,29 @@ await client.orders.modify({
|
|
|
179
206
|
Search historical orders.
|
|
180
207
|
|
|
181
208
|
```typescript
|
|
182
|
-
const
|
|
209
|
+
const response = await client.orders.search({
|
|
183
210
|
accountId: number;
|
|
184
211
|
startTimestamp?: string; // ISO 8601 format
|
|
185
212
|
endTimestamp?: string;
|
|
186
213
|
});
|
|
187
214
|
|
|
188
|
-
// Returns:
|
|
189
|
-
interface
|
|
215
|
+
// Returns: SearchOrdersResponseInterface
|
|
216
|
+
interface SearchOrdersResponseInterface {
|
|
217
|
+
orders: OrderInterface[];
|
|
218
|
+
success: boolean;
|
|
219
|
+
errorCode: number;
|
|
220
|
+
errorMessage: string | null;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
interface OrderInterface {
|
|
190
224
|
id: number;
|
|
191
225
|
accountId: number;
|
|
192
226
|
contractId: string;
|
|
193
227
|
creationTimestamp: string;
|
|
194
228
|
updateTimestamp: string | null;
|
|
195
|
-
status:
|
|
196
|
-
type:
|
|
197
|
-
side:
|
|
229
|
+
status: OrderStatusEnum;
|
|
230
|
+
type: OrderTypeEnum;
|
|
231
|
+
side: OrderSideEnum;
|
|
198
232
|
size: number;
|
|
199
233
|
limitPrice: number | null;
|
|
200
234
|
stopPrice: number | null;
|
|
@@ -206,9 +240,17 @@ interface Order {
|
|
|
206
240
|
Get currently open orders.
|
|
207
241
|
|
|
208
242
|
```typescript
|
|
209
|
-
const
|
|
243
|
+
const response = await client.orders.searchOpen({
|
|
210
244
|
accountId: number;
|
|
211
245
|
});
|
|
246
|
+
|
|
247
|
+
// Returns: SearchOpenOrdersResponseInterface
|
|
248
|
+
interface SearchOpenOrdersResponseInterface {
|
|
249
|
+
orders: OrderInterface[];
|
|
250
|
+
success: boolean;
|
|
251
|
+
errorCode: number;
|
|
252
|
+
errorMessage: string | null;
|
|
253
|
+
}
|
|
212
254
|
```
|
|
213
255
|
|
|
214
256
|
---
|
|
@@ -222,17 +264,24 @@ Access via `client.positions`
|
|
|
222
264
|
Get open positions.
|
|
223
265
|
|
|
224
266
|
```typescript
|
|
225
|
-
const
|
|
267
|
+
const response = await client.positions.searchOpen({
|
|
226
268
|
accountId: number;
|
|
227
269
|
});
|
|
228
270
|
|
|
229
|
-
// Returns:
|
|
230
|
-
interface
|
|
271
|
+
// Returns: SearchOpenPositionsResponseInterface
|
|
272
|
+
interface SearchOpenPositionsResponseInterface {
|
|
273
|
+
positions: PositionInterface[];
|
|
274
|
+
success: boolean;
|
|
275
|
+
errorCode: number;
|
|
276
|
+
errorMessage: string | null;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
interface PositionInterface {
|
|
231
280
|
id: number;
|
|
232
281
|
accountId: number;
|
|
233
282
|
contractId: string;
|
|
234
283
|
creationTimestamp: string;
|
|
235
|
-
type:
|
|
284
|
+
type: PositionTypeEnum; // Long, Short
|
|
236
285
|
size: number;
|
|
237
286
|
averagePrice: number;
|
|
238
287
|
}
|
|
@@ -243,10 +292,17 @@ interface Position {
|
|
|
243
292
|
Close a position entirely.
|
|
244
293
|
|
|
245
294
|
```typescript
|
|
246
|
-
await client.positions.close({
|
|
295
|
+
const response = await client.positions.close({
|
|
247
296
|
accountId: number;
|
|
248
297
|
contractId: string;
|
|
249
298
|
});
|
|
299
|
+
|
|
300
|
+
// Returns: ClosePositionResponseInterface
|
|
301
|
+
interface ClosePositionResponseInterface {
|
|
302
|
+
success: boolean;
|
|
303
|
+
errorCode: number;
|
|
304
|
+
errorMessage: string | null;
|
|
305
|
+
}
|
|
250
306
|
```
|
|
251
307
|
|
|
252
308
|
#### partialClose
|
|
@@ -254,11 +310,18 @@ await client.positions.close({
|
|
|
254
310
|
Partially close a position.
|
|
255
311
|
|
|
256
312
|
```typescript
|
|
257
|
-
await client.positions.partialClose({
|
|
313
|
+
const response = await client.positions.partialClose({
|
|
258
314
|
accountId: number;
|
|
259
315
|
contractId: string;
|
|
260
316
|
size: number; // Number of contracts to close
|
|
261
317
|
});
|
|
318
|
+
|
|
319
|
+
// Returns: PartialClosePositionResponseInterface
|
|
320
|
+
interface PartialClosePositionResponseInterface {
|
|
321
|
+
success: boolean;
|
|
322
|
+
errorCode: number;
|
|
323
|
+
errorMessage: string | null;
|
|
324
|
+
}
|
|
262
325
|
```
|
|
263
326
|
|
|
264
327
|
---
|
|
@@ -272,14 +335,21 @@ Access via `client.trades`
|
|
|
272
335
|
Search trade history.
|
|
273
336
|
|
|
274
337
|
```typescript
|
|
275
|
-
const
|
|
338
|
+
const response = await client.trades.search({
|
|
276
339
|
accountId: number;
|
|
277
340
|
startTimestamp: string; // ISO 8601 format
|
|
278
341
|
endTimestamp: string;
|
|
279
342
|
});
|
|
280
343
|
|
|
281
|
-
// Returns:
|
|
282
|
-
interface
|
|
344
|
+
// Returns: SearchTradesResponseInterface
|
|
345
|
+
interface SearchTradesResponseInterface {
|
|
346
|
+
trades: TradeInterface[];
|
|
347
|
+
success: boolean;
|
|
348
|
+
errorCode: number;
|
|
349
|
+
errorMessage: string | null;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
interface TradeInterface {
|
|
283
353
|
id: number;
|
|
284
354
|
accountId: number;
|
|
285
355
|
contractId: string;
|
|
@@ -287,7 +357,7 @@ interface Trade {
|
|
|
287
357
|
price: number;
|
|
288
358
|
profitAndLoss: number | null;
|
|
289
359
|
fees: number;
|
|
290
|
-
side:
|
|
360
|
+
side: OrderSideEnum;
|
|
291
361
|
size: number;
|
|
292
362
|
voided: boolean;
|
|
293
363
|
orderId: number;
|
|
@@ -305,13 +375,20 @@ Access via `client.contracts`
|
|
|
305
375
|
Search for contracts/symbols.
|
|
306
376
|
|
|
307
377
|
```typescript
|
|
308
|
-
const
|
|
378
|
+
const response = await client.contracts.search({
|
|
309
379
|
searchText: string; // e.g., "ES", "NQ", "CL"
|
|
310
380
|
live: boolean; // true for live, false for sim
|
|
311
381
|
});
|
|
312
382
|
|
|
313
|
-
// Returns:
|
|
314
|
-
interface
|
|
383
|
+
// Returns: SearchContractsResponseInterface
|
|
384
|
+
interface SearchContractsResponseInterface {
|
|
385
|
+
contracts: ContractInterface[];
|
|
386
|
+
success: boolean;
|
|
387
|
+
errorCode: number;
|
|
388
|
+
errorMessage: string | null;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
interface ContractInterface {
|
|
315
392
|
id: string;
|
|
316
393
|
name: string;
|
|
317
394
|
description: string;
|
|
@@ -326,12 +403,18 @@ interface Contract {
|
|
|
326
403
|
Get a specific contract by ID.
|
|
327
404
|
|
|
328
405
|
```typescript
|
|
329
|
-
const
|
|
406
|
+
const response = await client.contracts.searchById({
|
|
330
407
|
contractId: string; // e.g., "CON.F.US.ENQ.M25"
|
|
331
408
|
live: boolean;
|
|
332
409
|
});
|
|
333
410
|
|
|
334
|
-
// Returns:
|
|
411
|
+
// Returns: SearchContractByIdResponseInterface
|
|
412
|
+
interface SearchContractByIdResponseInterface {
|
|
413
|
+
contract: ContractInterface | null;
|
|
414
|
+
success: boolean;
|
|
415
|
+
errorCode: number;
|
|
416
|
+
errorMessage: string | null;
|
|
417
|
+
}
|
|
335
418
|
```
|
|
336
419
|
|
|
337
420
|
---
|
|
@@ -345,21 +428,28 @@ Access via `client.history`
|
|
|
345
428
|
Get historical OHLCV bars.
|
|
346
429
|
|
|
347
430
|
```typescript
|
|
348
|
-
import {
|
|
431
|
+
import { BarUnitEnum } from 'topstepx-api';
|
|
349
432
|
|
|
350
|
-
const
|
|
433
|
+
const response = await client.history.retrieveBars({
|
|
351
434
|
contractId: string;
|
|
352
435
|
live: boolean;
|
|
353
436
|
startTime: string; // ISO 8601 format
|
|
354
437
|
endTime: string;
|
|
355
|
-
unit:
|
|
438
|
+
unit: BarUnitEnum; // Second, Minute, Hour, Day, Week, Month
|
|
356
439
|
unitNumber: number; // e.g., 5 for 5-minute bars
|
|
357
440
|
limit: number; // Max bars to return
|
|
358
441
|
includePartialBar: boolean;
|
|
359
442
|
});
|
|
360
443
|
|
|
361
|
-
// Returns:
|
|
362
|
-
interface
|
|
444
|
+
// Returns: RetrieveBarsResponseInterface
|
|
445
|
+
interface RetrieveBarsResponseInterface {
|
|
446
|
+
bars: BarInterface[];
|
|
447
|
+
success: boolean;
|
|
448
|
+
errorCode: number;
|
|
449
|
+
errorMessage: string | null;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
interface BarInterface {
|
|
363
453
|
t: string; // timestamp
|
|
364
454
|
o: number; // open
|
|
365
455
|
h: number; // high
|
|
@@ -428,7 +518,7 @@ client.marketHub.on('depth', ({ contractId, data }) => {
|
|
|
428
518
|
#### Event Types
|
|
429
519
|
|
|
430
520
|
```typescript
|
|
431
|
-
interface
|
|
521
|
+
interface RealtimeMarketQuoteEventInterface {
|
|
432
522
|
symbol: string;
|
|
433
523
|
lastPrice: number;
|
|
434
524
|
bestBid: number;
|
|
@@ -440,7 +530,7 @@ interface Quote {
|
|
|
440
530
|
timestamp: string;
|
|
441
531
|
}
|
|
442
532
|
|
|
443
|
-
interface
|
|
533
|
+
interface RealtimeMarketTradeEventInterface {
|
|
444
534
|
symbolId: string;
|
|
445
535
|
price: number;
|
|
446
536
|
timestamp: string;
|
|
@@ -448,7 +538,7 @@ interface MarketTrade {
|
|
|
448
538
|
volume: number;
|
|
449
539
|
}
|
|
450
540
|
|
|
451
|
-
interface
|
|
541
|
+
interface RealtimeMarketDepthEventInterface {
|
|
452
542
|
price: number;
|
|
453
543
|
volume: number;
|
|
454
544
|
currentVolume: number;
|
|
@@ -513,43 +603,43 @@ client.userHub.on('account', (account) => {
|
|
|
513
603
|
|
|
514
604
|
```typescript
|
|
515
605
|
import {
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
606
|
+
OrderTypeEnum,
|
|
607
|
+
OrderSideEnum,
|
|
608
|
+
OrderStatusEnum,
|
|
609
|
+
BarUnitEnum,
|
|
610
|
+
PositionTypeEnum,
|
|
611
|
+
TradeTypeEnum,
|
|
522
612
|
} from 'topstepx-api';
|
|
523
613
|
|
|
524
|
-
//
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
//
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
//
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
//
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
//
|
|
551
|
-
|
|
552
|
-
|
|
614
|
+
// OrderTypeEnum
|
|
615
|
+
OrderTypeEnum.Limit // 1
|
|
616
|
+
OrderTypeEnum.Market // 2
|
|
617
|
+
OrderTypeEnum.Stop // 3
|
|
618
|
+
OrderTypeEnum.StopLimit // 4
|
|
619
|
+
|
|
620
|
+
// OrderSideEnum
|
|
621
|
+
OrderSideEnum.Buy // 0
|
|
622
|
+
OrderSideEnum.Sell // 1
|
|
623
|
+
|
|
624
|
+
// OrderStatusEnum
|
|
625
|
+
OrderStatusEnum.Pending // 0
|
|
626
|
+
OrderStatusEnum.Working // 1
|
|
627
|
+
OrderStatusEnum.Filled // 2
|
|
628
|
+
OrderStatusEnum.Cancelled // 3
|
|
629
|
+
OrderStatusEnum.Rejected // 4
|
|
630
|
+
OrderStatusEnum.PartiallyFilled // 5
|
|
631
|
+
|
|
632
|
+
// BarUnitEnum
|
|
633
|
+
BarUnitEnum.Second // 1
|
|
634
|
+
BarUnitEnum.Minute // 2
|
|
635
|
+
BarUnitEnum.Hour // 3
|
|
636
|
+
BarUnitEnum.Day // 4
|
|
637
|
+
BarUnitEnum.Week // 5
|
|
638
|
+
BarUnitEnum.Month // 6
|
|
639
|
+
|
|
640
|
+
// PositionTypeEnum
|
|
641
|
+
PositionTypeEnum.Long // 0
|
|
642
|
+
PositionTypeEnum.Short // 1
|
|
553
643
|
```
|
|
554
644
|
|
|
555
645
|
---
|
|
@@ -593,9 +683,9 @@ All errors extend `TopstepXError` and include:
|
|
|
593
683
|
```typescript
|
|
594
684
|
import {
|
|
595
685
|
TopstepXClient,
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
686
|
+
OrderTypeEnum,
|
|
687
|
+
OrderSideEnum,
|
|
688
|
+
BarUnitEnum,
|
|
599
689
|
ApiError,
|
|
600
690
|
} from 'topstepx-api';
|
|
601
691
|
import 'dotenv/config';
|
|
@@ -612,33 +702,33 @@ async function main() {
|
|
|
612
702
|
console.log('Connected to TopstepX');
|
|
613
703
|
|
|
614
704
|
// Get accounts
|
|
615
|
-
const
|
|
616
|
-
const account = accounts[0];
|
|
705
|
+
const accountsResponse = await client.accounts.search({ onlyActiveAccounts: true });
|
|
706
|
+
const account = accountsResponse.accounts[0];
|
|
617
707
|
console.log(`Using account: ${account.name} (${account.id})`);
|
|
618
708
|
|
|
619
709
|
// Search for ES contract
|
|
620
|
-
const
|
|
710
|
+
const contractsResponse = await client.contracts.search({
|
|
621
711
|
searchText: 'ES',
|
|
622
712
|
live: false,
|
|
623
713
|
});
|
|
624
|
-
const esContract = contracts.find(c => c.activeContract);
|
|
714
|
+
const esContract = contractsResponse.contracts.find(c => c.activeContract);
|
|
625
715
|
console.log(`Found contract: ${esContract?.id}`);
|
|
626
716
|
|
|
627
717
|
// Get historical data
|
|
628
718
|
const endTime = new Date();
|
|
629
719
|
const startTime = new Date(endTime.getTime() - 24 * 60 * 60 * 1000);
|
|
630
720
|
|
|
631
|
-
const
|
|
721
|
+
const barsResponse = await client.history.retrieveBars({
|
|
632
722
|
contractId: esContract!.id,
|
|
633
723
|
live: false,
|
|
634
724
|
startTime: startTime.toISOString(),
|
|
635
725
|
endTime: endTime.toISOString(),
|
|
636
|
-
unit:
|
|
726
|
+
unit: BarUnitEnum.Hour,
|
|
637
727
|
unitNumber: 1,
|
|
638
728
|
limit: 24,
|
|
639
729
|
includePartialBar: false,
|
|
640
730
|
});
|
|
641
|
-
console.log(`Retrieved ${bars.length} hourly bars`);
|
|
731
|
+
console.log(`Retrieved ${barsResponse.bars.length} hourly bars`);
|
|
642
732
|
|
|
643
733
|
// Subscribe to real-time quotes
|
|
644
734
|
client.marketHub.on('quote', ({ contractId, data }) => {
|
|
@@ -657,16 +747,16 @@ async function main() {
|
|
|
657
747
|
const order = await client.orders.place({
|
|
658
748
|
accountId: account.id,
|
|
659
749
|
contractId: esContract!.id,
|
|
660
|
-
type:
|
|
661
|
-
side:
|
|
750
|
+
type: OrderTypeEnum.Limit,
|
|
751
|
+
side: OrderSideEnum.Buy,
|
|
662
752
|
size: 1,
|
|
663
|
-
limitPrice: bars[bars.length - 1].c - 10, // 10 points below last close
|
|
753
|
+
limitPrice: barsResponse.bars[barsResponse.bars.length - 1].c - 10, // 10 points below last close
|
|
664
754
|
});
|
|
665
755
|
console.log(`Placed order: ${order.orderId}`);
|
|
666
756
|
|
|
667
757
|
// Check open orders
|
|
668
|
-
const
|
|
669
|
-
console.log(`Open orders: ${
|
|
758
|
+
const openOrdersResponse = await client.orders.searchOpen({ accountId: account.id });
|
|
759
|
+
console.log(`Open orders: ${openOrdersResponse.orders.length}`);
|
|
670
760
|
|
|
671
761
|
// Cancel the order
|
|
672
762
|
await client.orders.cancel({
|
|
@@ -705,27 +795,42 @@ import type {
|
|
|
705
795
|
TopstepXClientConfig,
|
|
706
796
|
TopstepXClientEvents,
|
|
707
797
|
|
|
708
|
-
// REST
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
//
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
798
|
+
// REST domain models
|
|
799
|
+
AccountInterface,
|
|
800
|
+
OrderInterface,
|
|
801
|
+
PositionInterface,
|
|
802
|
+
TradeInterface,
|
|
803
|
+
ContractInterface,
|
|
804
|
+
BarInterface,
|
|
805
|
+
|
|
806
|
+
// Response interfaces
|
|
807
|
+
SearchAccountsResponseInterface,
|
|
808
|
+
PlaceOrderResponseInterface,
|
|
809
|
+
CancelOrderResponseInterface,
|
|
810
|
+
ModifyOrderResponseInterface,
|
|
811
|
+
SearchOrdersResponseInterface,
|
|
812
|
+
SearchOpenOrdersResponseInterface,
|
|
813
|
+
SearchOpenPositionsResponseInterface,
|
|
814
|
+
ClosePositionResponseInterface,
|
|
815
|
+
PartialClosePositionResponseInterface,
|
|
816
|
+
SearchTradesResponseInterface,
|
|
817
|
+
SearchContractsResponseInterface,
|
|
818
|
+
SearchContractByIdResponseInterface,
|
|
819
|
+
RetrieveBarsResponseInterface,
|
|
820
|
+
|
|
821
|
+
// Request interfaces
|
|
822
|
+
PlaceOrderRequestInterface,
|
|
823
|
+
ModifyOrderRequestInterface,
|
|
824
|
+
SearchOrdersRequestInterface,
|
|
825
|
+
RetrieveBarsRequestInterface,
|
|
826
|
+
|
|
827
|
+
// WebSocket interfaces
|
|
828
|
+
RealtimeMarketQuoteEventInterface,
|
|
829
|
+
RealtimeMarketTradeEventInterface,
|
|
830
|
+
RealtimeMarketDepthEventInterface,
|
|
831
|
+
RealtimeUserOrderUpdateInterface,
|
|
832
|
+
RealtimeUserPositionUpdateInterface,
|
|
833
|
+
RealtimeUserTradeUpdateInterface,
|
|
729
834
|
} from 'topstepx-api';
|
|
730
835
|
```
|
|
731
836
|
|