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/dist/index.d.mts CHANGED
@@ -1,10 +1,11 @@
1
1
  import { HubConnection } from '@microsoft/signalr';
2
2
 
3
- interface HttpClientConfig {
3
+ interface HttpClientConfigInterface {
4
4
  baseUrl: string;
5
5
  getToken: () => Promise<string>;
6
6
  timeout?: number;
7
7
  }
8
+
8
9
  interface ApiResponseBase {
9
10
  success: boolean;
10
11
  errorCode: number;
@@ -12,21 +13,23 @@ interface ApiResponseBase {
12
13
  }
13
14
  declare class HttpClient {
14
15
  private readonly config;
15
- constructor(config: HttpClientConfig);
16
+ constructor(config: HttpClientConfigInterface);
16
17
  post<TRequest, TResponse extends ApiResponseBase>(endpoint: string, data: TRequest): Promise<TResponse>;
17
18
  }
18
19
 
19
- interface Account {
20
+ interface SearchAccountsRequestInterface {
21
+ onlyActiveAccounts?: boolean;
22
+ }
23
+
24
+ interface AccountInterface {
20
25
  id: number;
21
26
  name: string;
22
27
  canTrade: boolean;
23
28
  isVisible: boolean;
24
29
  }
25
- interface SearchAccountsRequest {
26
- onlyActiveAccounts: boolean;
27
- }
28
- interface SearchAccountsResponse {
29
- accounts: Account[];
30
+
31
+ interface SearchAccountsResponseInterface {
32
+ accounts: AccountInterface[];
30
33
  success: boolean;
31
34
  errorCode: number;
32
35
  errorMessage: string | null;
@@ -35,14 +38,14 @@ interface SearchAccountsResponse {
35
38
  declare class AccountApi {
36
39
  private readonly http;
37
40
  constructor(http: HttpClient);
38
- search(request: SearchAccountsRequest): Promise<SearchAccountsResponse>;
41
+ search(request: SearchAccountsRequestInterface): Promise<SearchAccountsResponseInterface>;
39
42
  }
40
43
 
41
44
  /**
42
45
  * Type of order to place.
43
46
  * @category Enums
44
47
  */
45
- declare enum OrderType {
48
+ declare enum OrderTypeEnum {
46
49
  /** Limit order - executes at specified price or better */
47
50
  Limit = 1,
48
51
  /** Market order - executes immediately at current market price */
@@ -52,21 +55,73 @@ declare enum OrderType {
52
55
  /** Stop-limit order - becomes limit order when stop price is reached */
53
56
  StopLimit = 4
54
57
  }
58
+
55
59
  /**
56
60
  * Side of the order (buy or sell).
57
61
  * @category Enums
58
62
  */
59
- declare enum OrderSide {
63
+ declare enum OrderSideEnum {
60
64
  /** Buy order - go long or close short position */
61
65
  Buy = 0,
62
66
  /** Sell order - go short or close long position */
63
67
  Sell = 1
64
68
  }
69
+
70
+ interface PlaceOrderRequestInterface {
71
+ accountId: number;
72
+ contractId: string;
73
+ type: OrderTypeEnum;
74
+ side: OrderSideEnum;
75
+ size: number;
76
+ limitPrice?: number | null;
77
+ stopPrice?: number | null;
78
+ trailPrice?: number | null;
79
+ customTag?: string | null;
80
+ linkedOrderId?: number | null;
81
+ }
82
+
83
+ interface PlaceOrderResponseInterface {
84
+ orderId: number;
85
+ success: boolean;
86
+ errorCode: number;
87
+ errorMessage: string | null;
88
+ }
89
+
90
+ interface SearchOrdersRequestInterface {
91
+ accountId: number;
92
+ startTimestamp?: string;
93
+ endTimestamp?: string;
94
+ }
95
+
96
+ interface ApiResponse<T = unknown> {
97
+ success: boolean;
98
+ errorCode: number;
99
+ errorMessage: string | null;
100
+ [key: string]: T | boolean | number | string | null | undefined;
101
+ }
102
+ interface TopstepXClientConfig {
103
+ username: string;
104
+ apiKey: string;
105
+ baseUrl?: string;
106
+ marketHubUrl?: string;
107
+ userHubUrl?: string;
108
+ autoRefresh?: boolean;
109
+ tokenValidityHours?: number;
110
+ }
111
+ interface TopstepXClientEvents {
112
+ [key: string]: unknown;
113
+ connected: void;
114
+ disconnected: void;
115
+ error: Error;
116
+ reconnecting: void;
117
+ reconnected: void;
118
+ }
119
+
65
120
  /**
66
121
  * Current status of an order.
67
122
  * @category Enums
68
123
  */
69
- declare enum OrderStatus {
124
+ declare enum OrderStatusEnum {
70
125
  /** Order is pending submission */
71
126
  Pending = 0,
72
127
  /** Order is working (open) in the market */
@@ -80,106 +135,73 @@ declare enum OrderStatus {
80
135
  /** Order is partially filled */
81
136
  PartiallyFilled = 5
82
137
  }
83
- /**
84
- * Time unit for historical bar data.
85
- * @category Enums
86
- */
87
- declare enum BarUnit {
88
- /** Second bars */
89
- Second = 1,
90
- /** Minute bars */
91
- Minute = 2,
92
- /** Hourly bars */
93
- Hour = 3,
94
- /** Daily bars */
95
- Day = 4,
96
- /** Weekly bars */
97
- Week = 5,
98
- /** Monthly bars */
99
- Month = 6
100
- }
138
+
101
139
  /**
102
140
  * Type of position (long or short).
103
141
  * @category Enums
104
142
  */
105
- declare enum PositionType {
143
+ declare enum PositionTypeEnum {
106
144
  /** Long position - bought contracts */
107
145
  Long = 0,
108
146
  /** Short position - sold contracts */
109
147
  Short = 1
110
148
  }
149
+
111
150
  /**
112
151
  * Type of trade execution.
113
152
  * @category Enums
114
153
  */
115
- declare enum TradeType {
154
+ declare enum TradeTypeEnum {
116
155
  /** Trade executed at bid price */
117
156
  Bid = 0,
118
157
  /** Trade executed at ask price */
119
158
  Ask = 1
120
159
  }
121
160
 
122
- interface Order {
161
+ interface OrderInterface {
123
162
  id: number;
124
163
  accountId: number;
125
164
  contractId: string;
126
165
  creationTimestamp: string;
127
166
  updateTimestamp: string | null;
128
- status: OrderStatus;
129
- type: OrderType;
130
- side: OrderSide;
167
+ status: OrderStatusEnum;
168
+ type: OrderTypeEnum;
169
+ side: OrderSideEnum;
131
170
  size: number;
132
171
  limitPrice: number | null;
133
172
  stopPrice: number | null;
134
173
  }
135
- interface PlaceOrderRequest {
136
- accountId: number;
137
- contractId: string;
138
- type: OrderType;
139
- side: OrderSide;
140
- size: number;
141
- limitPrice?: number | null;
142
- stopPrice?: number | null;
143
- trailPrice?: number | null;
144
- customTag?: string | null;
145
- linkedOrderId?: number | null;
146
- }
147
- interface PlaceOrderResponse {
148
- orderId: number;
149
- success: boolean;
150
- errorCode: number;
151
- errorMessage: string | null;
152
- }
153
- interface SearchOrdersRequest {
154
- accountId: number;
155
- startTimestamp?: string;
156
- endTimestamp?: string;
157
- }
158
- interface SearchOrdersResponse {
159
- orders: Order[];
174
+
175
+ interface SearchOrdersResponseInterface {
176
+ orders: OrderInterface[];
160
177
  success: boolean;
161
178
  errorCode: number;
162
179
  errorMessage: string | null;
163
180
  }
164
- interface SearchOpenOrdersRequest {
181
+
182
+ interface SearchOpenOrdersRequestInterface {
165
183
  accountId: number;
166
184
  }
167
- interface SearchOpenOrdersResponse {
168
- orders: Order[];
185
+
186
+ interface SearchOpenOrdersResponseInterface {
187
+ orders: OrderInterface[];
169
188
  success: boolean;
170
189
  errorCode: number;
171
190
  errorMessage: string | null;
172
191
  }
173
- interface CancelOrderRequest {
192
+
193
+ interface CancelOrderRequestInterface {
174
194
  accountId: number;
175
195
  orderId: number;
176
196
  }
177
- interface CancelOrderResponse {
197
+
198
+ interface CancelOrderResponseInterface {
178
199
  success: boolean;
179
200
  errorCode: number;
180
201
  errorMessage: string | null;
181
202
  }
182
- interface ModifyOrderRequest {
203
+
204
+ interface ModifyOrderRequestInterface {
183
205
  accountId: number;
184
206
  orderId: number;
185
207
  size?: number;
@@ -187,7 +209,8 @@ interface ModifyOrderRequest {
187
209
  stopPrice?: number | null;
188
210
  trailPrice?: number | null;
189
211
  }
190
- interface ModifyOrderResponse {
212
+
213
+ interface ModifyOrderResponseInterface {
191
214
  success: boolean;
192
215
  errorCode: number;
193
216
  errorMessage: string | null;
@@ -222,13 +245,13 @@ declare class OrderApi {
222
245
  * @param request - Search parameters including accountId and optional date range
223
246
  * @returns Array of orders matching the search criteria
224
247
  */
225
- search(request: SearchOrdersRequest): Promise<SearchOrdersResponse>;
248
+ search(request: SearchOrdersRequestInterface): Promise<SearchOrdersResponseInterface>;
226
249
  /**
227
250
  * Get all currently open (working) orders for an account.
228
251
  * @param request - Request containing the accountId
229
252
  * @returns Array of open orders
230
253
  */
231
- searchOpen(request: SearchOpenOrdersRequest): Promise<SearchOpenOrdersResponse>;
254
+ searchOpen(request: SearchOpenOrdersRequestInterface): Promise<SearchOpenOrdersResponseInterface>;
232
255
  /**
233
256
  * Place a new order.
234
257
  * @param request - Order details including type, side, size, and prices
@@ -256,54 +279,60 @@ declare class OrderApi {
256
279
  * });
257
280
  * ```
258
281
  */
259
- place(request: PlaceOrderRequest): Promise<PlaceOrderResponse>;
282
+ place(request: PlaceOrderRequestInterface): Promise<PlaceOrderResponseInterface>;
260
283
  /**
261
284
  * Cancel an existing order.
262
285
  * @param request - Request containing accountId and orderId to cancel
263
286
  * @returns Response indicating success or failure
264
287
  */
265
- cancel(request: CancelOrderRequest): Promise<CancelOrderResponse>;
288
+ cancel(request: CancelOrderRequestInterface): Promise<CancelOrderResponseInterface>;
266
289
  /**
267
290
  * Modify an existing order's size or price.
268
291
  * @param request - Request containing orderId and fields to modify
269
292
  * @returns Response indicating success or failure
270
293
  */
271
- modify(request: ModifyOrderRequest): Promise<ModifyOrderResponse>;
294
+ modify(request: ModifyOrderRequestInterface): Promise<ModifyOrderResponseInterface>;
295
+ }
296
+
297
+ interface SearchOpenPositionsRequestInterface {
298
+ accountId: number;
272
299
  }
273
300
 
274
- interface Position {
301
+ interface PositionInterface {
275
302
  id: number;
276
303
  accountId: number;
277
304
  contractId: string;
278
305
  creationTimestamp: string;
279
- type: PositionType;
306
+ type: PositionTypeEnum;
280
307
  size: number;
281
308
  averagePrice: number;
282
309
  }
283
- interface SearchOpenPositionsRequest {
284
- accountId: number;
285
- }
286
- interface SearchOpenPositionsResponse {
287
- positions: Position[];
310
+
311
+ interface SearchOpenPositionsResponseInterface {
312
+ positions: PositionInterface[];
288
313
  success: boolean;
289
314
  errorCode: number;
290
315
  errorMessage: string | null;
291
316
  }
292
- interface ClosePositionRequest {
317
+
318
+ interface ClosePositionRequestInterface {
293
319
  accountId: number;
294
320
  contractId: string;
295
321
  }
296
- interface ClosePositionResponse {
322
+
323
+ interface ClosePositionResponseInterface {
297
324
  success: boolean;
298
325
  errorCode: number;
299
326
  errorMessage: string | null;
300
327
  }
301
- interface PartialClosePositionRequest {
328
+
329
+ interface PartialClosePositionRequestInterface {
302
330
  accountId: number;
303
331
  contractId: string;
304
332
  size: number;
305
333
  }
306
- interface PartialClosePositionResponse {
334
+
335
+ interface PartialClosePositionResponseInterface {
307
336
  success: boolean;
308
337
  errorCode: number;
309
338
  errorMessage: string | null;
@@ -312,12 +341,18 @@ interface PartialClosePositionResponse {
312
341
  declare class PositionApi {
313
342
  private readonly http;
314
343
  constructor(http: HttpClient);
315
- searchOpen(request: SearchOpenPositionsRequest): Promise<SearchOpenPositionsResponse>;
316
- close(request: ClosePositionRequest): Promise<ClosePositionResponse>;
317
- partialClose(request: PartialClosePositionRequest): Promise<PartialClosePositionResponse>;
344
+ searchOpen(request: SearchOpenPositionsRequestInterface): Promise<SearchOpenPositionsResponseInterface>;
345
+ close(request: ClosePositionRequestInterface): Promise<ClosePositionResponseInterface>;
346
+ partialClose(request: PartialClosePositionRequestInterface): Promise<PartialClosePositionResponseInterface>;
347
+ }
348
+
349
+ interface SearchTradesRequestInterface {
350
+ accountId: number;
351
+ startTimestamp: string;
352
+ endTimestamp: string;
318
353
  }
319
354
 
320
- interface Trade {
355
+ interface TradeInterface {
321
356
  id: number;
322
357
  accountId: number;
323
358
  contractId: string;
@@ -325,18 +360,14 @@ interface Trade {
325
360
  price: number;
326
361
  profitAndLoss: number | null;
327
362
  fees: number;
328
- side: OrderSide;
363
+ side: OrderSideEnum;
329
364
  size: number;
330
365
  voided: boolean;
331
366
  orderId: number;
332
367
  }
333
- interface SearchTradesRequest {
334
- accountId: number;
335
- startTimestamp: string;
336
- endTimestamp: string;
337
- }
338
- interface SearchTradesResponse {
339
- trades: Trade[];
368
+
369
+ interface SearchTradesResponseInterface {
370
+ trades: TradeInterface[];
340
371
  success: boolean;
341
372
  errorCode: number;
342
373
  errorMessage: string | null;
@@ -345,10 +376,15 @@ interface SearchTradesResponse {
345
376
  declare class TradeApi {
346
377
  private readonly http;
347
378
  constructor(http: HttpClient);
348
- search(request: SearchTradesRequest): Promise<SearchTradesResponse>;
379
+ search(request: SearchTradesRequestInterface): Promise<SearchTradesResponseInterface>;
349
380
  }
350
381
 
351
- interface Contract {
382
+ interface SearchContractsRequestInterface {
383
+ searchText: string;
384
+ live: boolean;
385
+ }
386
+
387
+ interface ContractInterface {
352
388
  id: string;
353
389
  name: string;
354
390
  description: string;
@@ -356,54 +392,179 @@ interface Contract {
356
392
  tickValue: number;
357
393
  activeContract: boolean;
358
394
  }
359
- interface SearchContractsRequest {
360
- searchText: string;
361
- live: boolean;
362
- }
363
- interface SearchContractsResponse {
364
- contracts: Contract[];
395
+
396
+ interface SearchContractsResponseInterface {
397
+ contracts: ContractInterface[];
365
398
  success: boolean;
366
399
  errorCode: number;
367
400
  errorMessage: string | null;
368
401
  }
369
- interface SearchContractByIdRequest {
370
- contractId: string;
371
- live: boolean;
372
- }
373
- interface SearchContractByIdResponse {
374
- contract: Contract | null;
402
+
403
+ interface SearchContractByIdResponseInterface {
404
+ contract: ContractInterface | null;
375
405
  success: boolean;
376
406
  errorCode: number;
377
407
  errorMessage: string | null;
378
408
  }
379
409
 
410
+ interface SearchContractByIdRequestInterface {
411
+ contractId: string;
412
+ live: boolean;
413
+ }
414
+
380
415
  declare class ContractApi {
381
416
  private readonly http;
382
417
  constructor(http: HttpClient);
383
- search(request: SearchContractsRequest): Promise<SearchContractsResponse>;
384
- searchById(request: SearchContractByIdRequest): Promise<SearchContractByIdResponse | null>;
418
+ search(request: SearchContractsRequestInterface): Promise<SearchContractsResponseInterface>;
419
+ searchById(request: SearchContractByIdRequestInterface): Promise<SearchContractByIdResponseInterface | null>;
385
420
  }
386
421
 
387
- interface Bar {
388
- t: string;
389
- o: number;
390
- h: number;
391
- l: number;
392
- c: number;
393
- v: number;
422
+ declare enum CmeContractExchangeEnum {
423
+ CME = 0,
424
+ CBOT = 1,
425
+ COMEX = 2,
426
+ NYMEX = 3
427
+ }
428
+
429
+ declare enum CmeContractSectorEnum {
430
+ EQUITY = "Equity",
431
+ FOREIGN_EXCHANGE = "Foreign Exchange",
432
+ LIVE_STOCK = "Live Stock",
433
+ CROPS = "Crops",
434
+ GAS_AND_OIL = "Gas & Oil",
435
+ NOTES_AND_BONDS = "Notes & Bonds",
436
+ METALS = "Metals",
437
+ CRYPTO = "Crypto"
438
+ }
439
+
440
+ declare enum CmeContractSymbolEnum {
441
+ E_MINI_SP_500 = "ES",
442
+ MICRO_E_MINI_SP_500 = "MES",
443
+ E_MINI_NASDAQ = "NQ",
444
+ MICRO_E_MINI_NASDAQ = "MNQ",
445
+ E_MINI_RUSSELL = "RTY",
446
+ MICRO_E_MINI_RUSSELL = "M2K",
447
+ NIKKEI = "NKD",
448
+ MINI_DOW = "YM",
449
+ MICRO_MINI_DOW = "MYM",
450
+ AUD_USD = "6A",
451
+ MICRO_AUD_USD = "M6A",
452
+ GBP_USD = "6B",
453
+ MICRO_GBP_USD = "M6B",
454
+ CAD_USD = "6C",
455
+ EUR_USD = "6E",
456
+ MICRO_EUR_USD = "M6E",
457
+ E_MINI_EUR_USD = "E7",
458
+ JPY_USD = "6J",
459
+ CHF_USD = "6S",
460
+ MXN_USD = "6M",
461
+ NZD_USD = "6N",
462
+ LEAN_HOGS = "HE",
463
+ LIVE_CATTLE = "LE",
464
+ CORN = "ZC",
465
+ WHEAT = "ZW",
466
+ SOYBEANS = "ZS",
467
+ SOYBEAN_MEAL = "ZM",
468
+ SOYBEAN_OIL = "ZL",
469
+ CRUDE_OIL = "CL",
470
+ MICRO_CRUDE_OIL = "MCL",
471
+ NATURAL_GAS = "NG",
472
+ MICRO_NATURAL_GAS = "MNG",
473
+ E_MINI_CRUDE_OIL = "QM",
474
+ E_MINI_NATURAL_GAS = "QG",
475
+ RBOB_GASOLINE = "RB",
476
+ HEATING_OIL = "HO",
477
+ TWO_YEAR_NOTE = "ZT",
478
+ FIVE_YEAR_NOTE = "ZF",
479
+ TEN_YEAR_NOTE = "ZN",
480
+ TEN_YEAR_ULTRA_NOTE = "TN",
481
+ THIRTY_YEAR_BOND = "ZB",
482
+ ULTRA_BOND = "UB",
483
+ GOLD = "GC",
484
+ MICRO_GOLD = "MGC",
485
+ SILVER = "SI",
486
+ MICRO_SILVER = "SIL",
487
+ COPPER = "HG",
488
+ MICRO_COPPER = "MHG",
489
+ PLATINUM = "PL",
490
+ MICRO_BITCOIN = "MBT",
491
+ MICRO_ETHER = "MET"
492
+ }
493
+
494
+ interface CmeContractInterface {
495
+ symbol: CmeContractSymbolEnum;
496
+ name: string;
497
+ sector: CmeContractSectorEnum;
498
+ exchange: CmeContractExchangeEnum;
499
+ tickSize: number;
500
+ tickValue: number;
501
+ roundTripFees: number;
502
+ }
503
+
504
+ interface CmeContractSectorGroupInterface {
505
+ sector: CmeContractSectorEnum;
506
+ contracts: CmeContractInterface[];
507
+ }
508
+
509
+ interface CmeTradeSectorGroupInterface {
510
+ sector: CmeContractSectorEnum;
511
+ trades: TradeInterface[];
512
+ }
513
+
514
+ declare class CmeContractStore {
515
+ static getContracts(): CmeContractInterface[];
516
+ static getContractsBySector(): CmeContractSectorGroupInterface[];
517
+ static getContractBySymbol(symbol: CmeContractSymbolEnum): CmeContractInterface | undefined;
518
+ static getSectors(): CmeContractSectorEnum[];
519
+ static matchTradeNameToContract(trade: TradeInterface): CmeContractInterface | undefined;
520
+ static groupTradesBySector(trades?: TradeInterface[]): CmeTradeSectorGroupInterface[];
521
+ static matchContractNameToGlobexCode(contractName: string): CmeContractInterface | undefined;
522
+ }
523
+
524
+ declare const CME_CONTRACTS: CmeContractInterface[];
525
+
526
+ /**
527
+ * Time unit for historical bar data.
528
+ * @category Enums
529
+ */
530
+ declare enum BarUnitEnum {
531
+ /** Second bars */
532
+ Second = 1,
533
+ /** Minute bars */
534
+ Minute = 2,
535
+ /** Hourly bars */
536
+ Hour = 3,
537
+ /** Daily bars */
538
+ Day = 4,
539
+ /** Weekly bars */
540
+ Week = 5,
541
+ /** Monthly bars */
542
+ Month = 6,
543
+ BarUnit = 7
394
544
  }
395
- interface RetrieveBarsRequest {
545
+
546
+ interface RetrieveBarsRequestInterface {
396
547
  contractId: string;
397
548
  live: boolean;
398
549
  startTime: string;
399
550
  endTime: string;
400
- unit: BarUnit;
551
+ unit: BarUnitEnum;
401
552
  unitNumber: number;
402
553
  limit: number;
403
554
  includePartialBar: boolean;
404
555
  }
405
- interface RetrieveBarsResponse {
406
- bars: Bar[];
556
+
557
+ interface BarInterface {
558
+ t: string;
559
+ o: number;
560
+ h: number;
561
+ l: number;
562
+ c: number;
563
+ v: number;
564
+ }
565
+
566
+ interface RetrieveBarsResponseInterface {
567
+ bars: BarInterface[];
407
568
  success: boolean;
408
569
  errorCode: number;
409
570
  errorMessage: string | null;
@@ -412,38 +573,23 @@ interface RetrieveBarsResponse {
412
573
  declare class HistoryApi {
413
574
  private readonly http;
414
575
  constructor(http: HttpClient);
415
- retrieveBars(request: RetrieveBarsRequest): Promise<RetrieveBarsResponse>;
576
+ retrieveBars(request: RetrieveBarsRequestInterface): Promise<RetrieveBarsResponseInterface>;
416
577
  }
417
578
 
418
- interface AuthConfig {
579
+ interface AuthConfigInterface {
419
580
  username: string;
420
581
  apiKey: string;
421
582
  baseUrl?: string;
422
583
  autoRefresh?: boolean;
423
584
  tokenValidityHours?: number;
424
585
  }
425
- interface LoginRequest {
426
- userName: string;
427
- apiKey: string;
428
- }
429
- interface LoginResponse {
430
- token: string;
431
- success: boolean;
432
- errorCode: number;
433
- errorMessage: string | null;
434
- }
435
- interface ValidateResponse {
436
- success: boolean;
437
- errorCode: number;
438
- errorMessage: string | null;
439
- }
440
586
 
441
587
  declare class AuthService {
442
588
  private sessionToken;
443
589
  private tokenExpiration;
444
590
  private refreshTimer?;
445
591
  private readonly config;
446
- constructor(config: AuthConfig);
592
+ constructor(config: AuthConfigInterface);
447
593
  login(): Promise<void>;
448
594
  validate(): Promise<boolean>;
449
595
  getSessionToken(): Promise<string>;
@@ -454,19 +600,38 @@ declare class AuthService {
454
600
  destroy(): void;
455
601
  }
456
602
 
457
- interface ConnectionManagerConfig {
603
+ interface AuthLoginRequestInterface {
604
+ userName: string;
605
+ apiKey: string;
606
+ }
607
+
608
+ interface AuthLoginResponseInterface {
609
+ token: string;
610
+ success: boolean;
611
+ errorCode: number;
612
+ errorMessage: string | null;
613
+ }
614
+
615
+ interface AuthValidateResponseInterface {
616
+ success: boolean;
617
+ errorCode: number;
618
+ errorMessage: string | null;
619
+ }
620
+
621
+ interface ConnectionManagerConfigInterface {
458
622
  marketHubUrl: string;
459
623
  userHubUrl: string;
460
624
  auth: AuthService;
461
625
  reconnectDelays?: number[];
462
626
  }
627
+
463
628
  declare class ConnectionManager {
464
629
  private marketConn;
465
630
  private userConn;
466
631
  private readonly config;
467
632
  private marketConnectionCallbacks;
468
633
  private userConnectionCallbacks;
469
- constructor(config: ConnectionManagerConfig);
634
+ constructor(config: ConnectionManagerConfigInterface);
470
635
  connect(): Promise<void>;
471
636
  disconnect(): Promise<void>;
472
637
  get isConnected(): boolean;
@@ -489,7 +654,12 @@ declare class TypedEventEmitter<T extends EventMap = EventMap> {
489
654
  removeAllListeners<K extends keyof T>(event?: K): this;
490
655
  }
491
656
 
492
- interface MarketQuote {
657
+ interface RealtimeMarketEventInterface<T> {
658
+ contractId: string;
659
+ data: T[];
660
+ }
661
+
662
+ interface RealtimeMarketQuoteEventInterface {
493
663
  symbol: string;
494
664
  lastPrice: number;
495
665
  bestBid: number;
@@ -500,32 +670,31 @@ interface MarketQuote {
500
670
  lastUpdated: string;
501
671
  timestamp: string;
502
672
  }
503
- interface MarketTrade {
673
+
674
+ interface RealtimeMarketTradeEventInterface {
504
675
  symbolId: string;
505
676
  price: number;
506
677
  timestamp: string;
507
678
  type: 0 | 1;
508
679
  volume: number;
509
680
  }
510
- interface MarketDepth {
681
+
682
+ interface RealtimeMarketDepthEventInterface {
511
683
  price: number;
512
684
  volume: number;
513
685
  currentVolume: number;
514
686
  type: number;
515
687
  timestamp: string;
516
688
  }
517
- interface MarketEvent<T> {
518
- contractId: string;
519
- data: T[];
520
- }
521
- interface MarketHubEvents {
689
+
690
+ interface RealtimeMarketEventHubInterface {
522
691
  [key: string]: unknown;
523
- quote: MarketEvent<MarketQuote>;
524
- trade: MarketEvent<MarketTrade>;
525
- depth: MarketEvent<MarketDepth>;
692
+ quote: RealtimeMarketEventInterface<RealtimeMarketQuoteEventInterface>;
693
+ trade: RealtimeMarketEventInterface<RealtimeMarketTradeEventInterface>;
694
+ depth: RealtimeMarketEventInterface<RealtimeMarketDepthEventInterface>;
526
695
  }
527
696
 
528
- declare class MarketHub extends TypedEventEmitter<MarketHubEvents> {
697
+ declare class RealtimeMarketEventHub extends TypedEventEmitter<RealtimeMarketEventHubInterface> {
529
698
  private readonly connectionManager;
530
699
  private subscribedQuotes;
531
700
  private subscribedTrades;
@@ -542,29 +711,31 @@ declare class MarketHub extends TypedEventEmitter<MarketHubEvents> {
542
711
  unsubscribeDepth(contractId: string): Promise<void>;
543
712
  }
544
713
 
545
- interface OrderUpdate {
714
+ interface RealtimeUserOrderUpdateInterface {
546
715
  id: number;
547
716
  accountId: number;
548
717
  contractId: string;
549
718
  creationTimestamp: string;
550
719
  updateTimestamp: string | null;
551
- status: OrderStatus;
552
- type: OrderType;
553
- side: OrderSide;
720
+ status: OrderStatusEnum;
721
+ type: OrderTypeEnum;
722
+ side: OrderSideEnum;
554
723
  size: number;
555
724
  limitPrice: number | null;
556
725
  stopPrice: number | null;
557
726
  }
558
- interface PositionUpdate {
727
+
728
+ interface RealtimeUserPositionUpdateInterface {
559
729
  id: number;
560
730
  accountId: number;
561
731
  contractId: string;
562
732
  creationTimestamp: string;
563
- type: PositionType;
733
+ type: PositionTypeEnum;
564
734
  size: number;
565
735
  averagePrice: number;
566
736
  }
567
- interface TradeUpdate {
737
+
738
+ interface RealtimeUserTradeUpdateInterface {
568
739
  id: number;
569
740
  accountId: number;
570
741
  contractId: string;
@@ -572,26 +743,28 @@ interface TradeUpdate {
572
743
  price: number;
573
744
  profitAndLoss: number | null;
574
745
  fees: number;
575
- side: OrderSide;
746
+ side: OrderSideEnum;
576
747
  size: number;
577
748
  voided: boolean;
578
749
  orderId: number;
579
750
  }
580
- interface AccountUpdate {
751
+
752
+ interface RealtimeUserAccountUpdateInterface {
581
753
  id: number;
582
754
  name: string;
583
755
  canTrade: boolean;
584
756
  balance: number;
585
757
  }
586
- interface UserHubEvents {
758
+
759
+ interface RealtimeUserEventHubInterface {
587
760
  [key: string]: unknown;
588
- order: OrderUpdate;
589
- position: PositionUpdate;
590
- trade: TradeUpdate;
591
- account: AccountUpdate;
761
+ order: RealtimeUserOrderUpdateInterface;
762
+ position: RealtimeUserPositionUpdateInterface;
763
+ trade: RealtimeUserTradeUpdateInterface;
764
+ account: RealtimeUserAccountUpdateInterface;
592
765
  }
593
766
 
594
- declare class UserHub extends TypedEventEmitter<UserHubEvents> {
767
+ declare class RealtimeUserEventHub extends TypedEventEmitter<RealtimeUserEventHubInterface> {
595
768
  private readonly connectionManager;
596
769
  private subscribedOrders;
597
770
  private subscribedPositions;
@@ -608,30 +781,6 @@ declare class UserHub extends TypedEventEmitter<UserHubEvents> {
608
781
  unsubscribeTrades(accountId: number): Promise<void>;
609
782
  }
610
783
 
611
- interface ApiResponse<T = unknown> {
612
- success: boolean;
613
- errorCode: number;
614
- errorMessage: string | null;
615
- [key: string]: T | boolean | number | string | null | undefined;
616
- }
617
- interface TopstepXClientConfig {
618
- username: string;
619
- apiKey: string;
620
- baseUrl?: string;
621
- marketHubUrl?: string;
622
- userHubUrl?: string;
623
- autoRefresh?: boolean;
624
- tokenValidityHours?: number;
625
- }
626
- interface TopstepXClientEvents {
627
- [key: string]: unknown;
628
- connected: void;
629
- disconnected: void;
630
- error: Error;
631
- reconnecting: void;
632
- reconnected: void;
633
- }
634
-
635
784
  /**
636
785
  * Main client for interacting with the TopstepX trading API.
637
786
  *
@@ -690,9 +839,9 @@ declare class TopstepXClient extends TypedEventEmitter<TopstepXClientEvents> {
690
839
  /** Historical bars/candles API */
691
840
  readonly history: HistoryApi;
692
841
  /** Real-time market data hub (quotes, trades, depth) */
693
- readonly marketHub: MarketHub;
842
+ readonly marketHub: RealtimeMarketEventHub;
694
843
  /** Real-time account data hub (orders, positions, trades) */
695
- readonly userHub: UserHub;
844
+ readonly userHub: RealtimeUserEventHub;
696
845
  constructor(config: TopstepXClientConfig);
697
846
  /**
698
847
  * Connect to the TopstepX API.
@@ -734,4 +883,4 @@ declare class ConnectionError extends TopstepXError {
734
883
  constructor(message: string);
735
884
  }
736
885
 
737
- export { type Account, AccountApi, type AccountUpdate, ApiError, type ApiResponse, type AuthConfig, AuthService, AuthenticationError, type Bar, BarUnit, type CancelOrderRequest, type CancelOrderResponse, type ClosePositionRequest, type ClosePositionResponse, ConnectionError, ConnectionManager, type ConnectionManagerConfig, type Contract, ContractApi, HistoryApi, HttpClient, type HttpClientConfig, type LoginRequest, type LoginResponse, type MarketDepth, type MarketEvent, MarketHub, type MarketHubEvents, type MarketQuote, type MarketTrade, type ModifyOrderRequest, type ModifyOrderResponse, type Order, OrderApi, OrderSide, OrderStatus, OrderType, type OrderUpdate, type PartialClosePositionRequest, type PartialClosePositionResponse, type PlaceOrderRequest, type PlaceOrderResponse, type Position, PositionApi, PositionType, type PositionUpdate, type RetrieveBarsRequest, type RetrieveBarsResponse, type SearchAccountsRequest, type SearchAccountsResponse, type SearchContractByIdRequest, type SearchContractByIdResponse, type SearchContractsRequest, type SearchContractsResponse, type SearchOpenOrdersRequest, type SearchOpenPositionsRequest, type SearchOpenPositionsResponse, type SearchOrdersRequest, type SearchOrdersResponse, type SearchTradesRequest, type SearchTradesResponse, TopstepXClient, type TopstepXClientConfig, type TopstepXClientEvents, TopstepXError, type Trade, TradeApi, TradeType, type TradeUpdate, TypedEventEmitter, UserHub, type UserHubEvents, type ValidateResponse };
886
+ export { AccountApi, type AccountInterface, ApiError, type ApiResponse, type AuthConfigInterface, type AuthLoginRequestInterface, type AuthLoginResponseInterface, AuthService, type AuthValidateResponseInterface, AuthenticationError, type BarInterface, CME_CONTRACTS, type CancelOrderRequestInterface, type CancelOrderResponseInterface, type ClosePositionRequestInterface, type ClosePositionResponseInterface, CmeContractExchangeEnum, type CmeContractInterface, CmeContractSectorEnum, type CmeContractSectorGroupInterface, CmeContractStore, CmeContractSymbolEnum, type CmeTradeSectorGroupInterface, ConnectionError, ConnectionManager, type ConnectionManagerConfigInterface, ContractApi, type ContractInterface, HistoryApi, HttpClient, type HttpClientConfigInterface, type ModifyOrderRequestInterface, type ModifyOrderResponseInterface, OrderApi, type OrderInterface, OrderStatusEnum, type PartialClosePositionRequestInterface, type PartialClosePositionResponseInterface, type PlaceOrderRequestInterface, type PlaceOrderResponseInterface, PositionApi, type PositionInterface, PositionTypeEnum, type RealtimeMarketDepthEventInterface, RealtimeMarketEventHub, type RealtimeMarketEventHubInterface, type RealtimeMarketEventInterface, type RealtimeMarketQuoteEventInterface, type RealtimeMarketTradeEventInterface, type RealtimeUserAccountUpdateInterface, RealtimeUserEventHub, type RealtimeUserEventHubInterface, type RealtimeUserOrderUpdateInterface, type RealtimeUserPositionUpdateInterface, type RealtimeUserTradeUpdateInterface, type RetrieveBarsRequestInterface, type RetrieveBarsResponseInterface, type SearchAccountsRequestInterface, type SearchAccountsResponseInterface, type SearchContractByIdRequestInterface, type SearchContractByIdResponseInterface, type SearchContractsRequestInterface, type SearchContractsResponseInterface, type SearchOpenOrdersRequestInterface, type SearchOpenPositionsRequestInterface, type SearchOpenPositionsResponseInterface, type SearchOrdersRequestInterface, type SearchOrdersResponseInterface, type SearchTradesRequestInterface, type SearchTradesResponseInterface, TopstepXClient, type TopstepXClientConfig, type TopstepXClientEvents, TopstepXError, TradeApi, type TradeInterface, TradeTypeEnum, TypedEventEmitter };