@stxapp/stx-typescript 0.6.0

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.
@@ -0,0 +1,3355 @@
1
+ import { KeyObject } from 'node:crypto';
2
+
3
+ /** The HTTP request an auth provider is asked to authenticate. */
4
+ interface AuthRequest {
5
+ /** Uppercase HTTP method, e.g. `POST`. */
6
+ method: string;
7
+ /** Path including any query string, no scheme or host: exactly what is sent. */
8
+ path: string;
9
+ }
10
+ interface AuthProvider {
11
+ /** A stable label for logs: `api_key`, `oauth`, `oauth_app`. */
12
+ readonly kind: string;
13
+ /** Headers for one HTTP request. Called fresh for every attempt. */
14
+ authHeaders(request: AuthRequest): Promise<Record<string, string>>;
15
+ /**
16
+ * Called after a 401. Return true if the provider recovered (for example
17
+ * refreshed an OAuth token) and the request should be sent once more.
18
+ */
19
+ onUnauthorized?(): Promise<boolean>;
20
+ /**
21
+ * Headers for the WebSocket handshake. Called on every (re)connect;
22
+ * `context.reconnect` is true after a drop, so a provider can mint a fresh
23
+ * token rather than reuse the one from the connection that just died.
24
+ */
25
+ websocketHeaders?(context?: WebSocketAuthContext): Promise<Record<string, string>>;
26
+ }
27
+ /** What the socket tells an auth provider about the handshake it is building. */
28
+ interface WebSocketAuthContext {
29
+ /** True when this handshake follows a dropped or refused connection. */
30
+ reconnect?: boolean;
31
+ }
32
+
33
+ declare const Region: {
34
+ readonly US: "us";
35
+ readonly ONTARIO: "ontario";
36
+ };
37
+ type Region = (typeof Region)[keyof typeof Region];
38
+ declare const Environment: {
39
+ readonly PRODUCTION: "production";
40
+ readonly DEMO: "demo";
41
+ };
42
+ type Environment = (typeof Environment)[keyof typeof Environment];
43
+
44
+ /** A published STX environment. */
45
+ interface STXEnvironment {
46
+ /** A short name, useful in logs and configuration: `"ontario-demo"`. */
47
+ readonly name: string;
48
+ /** The `region` that selects it. */
49
+ readonly region: Region;
50
+ /** The `env` that selects it. */
51
+ readonly env: Environment;
52
+ /** The API hostname. */
53
+ readonly host: string;
54
+ /** True where orders settle against live balances. */
55
+ readonly realMoney: boolean;
56
+ }
57
+ /**
58
+ * The environments published at https://docs.stxapp.io/environments/, named
59
+ * `<region>-<env>`. Pass one as `environment`, or select it with
60
+ * `region` + `env`.
61
+ *
62
+ * This is not the list of hosts the SDK can reach: anything else (a host
63
+ * that moved after this version shipped, a local server) is reachable
64
+ * through `host`. United States production is absent until that host serves
65
+ * the API.
66
+ *
67
+ * API keys do not carry across exchanges: an Ontario key will not
68
+ * authenticate against the United States exchange.
69
+ */
70
+ declare const Environments: {
71
+ /** United States demo. Shared by every integrator. No real money. */
72
+ readonly USDemo: {
73
+ readonly name: "us-demo";
74
+ readonly region: "us";
75
+ readonly env: "demo";
76
+ readonly host: "demo.stxapp.io";
77
+ readonly realMoney: false;
78
+ };
79
+ /** Ontario demo. Shared, no real money. */
80
+ readonly OntarioDemo: {
81
+ readonly name: "ontario-demo";
82
+ readonly region: "ontario";
83
+ readonly env: "demo";
84
+ readonly host: "demo.stxapp.ca";
85
+ readonly realMoney: false;
86
+ };
87
+ /** **Ontario production. Real money.** Exercise your integration against `OntarioDemo` first. */
88
+ readonly OntarioProduction: {
89
+ readonly name: "ontario-production";
90
+ readonly region: "ontario";
91
+ readonly env: "production";
92
+ readonly host: "stxapp.ca";
93
+ readonly realMoney: true;
94
+ };
95
+ };
96
+ /** (region, env) -> hostname, for the environments above. */
97
+ declare const HOSTS: Readonly<Record<string, string>>;
98
+ /** An environment by its name (`"ontario-demo"`), or `STXConfigException`. */
99
+ declare function environmentNamed(name: string): STXEnvironment;
100
+ /** Hostname for a (region, env) pair, or `STXConfigException`. */
101
+ declare function resolveHost(region: string | null | undefined, env: string | null | undefined): string;
102
+ /**
103
+ * The REST base URL (scheme and authority, no path).
104
+ *
105
+ * `host` may be a bare hostname (`demo.stxapp.io`, `localhost:4000`), which
106
+ * gets `https://`, or a URL (`http://localhost:4000`) whose scheme is kept.
107
+ * Any path on the URL is ignored: the API lives at `/api/v1` on every host.
108
+ */
109
+ declare function baseUrlFor(region: string | null | undefined, env: string | null | undefined, host: string | null | undefined): string;
110
+ /** The WebSocket URL for a REST base URL: https maps to wss, http to ws. */
111
+ declare function socketUrlFor(baseUrl: string): string;
112
+
113
+ /** Why the exchange's geo-fencing refused a request. */
114
+ interface GeoRejection {
115
+ reason: "ip_not_allowed" | "packet_invalid" | "packet_other_user" | "packet_ip_mismatch" | "location_not_allowed";
116
+ /** The address the exchange saw, when its message names one. */
117
+ ipAddress?: string;
118
+ }
119
+ /**
120
+ * A geolocation packet, or a function returning one (sync or async). Return
121
+ * `undefined` to send none for that request.
122
+ */
123
+ type GeoLocationProvider = string | (() => string | undefined | null | Promise<string | undefined | null>);
124
+ /**
125
+ * Classify a 422 message from an order write. Returns undefined for a refusal
126
+ * that is not geo-fencing (funds, market closed, price step).
127
+ */
128
+ declare function geoRejection(message: string): GeoRejection | undefined;
129
+ /** The outcome of `STX.geoCheck()`. */
130
+ interface GeoCheckResult {
131
+ /** True when the exchange would accept an order write from here now. */
132
+ allowed: boolean;
133
+ /** Set when `allowed` is false. */
134
+ reason?: GeoRejection["reason"];
135
+ /** The exchange's message when `allowed` is false. */
136
+ message?: string;
137
+ /** The address the exchange saw, when its message names one. */
138
+ ipAddress?: string;
139
+ /** Whether a geolocation packet was sent with the check. */
140
+ sentPacket: boolean;
141
+ }
142
+
143
+ /**
144
+ * One account's balance and fee summary, in the dollar wire format.
145
+ */
146
+ interface Balance {
147
+ /**
148
+ * The account's cash balance. Unaffected by placing an order - not all of it
149
+ * may be available. In dollars. Money as a decimal string, as sent by the
150
+ * API.
151
+ */
152
+ account_balance?: string | null;
153
+ /**
154
+ * The account this balance is for.
155
+ */
156
+ account_id?: string | null;
157
+ /**
158
+ * The balance available to withdraw or place further orders with. Rounded
159
+ * **down** to the cent, so it never overstates what is spendable. In dollars.
160
+ * Money as a decimal string, as sent by the API.
161
+ */
162
+ available_balance?: string | null;
163
+ /**
164
+ * The fee percentage on the `fixed_percent` schedule; `null` for any other
165
+ * schedule. A number, not a money string.
166
+ */
167
+ base_fee_percent?: number | null;
168
+ /**
169
+ * Total liability from buy orders, including the potential trade-fee reserve.
170
+ * Rounded **up** to the cent. In dollars. Money as a decimal string, as sent
171
+ * by the API.
172
+ */
173
+ buy_order_liability?: string | null;
174
+ /**
175
+ * The account's escrow balance. In dollars. Money as a decimal string, as
176
+ * sent by the API.
177
+ */
178
+ escrow?: string | null;
179
+ /**
180
+ * The account's fee schedule. One of: `fixed_percent`, `revenue_share`,
181
+ * `loyalty_tier`, `fixed_percent_market_group`, `fixed_percent_event`,
182
+ * `on_trade`, `loyalty_tier_on_trade`.
183
+ */
184
+ fee_schedule?: string | null;
185
+ /**
186
+ * The account's loyalty tier. Every account has one; new accounts start at
187
+ * `rookie`. One of: `rookie`, `veteran`, `all_star`, `mvp`, `hall_of_fame`.
188
+ */
189
+ loyalty_tier?: string | null;
190
+ /**
191
+ * Per-trade maker fee factor, present only on the `on_trade` and
192
+ * `loyalty_tier_on_trade` schedules; `null` otherwise. A number, not a money
193
+ * string.
194
+ */
195
+ maker_factor?: number | null;
196
+ /**
197
+ * Loyalty points the account has accumulated. A whole number, not a money
198
+ * string.
199
+ */
200
+ points?: number | null;
201
+ /**
202
+ * Total liability from position premiums. Routinely negative. Rounded **up**
203
+ * to the cent in both signs. In dollars. Money as a decimal string, as sent
204
+ * by the API.
205
+ */
206
+ position_premium_liability?: string | null;
207
+ /**
208
+ * Total liability from sell orders, including the potential trade-fee
209
+ * reserve. Rounded **up** to the cent. In dollars. Money as a decimal string,
210
+ * as sent by the API.
211
+ */
212
+ sell_order_liability?: string | null;
213
+ /**
214
+ * Per-trade taker fee factor, present only on the `on_trade` and
215
+ * `loyalty_tier_on_trade` schedules; `null` otherwise. A number, not a money
216
+ * string.
217
+ */
218
+ taker_factor?: number | null;
219
+ /**
220
+ * Lifetime total balance adjustments. In dollars. Money as a decimal string,
221
+ * as sent by the API.
222
+ */
223
+ total_adjustments?: string | null;
224
+ /**
225
+ * Lifetime total deposits. In dollars. Money as a decimal string, as sent by
226
+ * the API.
227
+ */
228
+ total_deposits?: string | null;
229
+ /**
230
+ * Total fees from all settlements and other fees. In dollars. Money as a
231
+ * decimal string, as sent by the API.
232
+ */
233
+ total_fees?: string | null;
234
+ /**
235
+ * Total gross profit and loss from all settlements. In dollars. Money as a
236
+ * decimal string, as sent by the API.
237
+ */
238
+ total_settlement_pnl?: string | null;
239
+ /**
240
+ * The number of trades the account has made across every market.
241
+ */
242
+ total_trade_count?: number | null;
243
+ /**
244
+ * The risk the account has committed across every market. In dollars. Money
245
+ * as a decimal string, as sent by the API.
246
+ */
247
+ total_traded?: string | null;
248
+ /**
249
+ * Lifetime total withdrawals. In dollars. Money as a decimal string, as sent
250
+ * by the API.
251
+ */
252
+ total_withdrawals?: string | null;
253
+ /**
254
+ * The user that owns the account.
255
+ */
256
+ user_id?: string | null;
257
+ /** Fields the server added after this SDK was generated. */
258
+ [key: string]: unknown;
259
+ }
260
+ /**
261
+ * One price level of resting size on the book.
262
+ */
263
+ interface BookLevel {
264
+ /**
265
+ * The price of this level. In dollars. Money as a decimal string, as sent by
266
+ * the API.
267
+ */
268
+ price?: string | null;
269
+ /**
270
+ * Contracts resting at this price. Quantity as a decimal string, as sent by
271
+ * the API.
272
+ */
273
+ quantity?: string | null;
274
+ /** Fields the server added after this SDK was generated. */
275
+ [key: string]: unknown;
276
+ }
277
+ /**
278
+ * The outcome of cancelling one order.
279
+ */
280
+ interface Cancellation {
281
+ /**
282
+ * The order this outcome relates to.
283
+ */
284
+ order_id?: string | null;
285
+ /**
286
+ * The order status after cancelling, or a reason it was not cancelled -
287
+ * "Order not found" for an unknown id.
288
+ */
289
+ status?: string | null;
290
+ /** Fields the server added after this SDK was generated. */
291
+ [key: string]: unknown;
292
+ }
293
+ /**
294
+ * The failure envelope returned by every non-2xx response.
295
+ */
296
+ interface Error$1 {
297
+ /**
298
+ * Human-readable failure reason, e.g. "Missing or invalid API key
299
+ * credentials" or "The order's price must be lower than 1.00".
300
+ */
301
+ error?: string | null;
302
+ /** Fields the server added after this SDK was generated. */
303
+ [key: string]: unknown;
304
+ }
305
+ /**
306
+ * A sporting event that markets hang off.
307
+ */
308
+ interface Event {
309
+ /**
310
+ * Is this event archived or not
311
+ */
312
+ archived?: boolean | null;
313
+ /**
314
+ * The competition for this event
315
+ */
316
+ competition?: string | null;
317
+ /**
318
+ * The event the market belongs to.
319
+ */
320
+ event_id?: string | null;
321
+ /**
322
+ * The event_type of this event - ad_hoc, baseball_game, basketball_game etc
323
+ */
324
+ event_type?: string | null;
325
+ /**
326
+ * The map of participants in the event.
327
+ */
328
+ participants?: Array<Record<string, unknown>> | null;
329
+ /**
330
+ * Is this event promoted or not
331
+ */
332
+ promoted?: boolean | null;
333
+ /**
334
+ * The short title for this event
335
+ */
336
+ short_title?: string | null;
337
+ /**
338
+ * The sport for this event
339
+ */
340
+ sport?: string | null;
341
+ /**
342
+ * Start time of this event UNIX microseconds.
343
+ */
344
+ start_time?: number | null;
345
+ /**
346
+ * Start time of this event
347
+ */
348
+ start_time_iso?: string | null;
349
+ /**
350
+ * The status of this event One of: `scheduled`, `in_progress`, `completed`,
351
+ * `cancelled`.
352
+ */
353
+ status?: string | null;
354
+ /**
355
+ * The STX symbol for this event
356
+ */
357
+ symbol?: string | null;
358
+ /**
359
+ * The title of this event
360
+ */
361
+ title?: string | null;
362
+ /** Fields the server added after this SDK was generated. */
363
+ [key: string]: unknown;
364
+ }
365
+ /**
366
+ * One fee charged against the account, or a refund of one.
367
+ */
368
+ interface FeeTransaction {
369
+ /**
370
+ * The account the record belongs to.
371
+ */
372
+ account_id?: string | null;
373
+ /**
374
+ * The monetary value the entry was calculated from. In dollars. Money as a
375
+ * decimal string, as sent by the API.
376
+ */
377
+ amount?: string | null;
378
+ /**
379
+ * The event the market belongs to.
380
+ */
381
+ event_id?: string | null;
382
+ /**
383
+ * The fee that generated this entry, when it came from one.
384
+ */
385
+ fee_id?: string | null;
386
+ /**
387
+ * Unique identifier for the record.
388
+ */
389
+ id?: string | null;
390
+ /**
391
+ * Creation time, as UNIX microseconds.
392
+ */
393
+ inserted_at?: number | null;
394
+ /**
395
+ * The market this record relates to.
396
+ */
397
+ market_id?: string | null;
398
+ /**
399
+ * The payment that generated this entry, when it came from one.
400
+ */
401
+ payment_id?: string | null;
402
+ /**
403
+ * Points added by this entry. Negative when points were spent.
404
+ */
405
+ points?: number | null;
406
+ /**
407
+ * The settlement that generated this entry, when it came from one.
408
+ */
409
+ settlement_id?: string | null;
410
+ /**
411
+ * When the entry was recorded.
412
+ */
413
+ time?: string | null;
414
+ /**
415
+ * What moved the money or the points - for example a deposit, a trade fee, a
416
+ * referral, or a manual adjustment. Each endpoint returns only its own subset
417
+ * of these. One of: `deposit`, `withdrawal`, `settlement`, `fee`,
418
+ * `fee_refund`, `casino`, `adjustment`, `loyalty`, `loyalty_points_rollup`,
419
+ * `loyalty_points_referral`.
420
+ */
421
+ type?: string | null;
422
+ /** Fields the server added after this SDK was generated. */
423
+ [key: string]: unknown;
424
+ }
425
+ /**
426
+ * One fill against one of your orders.
427
+ */
428
+ interface Fill {
429
+ /**
430
+ * The account the record belongs to.
431
+ */
432
+ account_id?: string | null;
433
+ /**
434
+ * The action of the trade relative to the user. One of: `buy`, `sell`.
435
+ */
436
+ action?: string | null;
437
+ /**
438
+ * Internal. Operator audit trail, not part of the supported contract - do not
439
+ * depend on it.
440
+ */
441
+ admin_log?: Record<string, unknown> | null;
442
+ /**
443
+ * True if an operator has amended this trade. When true, compare
444
+ * `original_price` and `original_filled` against the current values.
445
+ */
446
+ amended?: boolean | null;
447
+ /**
448
+ * The client order id of the order that produced this trade, when one was
449
+ * supplied.
450
+ */
451
+ client_order_id?: string | null;
452
+ /**
453
+ * The number of contracts closed on this trade. Quantity as a decimal string,
454
+ * as sent by the API.
455
+ */
456
+ closed_contracts?: string | null;
457
+ /**
458
+ * The fee the user paid when closing the trade. In dollars. Money as a
459
+ * decimal string, as sent by the API.
460
+ */
461
+ closed_fee?: string | null;
462
+ /**
463
+ * Realised profit or loss on the closed portion. Negative for a loss. In
464
+ * dollars. Money as a decimal string, as sent by the API.
465
+ */
466
+ closed_net_pnl?: string | null;
467
+ /**
468
+ * The profit or loss the user made by closing the trade. In dollars. Money as
469
+ * a decimal string, as sent by the API.
470
+ */
471
+ closed_pnl?: string | null;
472
+ /**
473
+ * The amount of contracts (in position) that the trade is closing. Quantity
474
+ * as a decimal string, as sent by the API.
475
+ */
476
+ closing?: string | null;
477
+ /**
478
+ * The player's device associated with this trade
479
+ */
480
+ device_id?: string | null;
481
+ /**
482
+ * Number of contracts settled when market expired. Quantity as a decimal
483
+ * string, as sent by the API.
484
+ */
485
+ expired_contracts?: string | null;
486
+ /**
487
+ * The fee paid by the user when the market expired. In dollars. Money as a
488
+ * decimal string, as sent by the API.
489
+ */
490
+ expired_fee?: string | null;
491
+ /**
492
+ * Realised profit or loss on the expired portion. In dollars. Money as a
493
+ * decimal string, as sent by the API.
494
+ */
495
+ expired_net_pnl?: string | null;
496
+ /**
497
+ * The profit or loss the user make on the trade when the market expired. In
498
+ * dollars. Money as a decimal string, as sent by the API.
499
+ */
500
+ expired_pnl?: string | null;
501
+ /**
502
+ * When the trade expires if the market has not settled, as UNIX microseconds.
503
+ */
504
+ expires_at?: number | null;
505
+ /**
506
+ * The number of contracts that were traded. Quantity as a decimal string, as
507
+ * sent by the API.
508
+ */
509
+ filled?: string | null;
510
+ /**
511
+ * The gross PNL as a result of the trade. In dollars. Money as a decimal
512
+ * string, as sent by the API.
513
+ */
514
+ gross_pnl?: string | null;
515
+ /**
516
+ * Creation time, as UNIX microseconds.
517
+ */
518
+ inserted_at?: number | null;
519
+ /**
520
+ * The IP address associated with this trade
521
+ */
522
+ ip_address?: string | null;
523
+ /**
524
+ * When an operator last amended this trade, as UNIX microseconds. Null unless
525
+ * `amended` is true.
526
+ */
527
+ last_modified_at?: number | null;
528
+ /**
529
+ * Internal. Operator audit field, not part of the supported contract - do not
530
+ * depend on it.
531
+ */
532
+ last_modified_by_admin_id?: string | null;
533
+ /**
534
+ * Whether the associated order was the `provider` or the `taker` of the
535
+ * liquidity. One of: `provider`, `taker`.
536
+ */
537
+ liquidity_action?: string | null;
538
+ /**
539
+ * The market this record relates to.
540
+ */
541
+ market_id?: string | null;
542
+ /**
543
+ * When the position opened, as UNIX microseconds.
544
+ */
545
+ opened_at?: number | null;
546
+ /**
547
+ * The ID of the order that caused the trade.
548
+ */
549
+ order_id?: string | null;
550
+ /**
551
+ * Contracts filled at execution, before any amendment. Quantity as a decimal
552
+ * string, as sent by the API.
553
+ */
554
+ original_filled?: string | null;
555
+ /**
556
+ * The amount of premium received for the original trade. In dollars. Money as
557
+ * a decimal string, as sent by the API.
558
+ */
559
+ original_premium?: string | null;
560
+ /**
561
+ * Fill price at execution. Unchanged by later amendments. In dollars. Money
562
+ * as a decimal string, as sent by the API.
563
+ */
564
+ original_price?: string | null;
565
+ /**
566
+ * The original risk introduced for the original trade excluding `closed`. In
567
+ * dollars. Money as a decimal string, as sent by the API.
568
+ */
569
+ original_risk?: string | null;
570
+ /**
571
+ * The original to win introduced for the original trade excluding `closed`.
572
+ * In dollars. Money as a decimal string, as sent by the API.
573
+ */
574
+ original_to_win?: string | null;
575
+ /**
576
+ * The amount of premium per contract. In dollars. Money as a decimal string,
577
+ * as sent by the API.
578
+ */
579
+ pc_premium?: string | null;
580
+ /**
581
+ * The amount of risk per contract. In dollars. Money as a decimal string, as
582
+ * sent by the API.
583
+ */
584
+ pc_risk?: string | null;
585
+ /**
586
+ * The amount to win per contract. In dollars. Money as a decimal string, as
587
+ * sent by the API.
588
+ */
589
+ pc_to_win?: string | null;
590
+ /**
591
+ * True if the order was placed before the event started.
592
+ */
593
+ placed_pre_start?: boolean | null;
594
+ /**
595
+ * The total number of loyalty points awarded as a result of making the trade.
596
+ */
597
+ points?: number | null;
598
+ /**
599
+ * Whether the trade was based on pre-start activity.
600
+ */
601
+ pre_start?: boolean | null;
602
+ /**
603
+ * The price that the trade was executed at. In dollars. Money as a decimal
604
+ * string, as sent by the API.
605
+ */
606
+ price?: string | null;
607
+ /**
608
+ * The number of unsettled contracts in the trade. Quantity as a decimal
609
+ * string, as sent by the API.
610
+ */
611
+ remaining?: string | null;
612
+ /**
613
+ * The potential fee from unsettled contracts. In dollars. Money as a decimal
614
+ * string, as sent by the API.
615
+ */
616
+ remaining_potential_fee?: string | null;
617
+ /**
618
+ * Premium as yet unsettled. In dollars. Money as a decimal string, as sent by
619
+ * the API.
620
+ */
621
+ remaining_premium?: string | null;
622
+ /**
623
+ * The total current risk for the trade. In dollars. Money as a decimal
624
+ * string, as sent by the API.
625
+ */
626
+ remaining_risk?: string | null;
627
+ /**
628
+ * The remaining amount that the trade can win. In dollars. Money as a decimal
629
+ * string, as sent by the API.
630
+ */
631
+ remaining_to_win?: string | null;
632
+ /**
633
+ * The timestamp when this trade's status was set to `settled`
634
+ */
635
+ settled_at?: string | null;
636
+ /**
637
+ * Contracts already settled. Below `traded_contracts` on a partial
638
+ * settlement. Quantity as a decimal string, as sent by the API.
639
+ */
640
+ settled_contracts?: string | null;
641
+ /**
642
+ * The number of settlements where this `AccountTrade` is an opening trade.
643
+ */
644
+ settlements_count?: number | null;
645
+ /**
646
+ * Fill state. `created` once the matching engine has written the fill, `open`
647
+ * while the position is live, `settled` once it no longer contributes to a
648
+ * position, and `cancelled` if an admin reversed it. One of: `created`,
649
+ * `open`, `settled`, `cancelled`.
650
+ */
651
+ status?: string | null;
652
+ /**
653
+ * The ISO-8601 Date time the trade was created.
654
+ */
655
+ time?: string | null;
656
+ /**
657
+ * Sum of on-trade fee plus fees paid from settlements linked with the trade.
658
+ * In dollars. Money as a decimal string, as sent by the API.
659
+ */
660
+ total_fee?: string | null;
661
+ /**
662
+ * Per-trade fee (on-trade fee schedule). Included in total_fee. In dollars.
663
+ * Money as a decimal string, as sent by the API.
664
+ */
665
+ trade_fee?: string | null;
666
+ /**
667
+ * Unique identifier for the trade.
668
+ */
669
+ trade_id?: string | null;
670
+ /**
671
+ * Number of contracts in this trade. Quantity as a decimal string, as sent by
672
+ * the API.
673
+ */
674
+ traded_contracts?: string | null;
675
+ /**
676
+ * Fee before rounding. Use the rounded fee for reconciliation. In dollars.
677
+ * Carries up to 9 decimal places - parse money with a variable-scale decimal
678
+ * type, not a fixed-width one. Money as a decimal string, as sent by the API.
679
+ */
680
+ unrounded_trade_fee?: string | null;
681
+ /**
682
+ * Time of the last change, as UNIX microseconds.
683
+ */
684
+ updated_at?: number | null;
685
+ /**
686
+ * Remaining contracts including unsettled exposure. Quantity as a decimal
687
+ * string, as sent by the API.
688
+ */
689
+ virtual_remaining?: string | null;
690
+ /** Fields the server added after this SDK was generated. */
691
+ [key: string]: unknown;
692
+ }
693
+ /**
694
+ * A market you can trade, with its book and event context.
695
+ */
696
+ interface Market {
697
+ /**
698
+ * Is the market archived or not.
699
+ */
700
+ archived?: boolean | null;
701
+ /**
702
+ * The available bids on the market, best first.
703
+ */
704
+ bids?: BookLevel[] | null;
705
+ /**
706
+ * The text to use in describing the competition, e.g. NBA.
707
+ */
708
+ competition?: string | null;
709
+ /**
710
+ * The description of the market.
711
+ */
712
+ description?: string | null;
713
+ /**
714
+ * The event the market belongs to.
715
+ */
716
+ event_id?: string | null;
717
+ /**
718
+ * The short title of the event associated with the market.
719
+ */
720
+ event_short_title?: string | null;
721
+ /**
722
+ * The UTC start date and time of the event.
723
+ */
724
+ event_start?: string | null;
725
+ /**
726
+ * The status of the event that the market is attached to.
727
+ */
728
+ event_status?: string | null;
729
+ /**
730
+ * The title of the event associated with the market.
731
+ */
732
+ event_title?: string | null;
733
+ /**
734
+ * The type of event associated with the market.
735
+ */
736
+ event_type?: string | null;
737
+ /**
738
+ * Is the market featured or not.
739
+ */
740
+ featured?: boolean | null;
741
+ /**
742
+ * Is the market featured on home page.
743
+ */
744
+ featured_home?: boolean | null;
745
+ /**
746
+ * The categorisations under which the market appears. A list, not an object.
747
+ */
748
+ filters?: MarketFilter[] | null;
749
+ /**
750
+ * The human readable group title for the market.
751
+ */
752
+ group_title?: string | null;
753
+ /**
754
+ * Identity of the set of mutually exclusive outcomes this market prices
755
+ * against - the 30 World Series contracts, the 4 AFC East contracts, one
756
+ * fixture's moneyline pair. Opaque: compare for equality, never parse. Stable
757
+ * for the life of the market, and present in every status, so it is the field
758
+ * to map market data on. Unlike `symbol`, it does not move when a fixture is
759
+ * rescheduled.
760
+ */
761
+ grouping_id?: string | null;
762
+ /**
763
+ * The grouping in words, e.g. `AL East Division`, `Spread - 1st Quarter`.
764
+ * Descriptive rather than stable - for a tournament it is the event title,
765
+ * which can be renamed. Display it; join on `grouping_id`.
766
+ */
767
+ grouping_name?: string | null;
768
+ /**
769
+ * The category in which the market appears: `Upcoming`, `Live` or `nil`.
770
+ */
771
+ home_category?: string | null;
772
+ /**
773
+ * The order delay (in seconds) when the event is in progress.
774
+ */
775
+ in_play_delay_sec?: number | null;
776
+ /**
777
+ * The keywords that are set for the market.
778
+ */
779
+ keywords?: string[] | null;
780
+ /**
781
+ * The time that the last probability update was received by the server. UNIX
782
+ * microseconds.
783
+ */
784
+ last_probability_at?: number | null;
785
+ /**
786
+ * The price of the last executed trade. In dollars. Money as a decimal
787
+ * string, as sent by the API.
788
+ */
789
+ last_traded_price?: string | null;
790
+ /**
791
+ * `true` when the probability was set by hand, `false` when it came from the
792
+ * odds provider. A flag, not a probability figure.
793
+ */
794
+ manual_probability?: boolean | null;
795
+ /**
796
+ * The market this record relates to.
797
+ */
798
+ market_id?: string | null;
799
+ /**
800
+ * The highest price an order in this market may take, and the settlement
801
+ * value of one winning contract. Orders must price strictly below it. In
802
+ * dollars. Money as a decimal string, as sent by the API.
803
+ */
804
+ max_price?: string | null;
805
+ /**
806
+ * The available offers on the market, best first.
807
+ */
808
+ offers?: BookLevel[] | null;
809
+ /**
810
+ * Current open interest in the market. In contracts. Quantity as a decimal
811
+ * string, as sent by the API.
812
+ */
813
+ open_interest?: string | null;
814
+ /**
815
+ * The map of participants in the market.
816
+ */
817
+ participants?: Array<Record<string, unknown>> | null;
818
+ /**
819
+ * The cost of each loyalty point for amount risked by the user.
820
+ */
821
+ points_cost?: number | null;
822
+ /**
823
+ * Text describing the position this market takes, e.g. a participant name. A
824
+ * label, not a numeric ordering.
825
+ */
826
+ position?: string | null;
827
+ /**
828
+ * Powered by - provider used to result this market.
829
+ */
830
+ powered_by?: Record<string, unknown> | null;
831
+ /**
832
+ * The market price that the market is trading at. In dollars. Money as a
833
+ * decimal string, as sent by the API.
834
+ */
835
+ price?: string | null;
836
+ /**
837
+ * The change in price over the last 24 hours, as a percentage. Not money - it
838
+ * stays a number and must not be divided by 100.
839
+ */
840
+ price_change24h?: number | null;
841
+ /**
842
+ * What is the probability for the market
843
+ */
844
+ probability?: number | null;
845
+ /**
846
+ * The question that the market is asking.
847
+ */
848
+ question?: string | null;
849
+ /**
850
+ * The last 15 trades on the market.
851
+ */
852
+ recent_trades?: RecentTrade[] | null;
853
+ /**
854
+ * The result of the market.
855
+ */
856
+ result?: string | null;
857
+ /**
858
+ * The rules for this market.
859
+ */
860
+ rules?: string | null;
861
+ /**
862
+ * When the market was resulted or voided. A raw microsecond integer, unlike
863
+ * the ISO-8601 `timestamp` and `event_start` beside it. UNIX microseconds.
864
+ */
865
+ settled_at?: number | null;
866
+ /**
867
+ * The human readable short title for the market.
868
+ */
869
+ short_title?: string | null;
870
+ /**
871
+ * The specifier for the rules to properly determine the market.
872
+ */
873
+ specifier?: string | null;
874
+ /**
875
+ * The text to use in describing the sport, e.g. Basketball.
876
+ */
877
+ sport?: string | null;
878
+ /**
879
+ * The stat line this market is derived from, or `null` for a market that is
880
+ * not a stat-line prop.
881
+ */
882
+ stat_detail?: StatDetail | null;
883
+ /**
884
+ * Market state. See [Market and order status](/concepts/market-status/) -
885
+ * note that a market with `status: open` may still report as suspended when
886
+ * trading is halted. One of: `scheduled`, `pre_open`, `open`, `suspended`,
887
+ * `closed`, `resulted`, `cancelled`, `voided`.
888
+ */
889
+ status?: string | null;
890
+ /**
891
+ * A unique symbol for this market.
892
+ */
893
+ symbol?: string | null;
894
+ /**
895
+ * Server time when this payload was generated, as an ISO-8601 string. The
896
+ * `timestamp_int` sibling carries the same instant as UNIX microseconds.
897
+ */
898
+ timestamp?: string | null;
899
+ /**
900
+ * The UNIX microseconds timestamp of when this market info was created.
901
+ */
902
+ timestamp_int?: number | null;
903
+ /**
904
+ * The human readable title for the market.
905
+ */
906
+ title?: string | null;
907
+ /**
908
+ * Contracts traded on this market across its lifetime. Quantity as a decimal
909
+ * string, as sent by the API.
910
+ */
911
+ total_volume?: string | null;
912
+ /**
913
+ * Trading flag - if the market is open for trading or not
914
+ */
915
+ trading?: boolean | null;
916
+ /**
917
+ * The categorisations used for organising trades, settlements and related
918
+ * items. A list, not an object.
919
+ */
920
+ trading_filters?: MarketFilter[] | null;
921
+ /**
922
+ * Trade volume this market has had in the last 24 hours. In contracts.
923
+ * Quantity as a decimal string, as sent by the API.
924
+ */
925
+ volume24h?: string | null;
926
+ /** Fields the server added after this SDK was generated. */
927
+ [key: string]: unknown;
928
+ }
929
+ /**
930
+ * One categorisation this market appears under.
931
+ */
932
+ interface MarketFilter {
933
+ /**
934
+ * Top-level category, e.g. a sport or a promotional section.
935
+ */
936
+ category?: string | null;
937
+ /**
938
+ * Grouping within the section.
939
+ */
940
+ grouping?: string | null;
941
+ /**
942
+ * Whether the categorisation was assigned by hand.
943
+ */
944
+ manual?: boolean | null;
945
+ /**
946
+ * Section heading this market groups under.
947
+ */
948
+ section?: string | null;
949
+ /**
950
+ * Category within `category`, e.g. a competition.
951
+ */
952
+ subcategory?: string | null;
953
+ /**
954
+ * Grouping within `grouping`.
955
+ */
956
+ subgrouping?: string | null;
957
+ /** Fields the server added after this SDK was generated. */
958
+ [key: string]: unknown;
959
+ }
960
+ /**
961
+ * Your exposure and realised result in one market.
962
+ */
963
+ interface MarketStat {
964
+ /**
965
+ * The account the record belongs to.
966
+ */
967
+ account_id?: string | null;
968
+ /**
969
+ * DateTime at which the record is marked as archived. It will be `nil` until
970
+ * the market is archived. UNIX microseconds.
971
+ */
972
+ archived_at?: number | null;
973
+ /**
974
+ * The amount of the `position` that is not reserved for pending orders. In
975
+ * contracts. Quantity as a decimal string, as sent by the API.
976
+ */
977
+ available_position?: string | null;
978
+ /**
979
+ * The average premium of all open contracts. In dollars. Money as a decimal
980
+ * string, as sent by the API.
981
+ */
982
+ average_open_premium?: string | null;
983
+ /**
984
+ * The total number of buy contracts that were closed. Quantity as a decimal
985
+ * string, as sent by the API.
986
+ */
987
+ buy_contracts_closed?: string | null;
988
+ /**
989
+ * The total number of buy contracts that were expired. Quantity as a decimal
990
+ * string, as sent by the API.
991
+ */
992
+ buy_contracts_expired?: string | null;
993
+ /**
994
+ * The total number of buy contracts settled in the position. Quantity as a
995
+ * decimal string, as sent by the API.
996
+ */
997
+ buy_contracts_settled?: string | null;
998
+ /**
999
+ * The total number of buy contracts the account has traded. Only opening
1000
+ * trade's contracts are included. Quantity as a decimal string, as sent by
1001
+ * the API.
1002
+ */
1003
+ buy_contracts_traded?: string | null;
1004
+ /**
1005
+ * The order liability on this position from buy orders. In dollars. Money as
1006
+ * a decimal string, as sent by the API.
1007
+ */
1008
+ buy_order_liability?: string | null;
1009
+ /**
1010
+ * Count of all buy orders.
1011
+ */
1012
+ buy_orders?: number | null;
1013
+ /**
1014
+ * The original risk incurred by buy trades. In dollars. Money as a decimal
1015
+ * string, as sent by the API.
1016
+ */
1017
+ buy_original_risk?: string | null;
1018
+ /**
1019
+ * Count of all settlements from buy trades.
1020
+ */
1021
+ buy_settlements?: number | null;
1022
+ /**
1023
+ * The total number of buy trades the account has made on the market.
1024
+ */
1025
+ buy_trade_count?: number | null;
1026
+ /**
1027
+ * Sum of all not matched contracts in buy cancelled orders. Quantity as a
1028
+ * decimal string, as sent by the API.
1029
+ */
1030
+ cancelled_buy_contracts?: string | null;
1031
+ /**
1032
+ * Number of buy orders that were cancelled.
1033
+ */
1034
+ cancelled_buy_orders?: number | null;
1035
+ /**
1036
+ * Sum of all not matched contracts in all cancelled orders. Quantity as a
1037
+ * decimal string, as sent by the API.
1038
+ */
1039
+ cancelled_contracts?: string | null;
1040
+ /**
1041
+ * Number of orders that were cancelled.
1042
+ */
1043
+ cancelled_orders?: number | null;
1044
+ /**
1045
+ * Sum of all not matched contracts in sell cancelled orders. Quantity as a
1046
+ * decimal string, as sent by the API.
1047
+ */
1048
+ cancelled_sell_contracts?: string | null;
1049
+ /**
1050
+ * Number of sell orders that were cancelled.
1051
+ */
1052
+ cancelled_sell_orders?: number | null;
1053
+ /**
1054
+ * Total premium from closed buy trade contracts. In dollars. Money as a
1055
+ * decimal string, as sent by the API.
1056
+ */
1057
+ closed_buy_premium?: string | null;
1058
+ /**
1059
+ * The total value of fees from closed settlements. In dollars. Money as a
1060
+ * decimal string, as sent by the API.
1061
+ */
1062
+ closed_fees?: string | null;
1063
+ /**
1064
+ * The profit or loss the account has made in `closed` settlements. In
1065
+ * dollars. Money as a decimal string, as sent by the API.
1066
+ */
1067
+ closed_gross_pnl?: string | null;
1068
+ /**
1069
+ * The net profit or loss after subtracting `closed_fees`. In dollars. Money
1070
+ * as a decimal string, as sent by the API.
1071
+ */
1072
+ closed_net_pnl?: string | null;
1073
+ /**
1074
+ * Total premium from closed contracts. In dollars. Money as a decimal string,
1075
+ * as sent by the API.
1076
+ */
1077
+ closed_premium?: string | null;
1078
+ /**
1079
+ * Total premium from closed sell trade contracts. In dollars. Money as a
1080
+ * decimal string, as sent by the API.
1081
+ */
1082
+ closed_sell_premium?: string | null;
1083
+ /**
1084
+ * The competition of this market
1085
+ */
1086
+ competition?: string | null;
1087
+ /**
1088
+ * The total number of all contracts that were closed. Quantity as a decimal
1089
+ * string, as sent by the API.
1090
+ */
1091
+ contracts_closed?: string | null;
1092
+ /**
1093
+ * The total number of all contracts that were expired. Quantity as a decimal
1094
+ * string, as sent by the API.
1095
+ */
1096
+ contracts_expired?: string | null;
1097
+ /**
1098
+ * Sum of all not matched contracts in buy orders. Quantity as a decimal
1099
+ * string, as sent by the API.
1100
+ */
1101
+ contracts_in_buy_orders?: string | null;
1102
+ /**
1103
+ * Sum of all not matched contracts in all orders. Order.quanity -
1104
+ * Order.filled. Quantity as a decimal string, as sent by the API.
1105
+ */
1106
+ contracts_in_orders?: string | null;
1107
+ /**
1108
+ * Sum of all not matched contracts in sell orders. Quantity as a decimal
1109
+ * string, as sent by the API.
1110
+ */
1111
+ contracts_in_sell_orders?: string | null;
1112
+ /**
1113
+ * The number of contracts that have been settled. Quantity as a decimal
1114
+ * string, as sent by the API.
1115
+ */
1116
+ contracts_settled?: string | null;
1117
+ /**
1118
+ * The total number of all contracts (AccountTrade.filled). Only opening trade
1119
+ * contracts are counted. Doesn't include contracts closing other trades.
1120
+ * Quantity as a decimal string, as sent by the API.
1121
+ */
1122
+ contracts_traded?: string | null;
1123
+ /**
1124
+ * The event the market belongs to.
1125
+ */
1126
+ event_id?: string | null;
1127
+ /**
1128
+ * The start time of the event. UNIX microseconds.
1129
+ */
1130
+ event_start_time?: number | null;
1131
+ /**
1132
+ * Total premium from expired buy trade contracts. In dollars. Money as a
1133
+ * decimal string, as sent by the API.
1134
+ */
1135
+ expired_buy_premium?: string | null;
1136
+ /**
1137
+ * The total value of fees from expired settlements. In dollars. Money as a
1138
+ * decimal string, as sent by the API.
1139
+ */
1140
+ expired_fees?: string | null;
1141
+ /**
1142
+ * The profit or loss the account has made in `expired` settlements. In
1143
+ * dollars. Money as a decimal string, as sent by the API.
1144
+ */
1145
+ expired_gross_pnl?: string | null;
1146
+ /**
1147
+ * The net profit or loss after subtracting `expired_fees`. In dollars. Money
1148
+ * as a decimal string, as sent by the API.
1149
+ */
1150
+ expired_net_pnl?: string | null;
1151
+ /**
1152
+ * Total premium from expired contracts. In dollars. Money as a decimal
1153
+ * string, as sent by the API.
1154
+ */
1155
+ expired_premium?: string | null;
1156
+ /**
1157
+ * Total premium from expired sell trade contracts. In dollars. Money as a
1158
+ * decimal string, as sent by the API.
1159
+ */
1160
+ expired_sell_premium?: string | null;
1161
+ /**
1162
+ * Internal. Virtual field naming the fee module in use, not part of the
1163
+ * supported contract.
1164
+ */
1165
+ fee_plugin?: string | null;
1166
+ /**
1167
+ * Creation time, as UNIX microseconds.
1168
+ */
1169
+ inserted_at?: number | null;
1170
+ /**
1171
+ * DateTime at which the last settlement was created. UNIX microseconds.
1172
+ */
1173
+ last_settled_at?: number | null;
1174
+ /**
1175
+ * The market this record relates to.
1176
+ */
1177
+ market_id?: string | null;
1178
+ /**
1179
+ * The market's maximum price - the settlement value of one winning contract.
1180
+ * In dollars. Money as a decimal string, as sent by the API.
1181
+ */
1182
+ market_max_price?: string | null;
1183
+ /**
1184
+ * Worst-case loss if this market settles against the position you hold. In
1185
+ * dollars. Money as a decimal string, as sent by the API.
1186
+ */
1187
+ max_liability_loss?: string | null;
1188
+ /**
1189
+ * Worst-case loss if this market settles in favour of the position you hold.
1190
+ * In dollars. Money as a decimal string, as sent by the API.
1191
+ */
1192
+ max_liability_win?: string | null;
1193
+ /**
1194
+ * The maximum potential fees including all actual fees paid. In dollars.
1195
+ * Money as a decimal string, as sent by the API.
1196
+ */
1197
+ max_potential_fee?: string | null;
1198
+ /**
1199
+ * The maximum potential profit, including all actual profit. In dollars.
1200
+ * Money as a decimal string, as sent by the API.
1201
+ */
1202
+ max_potential_profit?: string | null;
1203
+ /**
1204
+ * The total amount of risk on unsettled contracts. In dollars. Money as a
1205
+ * decimal string, as sent by the API.
1206
+ */
1207
+ max_risk?: string | null;
1208
+ /**
1209
+ * Internal. Consistency flag used by position rebuilds, not part of the
1210
+ * supported contract.
1211
+ */
1212
+ needs_rebuild?: boolean | null;
1213
+ /**
1214
+ * The number of open orders the account has on the market.
1215
+ */
1216
+ open_order_count?: number | null;
1217
+ /**
1218
+ * The amount of potential fee that is related to unsettled contracts. In
1219
+ * dollars. Money as a decimal string, as sent by the API.
1220
+ */
1221
+ open_potential_fee?: string | null;
1222
+ /**
1223
+ * The potential profit from the outstanding contracts. In dollars. Money as a
1224
+ * decimal string, as sent by the API.
1225
+ */
1226
+ open_potential_profit?: string | null;
1227
+ /**
1228
+ * Total premium on the user's current position in the market. In dollars.
1229
+ * Money as a decimal string, as sent by the API.
1230
+ */
1231
+ open_premium?: string | null;
1232
+ /**
1233
+ * The amount of risk associated with outstanding contracts. In dollars. Money
1234
+ * as a decimal string, as sent by the API.
1235
+ */
1236
+ open_risk?: string | null;
1237
+ /**
1238
+ * The number of open trades the account has on the market.
1239
+ */
1240
+ open_trade_count?: number | null;
1241
+ /**
1242
+ * The order liability on this position from all orders. In dollars. Money as
1243
+ * a decimal string, as sent by the API.
1244
+ */
1245
+ order_liability?: string | null;
1246
+ /**
1247
+ * Count of all orders.
1248
+ */
1249
+ orders?: number | null;
1250
+ /**
1251
+ * The original risk incurred by all trades. In dollars. Money as a decimal
1252
+ * string, as sent by the API.
1253
+ */
1254
+ original_risk?: string | null;
1255
+ /**
1256
+ * Fees that would be charged if the resting close orders all filled. In
1257
+ * dollars. Money as a decimal string, as sent by the API.
1258
+ */
1259
+ pending_close_fee?: string | null;
1260
+ /**
1261
+ * Profit or loss that would be realised if the resting close orders all
1262
+ * filled. In dollars. Money as a decimal string, as sent by the API.
1263
+ */
1264
+ pending_close_pnl?: string | null;
1265
+ /**
1266
+ * The numerical position of the account in the market. In contracts. Quantity
1267
+ * as a decimal string, as sent by the API.
1268
+ */
1269
+ position?: string | null;
1270
+ /**
1271
+ * Internal. Links to a position-accountability alert, not part of the
1272
+ * supported contract.
1273
+ */
1274
+ position_accountability_alert_id?: string | null;
1275
+ /**
1276
+ * The liability of the position that affects available balance. In dollars.
1277
+ * Money as a decimal string, as sent by the API.
1278
+ */
1279
+ position_premium_liability?: string | null;
1280
+ /**
1281
+ * Fees that would be charged if every open order on this market filled. In
1282
+ * dollars. Money as a decimal string, as sent by the API.
1283
+ */
1284
+ potential_order_trade_fee?: string | null;
1285
+ /**
1286
+ * Number of buy orders that were rejected.
1287
+ */
1288
+ rejected_buy_orders?: number | null;
1289
+ /**
1290
+ * Number of orders that were rejected.
1291
+ */
1292
+ rejected_orders?: number | null;
1293
+ /**
1294
+ * Number of sell orders that were rejected.
1295
+ */
1296
+ rejected_sell_orders?: number | null;
1297
+ /**
1298
+ * The total number of buy contracts that were closed. Quantity as a decimal
1299
+ * string, as sent by the API.
1300
+ */
1301
+ sell_contracts_closed?: string | null;
1302
+ /**
1303
+ * The total number of sell contracts that were expired. Quantity as a decimal
1304
+ * string, as sent by the API.
1305
+ */
1306
+ sell_contracts_expired?: string | null;
1307
+ /**
1308
+ * The total number of sell contracts settled in the position. Quantity as a
1309
+ * decimal string, as sent by the API.
1310
+ */
1311
+ sell_contracts_settled?: string | null;
1312
+ /**
1313
+ * The total number of sell contracts the account has traded in the market.
1314
+ * Only opening trade's contracts are included. Quantity as a decimal string,
1315
+ * as sent by the API.
1316
+ */
1317
+ sell_contracts_traded?: string | null;
1318
+ /**
1319
+ * The order liability on this position from sell orders. In dollars. Money as
1320
+ * a decimal string, as sent by the API.
1321
+ */
1322
+ sell_order_liability?: string | null;
1323
+ /**
1324
+ * Count of all sell orders.
1325
+ */
1326
+ sell_orders?: number | null;
1327
+ /**
1328
+ * The original risk incurred by sell trades. In dollars. Money as a decimal
1329
+ * string, as sent by the API.
1330
+ */
1331
+ sell_original_risk?: string | null;
1332
+ /**
1333
+ * Count of all settlements from sell trades.
1334
+ */
1335
+ sell_settlements?: number | null;
1336
+ /**
1337
+ * The total number of sell trades the account has made on the market.
1338
+ */
1339
+ sell_trade_count?: number | null;
1340
+ /**
1341
+ * DateTime at which the expired settlements were recorded which will be `nil`
1342
+ * if the market has not resulted or voided yet. UNIX microseconds.
1343
+ */
1344
+ settled_at?: number | null;
1345
+ /**
1346
+ * Count of all settlements from all trades.
1347
+ */
1348
+ settlements?: number | null;
1349
+ /**
1350
+ * The sport of this market
1351
+ */
1352
+ sport?: string | null;
1353
+ /**
1354
+ * The status of the **market** this record covers, merged in from the live
1355
+ * market index. `null` when the market is no longer held there.
1356
+ */
1357
+ status?: string | null;
1358
+ /**
1359
+ * The title of the **market** this record covers, merged in from the live
1360
+ * market index. `null` when the market is no longer held there.
1361
+ */
1362
+ title?: string | null;
1363
+ /**
1364
+ * The total fees that have been collected on the settlements. In dollars.
1365
+ * Money as a decimal string, as sent by the API.
1366
+ */
1367
+ total_fees?: string | null;
1368
+ /**
1369
+ * The liability affecting avail. balance from open orders and position. In
1370
+ * dollars. Money as a decimal string, as sent by the API.
1371
+ */
1372
+ total_liability?: string | null;
1373
+ /**
1374
+ * The net profit or loss after subtracting `total_fees`. In dollars. Money as
1375
+ * a decimal string, as sent by the API.
1376
+ */
1377
+ total_net_pnl?: string | null;
1378
+ /**
1379
+ * The total Profit or Loss on all settlements. In dollars. Money as a decimal
1380
+ * string, as sent by the API.
1381
+ */
1382
+ total_settlement_pnl?: string | null;
1383
+ /**
1384
+ * The total number of trades the account has made on the market.
1385
+ */
1386
+ trade_count?: number | null;
1387
+ /**
1388
+ * Time of the last change, as UNIX microseconds.
1389
+ */
1390
+ updated_at?: number | null;
1391
+ /** Fields the server added after this SDK was generated. */
1392
+ [key: string]: unknown;
1393
+ }
1394
+ /**
1395
+ * The account behind the API key.
1396
+ */
1397
+ interface Me {
1398
+ /**
1399
+ * Your account id. Trades, settlements and balances are scoped to it.
1400
+ */
1401
+ account_id?: string | null;
1402
+ /**
1403
+ * First name on the account, or `null` if no profile is loaded.
1404
+ */
1405
+ first_name?: string | null;
1406
+ /**
1407
+ * The id of the API key that signed this request - the value sent in the
1408
+ * access-key header.
1409
+ */
1410
+ key_id?: string | null;
1411
+ /**
1412
+ * Last name on the account, or `null` if no profile is loaded.
1413
+ */
1414
+ last_name?: string | null;
1415
+ /**
1416
+ * How this request authenticated. `api_key` for signed requests.
1417
+ */
1418
+ method?: string | null;
1419
+ /**
1420
+ * Access level granted to this key: `read_only`, or `read_write` for keys
1421
+ * that may place and cancel orders. One of: `read_only`, `read_write`.
1422
+ */
1423
+ scope?: string | null;
1424
+ /**
1425
+ * Your user id. Substitute this into private channel topics such as
1426
+ * `orders:{user_id}`.
1427
+ */
1428
+ user_id?: string | null;
1429
+ /** Fields the server added after this SDK was generated. */
1430
+ [key: string]: unknown;
1431
+ }
1432
+ /**
1433
+ * A new order to place on the exchange.
1434
+ */
1435
+ interface NewOrder {
1436
+ /**
1437
+ * Which side of the book the order takes. One of: `buy`, `sell`.
1438
+ */
1439
+ action?: string | null;
1440
+ /**
1441
+ * Cancel this order if the `orders` channel stops heartbeating. See the
1442
+ * cancel_on_disconnect guide.
1443
+ */
1444
+ cancel_on_disconnect?: boolean | null;
1445
+ /**
1446
+ * Your own reference, echoed back unchanged. A free-form string, not a UUID -
1447
+ * FIX clients routinely send ids like `my-order-001`.
1448
+ */
1449
+ client_order_id?: string | null;
1450
+ /**
1451
+ * Identifier for the device placing the order.
1452
+ */
1453
+ device_id?: string | null;
1454
+ /**
1455
+ * When the order should stop resting. One of: `good_till_start`,
1456
+ * `good_till_time`.
1457
+ */
1458
+ expiration?: string | null;
1459
+ /**
1460
+ * The moment a `good_till_time` order expires. Required when `expiration` is
1461
+ * `good_till_time`. UNIX microseconds.
1462
+ */
1463
+ expiration_time?: number | null;
1464
+ /**
1465
+ * The market to place the order on.
1466
+ */
1467
+ market_id?: string | null;
1468
+ /**
1469
+ * Whether the order takes a price or rests on the book. One of: `limit`,
1470
+ * `market`.
1471
+ */
1472
+ order_type?: string | null;
1473
+ /**
1474
+ * Limit price in dollars, as a string - `"0.42"` is 42 cents and `"42.00"` is
1475
+ * $42. A number is rejected outright rather than reinterpreted, because a
1476
+ * bare `3000` is ambiguous between subunits and dollars and the wrong reading
1477
+ * is a 100x overprice that still passes range validation. Must be strictly
1478
+ * less than the market's `max_price`; read that from the market rather than
1479
+ * assuming a fixed ceiling. Required for `limit` orders and unused by
1480
+ * `market` orders, but validated whenever it is present: a malformed or
1481
+ * sub-cent price is a 400 on a `market` order too, rather than being quietly
1482
+ * dropped. An explicit `null` is accepted there, exactly as omitting the key
1483
+ * is. Must be greater than zero and a whole number of cents - at most two
1484
+ * decimal places, not counting trailing zeros. So "0.42" and "0.4200" are the
1485
+ * same accepted value, and "0.001" is rejected. Money as a decimal string, as
1486
+ * sent by the API.
1487
+ */
1488
+ price?: string | null;
1489
+ /**
1490
+ * Number of contracts, greater than zero, as a decimal string: `"10"` and
1491
+ * `"10.00"` are read the same. A number is rejected rather than converted,
1492
+ * the same rule `price` follows, though for a different reason - a float
1493
+ * arrives as a binary double, so the size that rests on the book would not
1494
+ * always be the size that was sent. More than nine decimal places is rounded.
1495
+ * Responses always return it as a string.
1496
+ */
1497
+ quantity?: string | null;
1498
+ /** Fields the server added after this SDK was generated. */
1499
+ [key: string]: unknown;
1500
+ }
1501
+ /**
1502
+ * An order resting on, or already matched against, the exchange book.
1503
+ */
1504
+ interface Order {
1505
+ /**
1506
+ * When the matching engine accepted the order. `null` while the order is
1507
+ * still pending. UNIX microseconds.
1508
+ */
1509
+ accepted_at?: number | null;
1510
+ /**
1511
+ * The action of the order, either `buy` or `sell`. One of: `buy`, `sell`.
1512
+ */
1513
+ action?: string | null;
1514
+ /**
1515
+ * Order size expressed as stake, for orders placed by amount rather than
1516
+ * quantity. In dollars. Money as a decimal string, as sent by the API.
1517
+ */
1518
+ amount?: string | null;
1519
+ /**
1520
+ * Volume-weighted average fill price. `null` until the order has its first
1521
+ * fill. In dollars. Money as a decimal string, as sent by the API.
1522
+ */
1523
+ avg_price?: string | null;
1524
+ /**
1525
+ * The cancellation reason, if the order was cancelled.
1526
+ */
1527
+ cancellation_reason?: string | null;
1528
+ /**
1529
+ * Your own identifier, echoed back unchanged, or `null` if you sent none. A
1530
+ * free-form string, not a UUID, and set by REST and FIX callers alike.
1531
+ */
1532
+ client_order_id?: string | null;
1533
+ /**
1534
+ * The extended deadline for a delayed order. UNIX microseconds.
1535
+ */
1536
+ delayed_until?: number | null;
1537
+ /**
1538
+ * The device from which this order was placed.
1539
+ */
1540
+ device_id?: string | null;
1541
+ /**
1542
+ * The expiration condition for the order. One of: `good_till_start`,
1543
+ * `good_till_time`.
1544
+ */
1545
+ expiration?: string | null;
1546
+ /**
1547
+ * The expiration time for time-based expiration. UNIX microseconds.
1548
+ */
1549
+ expiration_time?: number | null;
1550
+ /**
1551
+ * Contracts filled so far. Compare with `quantity` to get remaining size.
1552
+ * Quantity as a decimal string, as sent by the API.
1553
+ */
1554
+ filled?: string | null;
1555
+ /**
1556
+ * The portion of `amount` that has been filled. In dollars. Money as a
1557
+ * decimal string, as sent by the API.
1558
+ */
1559
+ filled_amount?: string | null;
1560
+ /**
1561
+ * The percentage of the contracts on the order that have been filled. A
1562
+ * percentage, not money.
1563
+ */
1564
+ filled_percentage?: number | null;
1565
+ /**
1566
+ * True if the order arrived over FIX rather than REST.
1567
+ */
1568
+ fix_order?: boolean | null;
1569
+ /**
1570
+ * Unique identifier for the record.
1571
+ */
1572
+ id?: string | null;
1573
+ /**
1574
+ * Creation time, as UNIX microseconds.
1575
+ */
1576
+ inserted_at?: number | null;
1577
+ /**
1578
+ * The IP address from which this order was placed.
1579
+ */
1580
+ ip_address?: string | null;
1581
+ /**
1582
+ * The market this record relates to.
1583
+ */
1584
+ market_id?: string | null;
1585
+ /**
1586
+ * The odds type used when placing the order.
1587
+ */
1588
+ odds_type?: string | null;
1589
+ /**
1590
+ * The odds value used when placing the order.
1591
+ */
1592
+ odds_value?: string | null;
1593
+ /**
1594
+ * The type of order, either `limit` or `market`. One of: `limit`, `market`.
1595
+ */
1596
+ order_type?: string | null;
1597
+ /**
1598
+ * Whether the order was placed before the event started.
1599
+ */
1600
+ placed_pre_start?: boolean | null;
1601
+ /**
1602
+ * Limit price. The ceiling is the market's `max_price`, not a fixed 99 - read
1603
+ * it from the market. Absent for market orders. In dollars. Carries up to 7
1604
+ * decimal places - parse money with a variable-scale decimal type, not a
1605
+ * fixed-width one. Money as a decimal string, as sent by the API.
1606
+ */
1607
+ price?: string | null;
1608
+ /**
1609
+ * Order size in contracts. Quantity as a decimal string, as sent by the API.
1610
+ */
1611
+ quantity?: string | null;
1612
+ /**
1613
+ * The rejection reason, if the order was rejected.
1614
+ */
1615
+ rejection_reason?: string | null;
1616
+ /**
1617
+ * Order state - one of nine. See [Market and order
1618
+ * status](/concepts/market-status/#order-statuses) for the full set and which
1619
+ * are terminal. One of: `created`, `requested`, `accepted`, `delayed`,
1620
+ * `open`, `filled`, `rejected`, `cancelled`, `partially_cancelled`.
1621
+ */
1622
+ status?: string | null;
1623
+ /**
1624
+ * The ISO-8601 timestamp of the time the order was placed.
1625
+ */
1626
+ time?: string | null;
1627
+ /**
1628
+ * Total premium across all fills on this order. In dollars. Money as a
1629
+ * decimal string, as sent by the API.
1630
+ */
1631
+ total_value?: string | null;
1632
+ /** Fields the server added after this SDK was generated. */
1633
+ [key: string]: unknown;
1634
+ }
1635
+ /**
1636
+ * One deposit, withdrawal or balance adjustment, enriched with its payment
1637
+ * method.
1638
+ */
1639
+ interface PaymentTransaction {
1640
+ /**
1641
+ * The account the record belongs to.
1642
+ */
1643
+ account_id?: string | null;
1644
+ /**
1645
+ * The monetary value the entry was calculated from. In dollars. Money as a
1646
+ * decimal string, as sent by the API.
1647
+ */
1648
+ amount?: string | null;
1649
+ /**
1650
+ * The event the market belongs to.
1651
+ */
1652
+ event_id?: string | null;
1653
+ /**
1654
+ * The fee that generated this entry, when it came from one.
1655
+ */
1656
+ fee_id?: string | null;
1657
+ /**
1658
+ * Unique identifier for the record.
1659
+ */
1660
+ id?: string | null;
1661
+ /**
1662
+ * Creation time, as UNIX microseconds.
1663
+ */
1664
+ inserted_at?: number | null;
1665
+ /**
1666
+ * The market this record relates to.
1667
+ */
1668
+ market_id?: string | null;
1669
+ /**
1670
+ * The payment method the provider reports for this transaction.
1671
+ */
1672
+ method?: string | null;
1673
+ /**
1674
+ * The payment that generated this entry, when it came from one.
1675
+ */
1676
+ payment_id?: string | null;
1677
+ /**
1678
+ * Points added by this entry. Negative when points were spent.
1679
+ */
1680
+ points?: number | null;
1681
+ /**
1682
+ * The provider's reason or description for the transaction.
1683
+ */
1684
+ reason?: string | null;
1685
+ /**
1686
+ * The settlement that generated this entry, when it came from one.
1687
+ */
1688
+ settlement_id?: string | null;
1689
+ /**
1690
+ * For Interac, whether the transfer was a `Send` or a `Request`.
1691
+ */
1692
+ sub_method?: string | null;
1693
+ /**
1694
+ * When the entry was recorded.
1695
+ */
1696
+ time?: string | null;
1697
+ /**
1698
+ * What moved the money or the points - for example a deposit, a trade fee, a
1699
+ * referral, or a manual adjustment. Each endpoint returns only its own subset
1700
+ * of these. One of: `deposit`, `withdrawal`, `settlement`, `fee`,
1701
+ * `fee_refund`, `casino`, `adjustment`, `loyalty`, `loyalty_points_rollup`,
1702
+ * `loyalty_points_referral`.
1703
+ */
1704
+ type?: string | null;
1705
+ /** Fields the server added after this SDK was generated. */
1706
+ [key: string]: unknown;
1707
+ }
1708
+ /**
1709
+ * Your position in one market.
1710
+ */
1711
+ interface Position {
1712
+ /**
1713
+ * The account the position belongs to.
1714
+ */
1715
+ account_id?: string | null;
1716
+ /**
1717
+ * Average premium per contract for the open portion. In dollars. Money as a
1718
+ * decimal string, as sent by the API.
1719
+ */
1720
+ average_open_premium?: string | null;
1721
+ /**
1722
+ * Liability from your open buy orders on this market. In dollars. Money as a
1723
+ * decimal string, as sent by the API.
1724
+ */
1725
+ buy_order_liability?: string | null;
1726
+ /**
1727
+ * Contracts settled in the position so far. Quantity as a decimal string, as
1728
+ * sent by the API.
1729
+ */
1730
+ contracts_settled?: string | null;
1731
+ /**
1732
+ * The event the market belongs to.
1733
+ */
1734
+ event_id?: string | null;
1735
+ /**
1736
+ * `total_settlement_pnl` plus any pending-close profit or loss that has not
1737
+ * settled yet. In dollars. Money as a decimal string, as sent by the API.
1738
+ */
1739
+ gross_pnl?: string | null;
1740
+ /**
1741
+ * The unique id of the position record.
1742
+ */
1743
+ id?: string | null;
1744
+ /**
1745
+ * The market the position is on.
1746
+ */
1747
+ market_id?: string | null;
1748
+ /**
1749
+ * Total potential fee across the position's settlements. In dollars. Money as
1750
+ * a decimal string, as sent by the API.
1751
+ */
1752
+ max_potential_fee?: string | null;
1753
+ /**
1754
+ * Total possible profit for the position if everything settles favourably. In
1755
+ * dollars. Money as a decimal string, as sent by the API.
1756
+ */
1757
+ max_potential_profit?: string | null;
1758
+ /**
1759
+ * Account-level risk on the position, netting in already settled profit and
1760
+ * loss. In dollars. Money as a decimal string, as sent by the API.
1761
+ */
1762
+ max_risk?: string | null;
1763
+ /**
1764
+ * Potential fee on the open contracts when they settle. In dollars. Money as
1765
+ * a decimal string, as sent by the API.
1766
+ */
1767
+ open_potential_fee?: string | null;
1768
+ /**
1769
+ * Possible profit on the position's open contracts. In dollars. Money as a
1770
+ * decimal string, as sent by the API.
1771
+ */
1772
+ open_potential_profit?: string | null;
1773
+ /**
1774
+ * Risk on the position's open (unsettled) contracts. In dollars. Money as a
1775
+ * decimal string, as sent by the API.
1776
+ */
1777
+ open_risk?: string | null;
1778
+ /**
1779
+ * Net position in the market: positive if long (bought), negative if short
1780
+ * (sold). Can be `"0.00"` for a market you have traded and closed out that
1781
+ * has not settled yet. In contracts. Quantity as a decimal string, as sent by
1782
+ * the API.
1783
+ */
1784
+ position?: string | null;
1785
+ /**
1786
+ * Liability from the position's premium that counts against available
1787
+ * balance. Routinely negative. In dollars. Money as a decimal string, as sent
1788
+ * by the API.
1789
+ */
1790
+ position_premium_liability?: string | null;
1791
+ /**
1792
+ * Total premium paid or received for the open portion of the position. In
1793
+ * dollars. Money as a decimal string, as sent by the API.
1794
+ */
1795
+ premium?: string | null;
1796
+ /**
1797
+ * Liability from your open sell orders on this market. In dollars. Money as a
1798
+ * decimal string, as sent by the API.
1799
+ */
1800
+ sell_order_liability?: string | null;
1801
+ /**
1802
+ * Total fees paid across the position's settlements. In dollars. Money as a
1803
+ * decimal string, as sent by the API.
1804
+ */
1805
+ total_fee?: string | null;
1806
+ /**
1807
+ * Profit or loss realised from settlements so far. In dollars. Money as a
1808
+ * decimal string, as sent by the API.
1809
+ */
1810
+ total_settlement_pnl?: string | null;
1811
+ /** Fields the server added after this SDK was generated. */
1812
+ [key: string]: unknown;
1813
+ }
1814
+ /**
1815
+ * One recent public trade on the market.
1816
+ */
1817
+ interface RecentTrade {
1818
+ /**
1819
+ * Which side took liquidity. `Trade.liquidity_taker/1` derives this from the
1820
+ * resting side, so the values are `buyer` and `seller` - not `buy`/`sell` as
1821
+ * on an order's `action`. One of: `buyer`, `seller`.
1822
+ */
1823
+ liquidity_taker?: string | null;
1824
+ /**
1825
+ * The price the trade executed at. In dollars. Money as a decimal string, as
1826
+ * sent by the API.
1827
+ */
1828
+ price?: string | null;
1829
+ /**
1830
+ * Contracts traded. Quantity as a decimal string, as sent by the API.
1831
+ */
1832
+ quantity?: string | null;
1833
+ /**
1834
+ * When the trade executed.
1835
+ */
1836
+ timestamp?: string | null;
1837
+ /**
1838
+ * When the trade executed, as UNIX microseconds.
1839
+ */
1840
+ timestamp_us?: number | null;
1841
+ /** Fields the server added after this SDK was generated. */
1842
+ [key: string]: unknown;
1843
+ }
1844
+ /**
1845
+ * One closed or expired position.
1846
+ */
1847
+ interface Settlement {
1848
+ /**
1849
+ * The account the record belongs to.
1850
+ */
1851
+ account_id?: string | null;
1852
+ /**
1853
+ * Whether the closing trade's order was placed before the event started.
1854
+ */
1855
+ closing_placed_pre_start?: boolean | null;
1856
+ /**
1857
+ * The price of the contracts when the position was closed. In dollars. Money
1858
+ * as a decimal string, as sent by the API.
1859
+ */
1860
+ closing_price?: string | null;
1861
+ /**
1862
+ * The id of the trade that closed this settlement, if any.
1863
+ */
1864
+ closing_trade_id?: string | null;
1865
+ /**
1866
+ * Whether the closing trade was placed before the event started.
1867
+ */
1868
+ closing_traded_pre_start?: boolean | null;
1869
+ /**
1870
+ * The fee charged for the settlement. In dollars. Money as a decimal string,
1871
+ * as sent by the API.
1872
+ */
1873
+ fee?: string | null;
1874
+ /**
1875
+ * The profit or loss associated with the position. In dollars. Money as a
1876
+ * decimal string, as sent by the API.
1877
+ */
1878
+ gross_pnl?: string | null;
1879
+ /**
1880
+ * Unique identifier for the record.
1881
+ */
1882
+ id?: string | null;
1883
+ /**
1884
+ * Creation time, as UNIX microseconds.
1885
+ */
1886
+ inserted_at?: number | null;
1887
+ /**
1888
+ * The market this record relates to.
1889
+ */
1890
+ market_id?: string | null;
1891
+ /**
1892
+ * Whether the opening trade's order was placed before the event started.
1893
+ */
1894
+ opening_placed_pre_start?: boolean | null;
1895
+ /**
1896
+ * The price of the contracts when the position was opened. In dollars. Money
1897
+ * as a decimal string, as sent by the API.
1898
+ */
1899
+ opening_price?: string | null;
1900
+ /**
1901
+ * The id of the trade that opened this settlement.
1902
+ */
1903
+ opening_trade_id?: string | null;
1904
+ /**
1905
+ * Whether the opening trade was placed before the event started.
1906
+ */
1907
+ opening_traded_pre_start?: boolean | null;
1908
+ /**
1909
+ * Whether the settlement was placed before the event started.
1910
+ */
1911
+ pre_start?: boolean | null;
1912
+ /**
1913
+ * The number of contracts that were settled. Quantity as a decimal string, as
1914
+ * sent by the API.
1915
+ */
1916
+ quantity?: string | null;
1917
+ /**
1918
+ * The net profit or loss minus fees. In dollars. Money as a decimal string,
1919
+ * as sent by the API.
1920
+ */
1921
+ realized_pnl?: string | null;
1922
+ /**
1923
+ * The amount of premium that was settled by the trade. In dollars. Money as a
1924
+ * decimal string, as sent by the API.
1925
+ */
1926
+ settled_premium?: string | null;
1927
+ /**
1928
+ * The amount of risk that was settled by the trade. In dollars. Money as a
1929
+ * decimal string, as sent by the API.
1930
+ */
1931
+ settled_risk?: string | null;
1932
+ /**
1933
+ * ISO-8601 timestamp of when the settlement was created. Same instant as
1934
+ * `inserted_at`, which carries it as UNIX microseconds.
1935
+ */
1936
+ time?: string | null;
1937
+ /**
1938
+ * The type of settlement. One of: `closed_short`, `closed_long`,
1939
+ * `expired_short`, `expired_long`.
1940
+ */
1941
+ type?: string | null;
1942
+ /** Fields the server added after this SDK was generated. */
1943
+ [key: string]: unknown;
1944
+ }
1945
+ /**
1946
+ * The stat line a prop market is derived from.
1947
+ */
1948
+ interface StatDetail {
1949
+ /**
1950
+ * The player's jersey number, when known.
1951
+ */
1952
+ jersey?: string | null;
1953
+ /**
1954
+ * The line value the market sits at, when the prop carries one.
1955
+ */
1956
+ line?: number | null;
1957
+ /**
1958
+ * The participant the line belongs to, when applicable.
1959
+ */
1960
+ participant?: string | null;
1961
+ /**
1962
+ * The player the line belongs to, or `null` for a team line.
1963
+ */
1964
+ player?: string | null;
1965
+ /**
1966
+ * The shape of the prop. One of: `ou`, `yn`, `1v2`, `field`.
1967
+ */
1968
+ prop_type?: string | null;
1969
+ /**
1970
+ * The stat being wagered on, e.g. `passingYards`.
1971
+ */
1972
+ stat?: string | null;
1973
+ /**
1974
+ * Human-readable name for `stat`.
1975
+ */
1976
+ stat_display_name?: string | null;
1977
+ /** Fields the server added after this SDK was generated. */
1978
+ [key: string]: unknown;
1979
+ }
1980
+ /**
1981
+ * One ledger entry on the account.
1982
+ */
1983
+ interface Transaction {
1984
+ /**
1985
+ * The account the record belongs to.
1986
+ */
1987
+ account_id?: string | null;
1988
+ /**
1989
+ * The monetary value the entry was calculated from. In dollars. Money as a
1990
+ * decimal string, as sent by the API.
1991
+ */
1992
+ amount?: string | null;
1993
+ /**
1994
+ * The event the market belongs to.
1995
+ */
1996
+ event_id?: string | null;
1997
+ /**
1998
+ * The fee that generated this entry, when it came from one.
1999
+ */
2000
+ fee_id?: string | null;
2001
+ /**
2002
+ * Unique identifier for the record.
2003
+ */
2004
+ id?: string | null;
2005
+ /**
2006
+ * Creation time, as UNIX microseconds.
2007
+ */
2008
+ inserted_at?: number | null;
2009
+ /**
2010
+ * The market this record relates to.
2011
+ */
2012
+ market_id?: string | null;
2013
+ /**
2014
+ * The payment that generated this entry, when it came from one.
2015
+ */
2016
+ payment_id?: string | null;
2017
+ /**
2018
+ * Points added by this entry. Negative when points were spent.
2019
+ */
2020
+ points?: number | null;
2021
+ /**
2022
+ * For referral entries, the account that was referred.
2023
+ */
2024
+ referee_account_id?: string | null;
2025
+ /**
2026
+ * For referral entries, the account that referred.
2027
+ */
2028
+ referrer_account_id?: string | null;
2029
+ /**
2030
+ * The settlement that generated this entry, when it came from one.
2031
+ */
2032
+ settlement_id?: string | null;
2033
+ /**
2034
+ * When the entry was recorded.
2035
+ */
2036
+ time?: string | null;
2037
+ /**
2038
+ * What moved the money or the points - for example a deposit, a trade fee, a
2039
+ * referral, or a manual adjustment. Each endpoint returns only its own subset
2040
+ * of these. One of: `deposit`, `withdrawal`, `settlement`, `fee`,
2041
+ * `fee_refund`, `casino`, `adjustment`, `loyalty`, `loyalty_points_rollup`,
2042
+ * `loyalty_points_referral`.
2043
+ */
2044
+ type?: string | null;
2045
+ /** Fields the server added after this SDK was generated. */
2046
+ [key: string]: unknown;
2047
+ }
2048
+
2049
+ type models_Balance = Balance;
2050
+ type models_BookLevel = BookLevel;
2051
+ type models_Cancellation = Cancellation;
2052
+ type models_Event = Event;
2053
+ type models_FeeTransaction = FeeTransaction;
2054
+ type models_Fill = Fill;
2055
+ type models_Market = Market;
2056
+ type models_MarketFilter = MarketFilter;
2057
+ type models_MarketStat = MarketStat;
2058
+ type models_Me = Me;
2059
+ type models_NewOrder = NewOrder;
2060
+ type models_Order = Order;
2061
+ type models_PaymentTransaction = PaymentTransaction;
2062
+ type models_Position = Position;
2063
+ type models_RecentTrade = RecentTrade;
2064
+ type models_Settlement = Settlement;
2065
+ type models_StatDetail = StatDetail;
2066
+ type models_Transaction = Transaction;
2067
+ declare namespace models {
2068
+ export type { models_Balance as Balance, models_BookLevel as BookLevel, models_Cancellation as Cancellation, Error$1 as Error, models_Event as Event, models_FeeTransaction as FeeTransaction, models_Fill as Fill, models_Market as Market, models_MarketFilter as MarketFilter, models_MarketStat as MarketStat, models_Me as Me, models_NewOrder as NewOrder, models_Order as Order, models_PaymentTransaction as PaymentTransaction, models_Position as Position, models_RecentTrade as RecentTrade, models_Settlement as Settlement, models_StatDetail as StatDetail, models_Transaction as Transaction };
2069
+ }
2070
+
2071
+ interface Operation {
2072
+ readonly method: "GET" | "POST" | "DELETE";
2073
+ readonly path: string;
2074
+ readonly query: readonly string[];
2075
+ readonly pathParams: readonly string[];
2076
+ readonly hasBody: boolean;
2077
+ readonly responseKey: string;
2078
+ readonly model: string;
2079
+ readonly isList: boolean;
2080
+ readonly paginated: boolean;
2081
+ }
2082
+ declare const OPERATIONS: {
2083
+ readonly account_balance_get: {
2084
+ readonly method: "GET";
2085
+ readonly path: "/api/v1/account/balance";
2086
+ readonly query: readonly [];
2087
+ readonly pathParams: readonly [];
2088
+ readonly hasBody: false;
2089
+ readonly responseKey: "balance";
2090
+ readonly model: "Balance";
2091
+ readonly isList: false;
2092
+ readonly paginated: false;
2093
+ };
2094
+ readonly account_market_stats_get: {
2095
+ readonly method: "GET";
2096
+ readonly path: "/api/v1/account/market_stats";
2097
+ readonly query: readonly ["market_ids", "event_ids", "exclude_zero_settlements", "from_time", "to_time", "sports", "competitions", "limit", "cursor"];
2098
+ readonly pathParams: readonly [];
2099
+ readonly hasBody: false;
2100
+ readonly responseKey: "market_stats";
2101
+ readonly model: "MarketStat";
2102
+ readonly isList: true;
2103
+ readonly paginated: true;
2104
+ };
2105
+ readonly events_get: {
2106
+ readonly method: "GET";
2107
+ readonly path: "/api/v1/events";
2108
+ readonly query: readonly ["event_ids", "sports", "competitions", "event_types", "title", "status", "promoted", "sort_by[name]", "sort_by[direction]", "limit", "cursor"];
2109
+ readonly pathParams: readonly [];
2110
+ readonly hasBody: false;
2111
+ readonly responseKey: "events";
2112
+ readonly model: "Event";
2113
+ readonly isList: true;
2114
+ readonly paginated: true;
2115
+ };
2116
+ readonly fills_get: {
2117
+ readonly method: "GET";
2118
+ readonly path: "/api/v1/fills";
2119
+ readonly query: readonly ["market_ids", "order_ids", "status", "limit", "cursor"];
2120
+ readonly pathParams: readonly [];
2121
+ readonly hasBody: false;
2122
+ readonly responseKey: "fills";
2123
+ readonly model: "Fill";
2124
+ readonly isList: true;
2125
+ readonly paginated: true;
2126
+ };
2127
+ readonly markets_get: {
2128
+ readonly method: "GET";
2129
+ readonly path: "/api/v1/markets";
2130
+ readonly query: readonly ["market_ids", "event_ids", "status", "trading", "sports", "competitions", "sort_by[name]", "sort_by[direction]", "limit", "cursor"];
2131
+ readonly pathParams: readonly [];
2132
+ readonly hasBody: false;
2133
+ readonly responseKey: "markets";
2134
+ readonly model: "Market";
2135
+ readonly isList: true;
2136
+ readonly paginated: true;
2137
+ };
2138
+ readonly me_get: {
2139
+ readonly method: "GET";
2140
+ readonly path: "/api/v1/me";
2141
+ readonly query: readonly [];
2142
+ readonly pathParams: readonly [];
2143
+ readonly hasBody: false;
2144
+ readonly responseKey: "me";
2145
+ readonly model: "Me";
2146
+ readonly isList: false;
2147
+ readonly paginated: false;
2148
+ };
2149
+ readonly orders_get: {
2150
+ readonly method: "GET";
2151
+ readonly path: "/api/v1/orders";
2152
+ readonly query: readonly ["order_ids", "client_order_ids", "market_ids", "status", "limit", "cursor"];
2153
+ readonly pathParams: readonly [];
2154
+ readonly hasBody: false;
2155
+ readonly responseKey: "orders";
2156
+ readonly model: "Order";
2157
+ readonly isList: true;
2158
+ readonly paginated: true;
2159
+ };
2160
+ readonly orders_post: {
2161
+ readonly method: "POST";
2162
+ readonly path: "/api/v1/orders";
2163
+ readonly query: readonly [];
2164
+ readonly pathParams: readonly [];
2165
+ readonly hasBody: true;
2166
+ readonly responseKey: "order";
2167
+ readonly model: "Order";
2168
+ readonly isList: false;
2169
+ readonly paginated: false;
2170
+ };
2171
+ readonly orders_all_delete: {
2172
+ readonly method: "DELETE";
2173
+ readonly path: "/api/v1/orders/all";
2174
+ readonly query: readonly [];
2175
+ readonly pathParams: readonly [];
2176
+ readonly hasBody: false;
2177
+ readonly responseKey: "cancellations";
2178
+ readonly model: "Cancellation";
2179
+ readonly isList: true;
2180
+ readonly paginated: false;
2181
+ };
2182
+ readonly orders_batched_delete: {
2183
+ readonly method: "DELETE";
2184
+ readonly path: "/api/v1/orders/batched";
2185
+ readonly query: readonly [];
2186
+ readonly pathParams: readonly [];
2187
+ readonly hasBody: true;
2188
+ readonly responseKey: "cancellations";
2189
+ readonly model: "Cancellation";
2190
+ readonly isList: true;
2191
+ readonly paginated: false;
2192
+ };
2193
+ readonly orders_batched_post: {
2194
+ readonly method: "POST";
2195
+ readonly path: "/api/v1/orders/batched";
2196
+ readonly query: readonly [];
2197
+ readonly pathParams: readonly [];
2198
+ readonly hasBody: true;
2199
+ readonly responseKey: "results";
2200
+ readonly model: "";
2201
+ readonly isList: true;
2202
+ readonly paginated: false;
2203
+ };
2204
+ readonly orders__order_id_delete: {
2205
+ readonly method: "DELETE";
2206
+ readonly path: "/api/v1/orders/{order_id}";
2207
+ readonly query: readonly [];
2208
+ readonly pathParams: readonly ["order_id"];
2209
+ readonly hasBody: false;
2210
+ readonly responseKey: "";
2211
+ readonly model: "";
2212
+ readonly isList: false;
2213
+ readonly paginated: false;
2214
+ };
2215
+ readonly orders__id_get: {
2216
+ readonly method: "GET";
2217
+ readonly path: "/api/v1/orders/{order_id}";
2218
+ readonly query: readonly [];
2219
+ readonly pathParams: readonly ["order_id"];
2220
+ readonly hasBody: false;
2221
+ readonly responseKey: "order";
2222
+ readonly model: "Order";
2223
+ readonly isList: false;
2224
+ readonly paginated: false;
2225
+ };
2226
+ readonly portfolio_adjustments_get: {
2227
+ readonly method: "GET";
2228
+ readonly path: "/api/v1/portfolio/adjustments";
2229
+ readonly query: readonly ["limit", "cursor"];
2230
+ readonly pathParams: readonly [];
2231
+ readonly hasBody: false;
2232
+ readonly responseKey: "adjustments";
2233
+ readonly model: "PaymentTransaction";
2234
+ readonly isList: true;
2235
+ readonly paginated: true;
2236
+ };
2237
+ readonly portfolio_deposits_get: {
2238
+ readonly method: "GET";
2239
+ readonly path: "/api/v1/portfolio/deposits";
2240
+ readonly query: readonly ["limit", "cursor"];
2241
+ readonly pathParams: readonly [];
2242
+ readonly hasBody: false;
2243
+ readonly responseKey: "deposits";
2244
+ readonly model: "PaymentTransaction";
2245
+ readonly isList: true;
2246
+ readonly paginated: true;
2247
+ };
2248
+ readonly portfolio_fees_get: {
2249
+ readonly method: "GET";
2250
+ readonly path: "/api/v1/portfolio/fees";
2251
+ readonly query: readonly ["limit", "cursor"];
2252
+ readonly pathParams: readonly [];
2253
+ readonly hasBody: false;
2254
+ readonly responseKey: "fees";
2255
+ readonly model: "FeeTransaction";
2256
+ readonly isList: true;
2257
+ readonly paginated: true;
2258
+ };
2259
+ readonly portfolio_loyalty_get: {
2260
+ readonly method: "GET";
2261
+ readonly path: "/api/v1/portfolio/loyalty";
2262
+ readonly query: readonly ["limit", "cursor"];
2263
+ readonly pathParams: readonly [];
2264
+ readonly hasBody: false;
2265
+ readonly responseKey: "loyalty";
2266
+ readonly model: "Transaction";
2267
+ readonly isList: true;
2268
+ readonly paginated: true;
2269
+ };
2270
+ readonly portfolio_settlements_get: {
2271
+ readonly method: "GET";
2272
+ readonly path: "/api/v1/portfolio/settlements";
2273
+ readonly query: readonly ["market_ids", "type", "limit", "cursor"];
2274
+ readonly pathParams: readonly [];
2275
+ readonly hasBody: false;
2276
+ readonly responseKey: "settlements";
2277
+ readonly model: "Settlement";
2278
+ readonly isList: true;
2279
+ readonly paginated: true;
2280
+ };
2281
+ readonly portfolio_withdrawals_get: {
2282
+ readonly method: "GET";
2283
+ readonly path: "/api/v1/portfolio/withdrawals";
2284
+ readonly query: readonly ["limit", "cursor"];
2285
+ readonly pathParams: readonly [];
2286
+ readonly hasBody: false;
2287
+ readonly responseKey: "withdrawals";
2288
+ readonly model: "PaymentTransaction";
2289
+ readonly isList: true;
2290
+ readonly paginated: true;
2291
+ };
2292
+ readonly positions_get: {
2293
+ readonly method: "GET";
2294
+ readonly path: "/api/v1/positions";
2295
+ readonly query: readonly ["market_ids"];
2296
+ readonly pathParams: readonly [];
2297
+ readonly hasBody: false;
2298
+ readonly responseKey: "positions";
2299
+ readonly model: "Position";
2300
+ readonly isList: true;
2301
+ readonly paginated: false;
2302
+ };
2303
+ readonly tnc_accept_post: {
2304
+ readonly method: "POST";
2305
+ readonly path: "/api/v1/tnc/accept";
2306
+ readonly query: readonly [];
2307
+ readonly pathParams: readonly [];
2308
+ readonly hasBody: true;
2309
+ readonly responseKey: "message";
2310
+ readonly model: "";
2311
+ readonly isList: false;
2312
+ readonly paginated: false;
2313
+ };
2314
+ };
2315
+ type OperationId = keyof typeof OPERATIONS;
2316
+
2317
+ declare class Page<T> implements Iterable<T> {
2318
+ readonly items: T[];
2319
+ readonly cursor: string | null;
2320
+ constructor(items: T[], cursor: string | null);
2321
+ /** True when another page exists. */
2322
+ get hasMore(): boolean;
2323
+ get length(): number;
2324
+ /** The item at `index`; negative counts from the end. */
2325
+ at(index: number): T | undefined;
2326
+ [Symbol.iterator](): Iterator<T>;
2327
+ toString(): string;
2328
+ }
2329
+
2330
+ /**
2331
+ * One entry of `placeOrders`: the order, or why it was not placed. Results
2332
+ * come back in the order the orders were sent; exactly one of `order` and
2333
+ * `errors` is set. `ok` is true when the order was placed.
2334
+ */
2335
+ interface BatchOrderResult {
2336
+ order?: Order | null;
2337
+ errors?: string[] | null;
2338
+ readonly ok: boolean;
2339
+ [key: string]: unknown;
2340
+ }
2341
+
2342
+ interface STXExceptionOptions {
2343
+ statusCode?: number;
2344
+ body?: unknown;
2345
+ method?: string;
2346
+ path?: string;
2347
+ cause?: unknown;
2348
+ }
2349
+ /** Base for every error the SDK throws. */
2350
+ declare class STXException extends Error {
2351
+ readonly statusCode: number | undefined;
2352
+ readonly body: unknown;
2353
+ readonly method: string | undefined;
2354
+ readonly path: string | undefined;
2355
+ constructor(message: string, opts?: STXExceptionOptions);
2356
+ }
2357
+ /** The client is misconfigured: unknown region, missing key, bad PEM. */
2358
+ declare class STXConfigException extends STXException {
2359
+ }
2360
+ /** The API answered with an error status. Base for the classes below. */
2361
+ declare class STXAPIException extends STXException {
2362
+ }
2363
+ /** 400: a parameter or body field was rejected, e.g. `price is required`. */
2364
+ declare class STXValidationException extends STXAPIException {
2365
+ }
2366
+ /**
2367
+ * 401: the signature, key id or timestamp was not accepted. A machine clock
2368
+ * more than 30 seconds off also lands here.
2369
+ */
2370
+ declare class STXAuthenticationException extends STXAPIException {
2371
+ }
2372
+ /**
2373
+ * 403: the key is read-only, or the account may not do this. For an OAuth
2374
+ * bearer token refused for scope, `requiredScopes` lists what would satisfy
2375
+ * the call (from the `WWW-Authenticate` challenge).
2376
+ */
2377
+ declare class STXForbiddenException extends STXAPIException {
2378
+ readonly requiredScopes: readonly string[];
2379
+ constructor(message: string, opts?: STXExceptionOptions & {
2380
+ requiredScopes?: readonly string[];
2381
+ });
2382
+ }
2383
+ /**
2384
+ * 401 on an OAuth bearer request: the access token is missing, expired or
2385
+ * revoked (`WWW-Authenticate: Bearer error="invalid_token"`). The OAuth
2386
+ * adapters refresh and retry once before this reaches you; seeing it means the
2387
+ * refresh did not help.
2388
+ */
2389
+ declare class STXInvalidTokenException extends STXAuthenticationException {
2390
+ }
2391
+ /**
2392
+ * 403 on an OAuth bearer request: the token is valid but its grant lacks the
2393
+ * scope this operation needs (`WWW-Authenticate: Bearer
2394
+ * error="insufficient_scope", scope="orders.write"`). `requiredScopes` names
2395
+ * what would satisfy it; send the member back through consent asking for it.
2396
+ */
2397
+ declare class STXInsufficientScopeException extends STXForbiddenException {
2398
+ }
2399
+ /** 404: the resource does not exist, or belongs to another account. */
2400
+ declare class STXNotFoundException extends STXAPIException {
2401
+ }
2402
+ /**
2403
+ * 422: the exchange refused the request, e.g. insufficient funds or a closed
2404
+ * market.
2405
+ */
2406
+ declare class STXRejectedException extends STXAPIException {
2407
+ }
2408
+ /**
2409
+ * 422 from the exchange's geo-fencing: this request's IP address is not
2410
+ * allowed to trade, or the geolocation packet sent with it was missing,
2411
+ * invalid, expired or from another user. A subclass of
2412
+ * `STXRejectedException`, so existing `catch` blocks still see it.
2413
+ *
2414
+ * `reason` classifies it; `ipAddress` is the address the exchange saw, when
2415
+ * its message names one. Never retried.
2416
+ */
2417
+ declare class STXGeoLocationException extends STXRejectedException {
2418
+ readonly reason: GeoRejection["reason"];
2419
+ readonly ipAddress: string | undefined;
2420
+ constructor(message: string, rejection: GeoRejection, opts?: STXExceptionOptions);
2421
+ }
2422
+ /** 429: too many requests. `retryAfter` is seconds, when sent. */
2423
+ declare class STXRateLimitException extends STXAPIException {
2424
+ readonly retryAfter: number | undefined;
2425
+ constructor(message: string, opts?: STXExceptionOptions & {
2426
+ retryAfter?: number;
2427
+ });
2428
+ }
2429
+ /** 5xx: the server failed. Retried by the default policy on GET and DELETE. */
2430
+ declare class STXServerException extends STXAPIException {
2431
+ }
2432
+ /** The request never got an answer: connection, DNS, TLS or timeout. */
2433
+ declare class STXTransportException extends STXException {
2434
+ }
2435
+ /**
2436
+ * A channel join or channel message was refused by the server. `reply` holds
2437
+ * the server's `response` object, for example `{reason: "unauthorized"}`.
2438
+ */
2439
+ declare class STXChannelException extends STXException {
2440
+ readonly topic: string;
2441
+ readonly reply: unknown;
2442
+ constructor(message: string, opts?: {
2443
+ topic?: string;
2444
+ reply?: unknown;
2445
+ });
2446
+ /**
2447
+ * The server's refusal reason, e.g. `unauthorized` (the topic is not yours)
2448
+ * or `insufficient_scope` (an OAuth token lacks the scope the topic needs).
2449
+ */
2450
+ get reason(): string | undefined;
2451
+ }
2452
+ /**
2453
+ * No reply, message or snapshot arrived on a channel in time. A subclass of
2454
+ * `STXChannelException`.
2455
+ */
2456
+ declare class STXTimeoutException extends STXChannelException {
2457
+ }
2458
+ /** Build the exception for one non-2xx response. */
2459
+ declare function errorForStatus(statusCode: number, body: unknown, opts: {
2460
+ method: string;
2461
+ path: string;
2462
+ retryAfter?: string | null;
2463
+ wwwAuthenticate?: string | null;
2464
+ }): STXAPIException;
2465
+
2466
+ type ExceptionClass = abstract new (...args: never[]) => STXException;
2467
+ interface RetryPolicyOptions {
2468
+ /** Total attempts, including the first. Default 3. */
2469
+ maxAttempts?: number;
2470
+ /** Milliseconds before the first retry. Default 500. */
2471
+ initialBackoffMs?: number;
2472
+ /** Cap on any one wait, in milliseconds. Default 30000. */
2473
+ maxBackoffMs?: number;
2474
+ /** Randomise each wait between 50% and 100% of its value. Default true. */
2475
+ jitter?: boolean;
2476
+ /** Exception classes eligible for a retry. */
2477
+ retryableExceptions?: readonly ExceptionClass[];
2478
+ }
2479
+ /**
2480
+ * How many times to try a call, and how long to wait between tries. The
2481
+ * default is 3 attempts, 500 ms initial backoff doubling to a 30 s cap, with
2482
+ * jitter. `new RetryPolicy({ maxAttempts: 1 })` (or `NO_RETRY`) turns
2483
+ * retries off.
2484
+ */
2485
+ declare class RetryPolicy {
2486
+ readonly maxAttempts: number;
2487
+ readonly initialBackoffMs: number;
2488
+ readonly maxBackoffMs: number;
2489
+ readonly jitter: boolean;
2490
+ readonly retryableExceptions: readonly ExceptionClass[];
2491
+ constructor(opts?: RetryPolicyOptions);
2492
+ /** Whether to try again after `exc` ended attempt number `attempt`. */
2493
+ shouldRetry(exc: STXException, attempt: number, idempotent: boolean): boolean;
2494
+ /** Milliseconds to wait after attempt `attempt` (1-based) failed. */
2495
+ computeBackoffMs(attempt: number, exc: STXException): number;
2496
+ }
2497
+ /** One attempt, no backoff. */
2498
+ declare const NO_RETRY: RetryPolicy;
2499
+
2500
+ declare const KEY_HEADER = "X-STX-ACCESS-KEY";
2501
+ declare const TIMESTAMP_HEADER = "X-STX-ACCESS-TIMESTAMP";
2502
+ declare const SIGNATURE_HEADER = "X-STX-ACCESS-SIGNATURE";
2503
+ /**
2504
+ * Signs the message bytes and returns the raw 64-byte Ed25519 signature. May
2505
+ * be async, for keys held in an HSM or a cloud KMS.
2506
+ */
2507
+ type Signer = (message: Uint8Array) => Uint8Array | Promise<Uint8Array>;
2508
+ /** PEM text, PEM bytes, a path to a PEM file, or a node KeyObject. */
2509
+ type PrivateKeyInput = string | Uint8Array | KeyObject;
2510
+ /** The string that gets signed: `timestamp + METHOD + path`. */
2511
+ declare function buildMessage(timestampMs: number, method: string, path: string): string;
2512
+ /** Path plus query string of `url`, as the HTTP signature wants it. */
2513
+ declare function requestPath(url: string): string;
2514
+ /** Path of `url` with the query string dropped, as the handshake signature wants it. */
2515
+ declare function handshakePath(url: string): string;
2516
+ /**
2517
+ * Parse a PKCS#8 Ed25519 private key from PEM text, PEM bytes, a path to a
2518
+ * PEM file (`~` expanded), or pass a KeyObject through.
2519
+ */
2520
+ declare function loadPrivateKey(value: PrivateKeyInput): KeyObject;
2521
+ /**
2522
+ * Parse the key once and return a signer. Pure Ed25519 over the message
2523
+ * bytes (a `null` algorithm), not Ed25519ph, which produces a well-formed
2524
+ * signature that never verifies server-side.
2525
+ */
2526
+ declare function signerFromPrivateKey(value: PrivateKeyInput): Signer;
2527
+ /**
2528
+ * An STX API key: the key id sent with every request, and the means of
2529
+ * signing. Build one from a PEM string or path:
2530
+ *
2531
+ * new ApiKeyCredentials("my-key-id", "~/.stx/ontario.pem")
2532
+ *
2533
+ * or from your own signer, for keys held in an HSM or KMS:
2534
+ *
2535
+ * new ApiKeyCredentials("my-key-id", undefined, { signer: (msg) => kms.sign(msg) })
2536
+ *
2537
+ * The private key never leaves the process; only signatures are sent.
2538
+ */
2539
+ declare class ApiKeyCredentials implements AuthProvider {
2540
+ #private;
2541
+ readonly kind = "api_key";
2542
+ readonly keyId: string;
2543
+ constructor(keyId: string, privateKey?: PrivateKeyInput | null, opts?: {
2544
+ signer?: Signer;
2545
+ });
2546
+ /** Raw Ed25519 signature over `message`. */
2547
+ sign(message: Uint8Array): Promise<Uint8Array>;
2548
+ /**
2549
+ * The three signed headers for one request. A fresh timestamp per call
2550
+ * unless `timestampMs` is given (tests): the server rejects anything more
2551
+ * than 30 seconds from its clock, so never cache a signature.
2552
+ */
2553
+ headers(method: string, path: string, timestampMs?: number): Promise<Record<string, string>>;
2554
+ authHeaders(request: AuthRequest): Promise<Record<string, string>>;
2555
+ websocketHeaders(): Promise<Record<string, string>>;
2556
+ toString(): string;
2557
+ }
2558
+
2559
+ declare const VERSION = "0.6.0";
2560
+ declare const USER_AGENT = "stx-typescript/0.6.0";
2561
+ /**
2562
+ * `Symbol.asyncDispose` where the runtime has it (Node 20+, Bun), so
2563
+ * `await using client = new STX()` works there; a registered stand-in on
2564
+ * Node 18, where the method is simply unused.
2565
+ */
2566
+ declare const ASYNC_DISPOSE: symbol;
2567
+
2568
+ /** Order statuses after which an order is no longer open. */
2569
+ declare const TERMINAL_ORDER_STATUSES: ReadonlySet<string>;
2570
+ /** Which part of the view a change touched. */
2571
+ type AccountChangeKind = "balance" | "orders" | "fills" | "positions" | "payment";
2572
+ /** One applied message, passed to `onChange`. */
2573
+ interface AccountChange {
2574
+ kind: AccountChangeKind;
2575
+ /** The wire event, e.g. `update` or `new_open_order`. */
2576
+ event: string;
2577
+ /** True for a join snapshot (first seed or after a reconnect): that part was replaced, not patched. */
2578
+ snapshot: boolean;
2579
+ /** The payload as the exchange sent it: money and quantities are dollar strings. */
2580
+ payload: any;
2581
+ view: AccountView;
2582
+ }
2583
+ /** The view's state as plain data, e.g. to send to a browser. */
2584
+ interface AccountState {
2585
+ /** The latest `balances` summary: `available_balance`, `buy_order_liability`, ... */
2586
+ balance: Record<string, any> | null;
2587
+ /** Open orders, newest first. */
2588
+ openOrders: Record<string, any>[];
2589
+ /** Fills, newest first. */
2590
+ fills: Record<string, any>[];
2591
+ /** Positions, one per market. */
2592
+ positions: Record<string, any>[];
2593
+ }
2594
+ interface AccountViewOptions {
2595
+ /** Restrict orders, fills and positions to these markets. The balance is always the whole account. */
2596
+ marketIds?: readonly string[];
2597
+ /** Which of your accounts the balance is for; omit for your only account. */
2598
+ accountId?: string;
2599
+ /** Called after every applied message, snapshots included. */
2600
+ onChange?: (change: AccountChange) => void;
2601
+ /** Wait this long for the four join snapshots before `accountView()` rejects. Default 15000; `null` waits forever. */
2602
+ snapshotTimeoutMs?: number | null;
2603
+ /** Keep positions whose quantity is zero. Default false: a flat position leaves `positions`. */
2604
+ keepFlatPositions?: boolean;
2605
+ /** The most fills held; the oldest go first. Default 1000. */
2606
+ maxFills?: number;
2607
+ }
2608
+ declare const CHANNELS: readonly ["balances", "orders", "fills", "positions"];
2609
+ /**
2610
+ * A live view of your account. Get one with `ws.accountView()`:
2611
+ *
2612
+ * const ws = await client.websocket().connect();
2613
+ * const view = await ws.accountView({ onChange: (c) => render(c.view.state()) });
2614
+ * view.balance?.available_balance; // "123.4500"
2615
+ * view.openOrders; // [{id, market_id, status, price, ...}]
2616
+ */
2617
+ declare class AccountView {
2618
+ #private;
2619
+ readonly ws: STXWebSocket;
2620
+ onChange: ((change: AccountChange) => void) | undefined;
2621
+ /** The joined channels, by name. */
2622
+ readonly channels: Partial<Record<(typeof CHANNELS)[number], Channel>>;
2623
+ /** Join snapshots applied so far, per channel: 1 after the first seed, more after reconnects. */
2624
+ readonly seeds: Record<string, number>;
2625
+ /** @internal Use `ws.accountView()`. */
2626
+ constructor(ws: STXWebSocket, opts?: AccountViewOptions);
2627
+ /** @internal Join the four channels and wait for their snapshots. */
2628
+ _open(opts: AccountViewOptions): Promise<this>;
2629
+ /** The latest balance summary, or `null` before the first snapshot. */
2630
+ get balance(): Record<string, any> | null;
2631
+ /** Open orders, newest first. */
2632
+ get openOrders(): Record<string, any>[];
2633
+ /** Fills, newest first. */
2634
+ get fills(): Record<string, any>[];
2635
+ /** Positions, one per market. */
2636
+ get positions(): Record<string, any>[];
2637
+ /** True once every channel has delivered its join snapshot. */
2638
+ get ready(): boolean;
2639
+ get closed(): boolean;
2640
+ /** The whole view as plain data. */
2641
+ state(): AccountState;
2642
+ toJSON(): AccountState;
2643
+ /**
2644
+ * Apply one channel message. The view calls this for the channels it
2645
+ * joined; call it yourself to feed messages from an `account:` channel or a
2646
+ * channel you joined elsewhere. Unknown events are ignored.
2647
+ */
2648
+ apply(msg: ChannelMessage | {
2649
+ channel?: string;
2650
+ event: string;
2651
+ payload: any;
2652
+ }): AccountChange | undefined;
2653
+ /** Leave the four channels. The socket stays open. */
2654
+ close(): Promise<void>;
2655
+ }
2656
+
2657
+ /** Events that carry state on join, by channel name (topic prefix). */
2658
+ declare const SNAPSHOT_EVENTS: Readonly<Record<string, readonly string[]>>;
2659
+ /** One pushed frame. */
2660
+ declare class ChannelMessage {
2661
+ /** The wire topic, e.g. `orders:<user_id>`. */
2662
+ readonly topic: string;
2663
+ readonly event: string;
2664
+ /** The event's JSON as documented for the channel; money and quantities are strings. */
2665
+ readonly payload: any;
2666
+ readonly ref: string | null;
2667
+ readonly joinRef: string | null;
2668
+ constructor(
2669
+ /** The wire topic, e.g. `orders:<user_id>`. */
2670
+ topic: string, event: string,
2671
+ /** The event's JSON as documented for the channel; money and quantities are strings. */
2672
+ payload: any, ref?: string | null, joinRef?: string | null);
2673
+ /** The topic without the user id: `"orders"` for `orders:<user_id>`. */
2674
+ get channel(): string;
2675
+ /** True for the state-on-join events (`all_orders`, `balances`, ...). */
2676
+ get isSnapshot(): boolean;
2677
+ }
2678
+ type MessageHandler = (msg: ChannelMessage) => void | Promise<void>;
2679
+ interface ReconnectPolicyOptions {
2680
+ initialBackoffMs?: number;
2681
+ maxBackoffMs?: number;
2682
+ /** `null` (the default) never gives up. */
2683
+ maxAttempts?: number | null;
2684
+ jitter?: boolean;
2685
+ }
2686
+ /** Backoff between reconnect attempts. */
2687
+ declare class ReconnectPolicy {
2688
+ readonly initialBackoffMs: number;
2689
+ readonly maxBackoffMs: number;
2690
+ readonly maxAttempts: number | null;
2691
+ readonly jitter: boolean;
2692
+ constructor(opts?: ReconnectPolicyOptions);
2693
+ delayMs(attempt: number): number;
2694
+ }
2695
+ /** One joined topic. */
2696
+ declare class Channel implements AsyncIterable<ChannelMessage> {
2697
+ #private;
2698
+ /** The wire topic, e.g. `orders:<user_id>`. */
2699
+ readonly topic: string;
2700
+ /** The topic without the user id, e.g. `orders`. */
2701
+ readonly name: string;
2702
+ /** What the next (re)join sends; updated by the `select*` and `watch` helpers so a reconnect keeps them. */
2703
+ joinPayload: Record<string, unknown>;
2704
+ onMessage: MessageHandler | undefined;
2705
+ pingIntervalMs: number | null;
2706
+ /** The `response` object from the latest join reply, e.g. `{selected_market_ids: null}`. */
2707
+ reply: Record<string, any>;
2708
+ /** The latest snapshot payload per snapshot event name. */
2709
+ snapshots: Record<string, any>;
2710
+ /** Market ids watched on `market_updates`; re-sent after a reconnect. */
2711
+ watches: string[];
2712
+ joinRef: string | null;
2713
+ joined: boolean;
2714
+ closed: boolean;
2715
+ constructor(ws: STXWebSocket, topic: string, joinPayload: Record<string, unknown>, onMessage: MessageHandler | undefined, opts: {
2716
+ pingIntervalMs: number | null;
2717
+ queueSize: number;
2718
+ });
2719
+ toString(): string;
2720
+ [Symbol.asyncIterator](): AsyncIterator<ChannelMessage>;
2721
+ /**
2722
+ * The next message on this channel. Rejects with `STXChannelException` if
2723
+ * none arrives within `timeoutMs` or the channel closes.
2724
+ */
2725
+ next(timeoutMs?: number | null): Promise<ChannelMessage>;
2726
+ /**
2727
+ * Wait for the state-on-join and return it as `{event: payload}`. `orders`
2728
+ * gives `{all_orders: {...}}`; `account` waits for all four of its
2729
+ * snapshots. `market_stats` and `market:<id>` return the join reply, which
2730
+ * carries the series or the whole market. Channels with no snapshot (`settlements`, `ticker`, `trades`,
2731
+ * `orderbook`, `markets`, `market_updates`) throw.
2732
+ */
2733
+ waitSnapshot(timeoutMs?: number | null): Promise<Record<string, any>>;
2734
+ /** @internal */
2735
+ _deliver(msg: ChannelMessage): Promise<void>;
2736
+ /** Send `event` on this channel and resolve to the reply's `response`. Rejects when the reply status is `error`. */
2737
+ push(event: string, payload?: unknown, timeoutMs?: number): Promise<any>;
2738
+ /**
2739
+ * Channel `ping`. On `orders` with cancel-on-disconnect armed this resets
2740
+ * the cancel deadline; on `account` and `orders` it keeps the session alive.
2741
+ */
2742
+ ping(): Promise<any>;
2743
+ /**
2744
+ * Change the `market_ids` filter without rejoining. On `orders`, `fills`,
2745
+ * `positions`, `settlements` and `account`, `null` clears the filter;
2746
+ * `orderbook` and `market_stats` require at least one id.
2747
+ */
2748
+ selectMarketIds(marketIds: readonly string[] | null): Promise<any>;
2749
+ /** `ticker` (`sports`, `competitions`) and `trades` (`market_ids`, `event_ids`): change filters without rejoining. */
2750
+ selectFilters(filters: Record<string, readonly string[] | null>): Promise<any>;
2751
+ /** `markets`: change the `rules` filter; `null` disables it. */
2752
+ selectRuleFilters(ruleFilters: readonly string[] | null): Promise<any>;
2753
+ /** `markets`: receive `market_created`, `market_updated` or both. */
2754
+ selectMessageTypes(messageTypes: readonly string[] | null): Promise<any>;
2755
+ /**
2756
+ * `market_updates`: start receiving `created`/`updated` for these markets.
2757
+ * Re-sent automatically after a reconnect.
2758
+ */
2759
+ watch(marketIds: readonly string[]): Promise<any>;
2760
+ /**
2761
+ * `market:<id>`: push the market's current `market_update` and
2762
+ * `order_book_update` again now (after a gap, or to re-read a field).
2763
+ */
2764
+ requestSnapshot(): Promise<any>;
2765
+ /** `market_stats`: fetch history at `range` (`day`, `week`, `month`, `all`) without changing the subscription. */
2766
+ requestSeries(marketIds: readonly string[], range?: string): Promise<any>;
2767
+ /** Leave the topic. The channel stops receiving and its iterator ends. */
2768
+ leave(): Promise<void>;
2769
+ /** @internal */
2770
+ _startPinger(): void;
2771
+ /** @internal */
2772
+ _stopPinger(): void;
2773
+ /** @internal */
2774
+ _resetForRejoin(): void;
2775
+ /** @internal */
2776
+ _close(): void;
2777
+ }
2778
+ /** Where the socket logs. Defaults to `console` for warnings and errors only. */
2779
+ interface Logger {
2780
+ debug(...args: unknown[]): void;
2781
+ info(...args: unknown[]): void;
2782
+ warn(...args: unknown[]): void;
2783
+ error(...args: unknown[]): void;
2784
+ }
2785
+ interface STXWebSocketOptions extends Pick<STXOptions, "environment" | "region" | "env" | "host" | "keyId" | "privateKey" | "signer" | "auth" | "profile" | "verifyTls"> {
2786
+ /** An `STX` client to take host, key and user id from. */
2787
+ rest?: STX;
2788
+ /** Your user id, if you already have it (skips `GET /me`). */
2789
+ userId?: string;
2790
+ /** Milliseconds between socket heartbeats. The server closes a socket silent for 60 s. Default 25000. */
2791
+ heartbeatIntervalMs?: number;
2792
+ /**
2793
+ * Milliseconds between channel `ping` frames on every joined topic; `null`
2794
+ * disables them. `orders` with cancel-on-disconnect pings faster, from the
2795
+ * granted timeout. Default 30000.
2796
+ */
2797
+ channelPingIntervalMs?: number | null;
2798
+ /** Reconnect after a drop. Default true. */
2799
+ reconnect?: boolean;
2800
+ reconnectPolicy?: ReconnectPolicy;
2801
+ /** Called after every successful reconnect and rejoin: the moment to reconcile from REST. */
2802
+ onReconnect?: () => void | Promise<void>;
2803
+ /**
2804
+ * Called when the socket gives up because its credentials are dead: an OAuth
2805
+ * grant was revoked (`STXGrantRevokedException`), or the tokens are gone. The
2806
+ * socket is closed by then; `ws.error` holds the same exception. Send the
2807
+ * member back through consent.
2808
+ */
2809
+ onAuthError?: (err: STXException) => void;
2810
+ /** Milliseconds to wait for a join or push reply. Default 10000. */
2811
+ joinTimeoutMs?: number;
2812
+ /** Messages buffered per channel for iteration; the oldest is dropped when full. Default 10000. */
2813
+ queueSize?: number;
2814
+ logger?: Logger;
2815
+ }
2816
+ /**
2817
+ * Phoenix-channels client for the documented STX topics. Build it from a REST
2818
+ * client, which supplies the host, the key and your user id:
2819
+ *
2820
+ * const client = new STX({ profile: "ontario" });
2821
+ * const ws = await client.websocket().connect();
2822
+ * const book = await ws.orderbook(["<market-id>"], { onMessage: console.log });
2823
+ * const orders = await ws.orders();
2824
+ * console.log(await orders.waitSnapshot());
2825
+ * await ws.runForever();
2826
+ *
2827
+ * or standalone with the same settings options as `STX`.
2828
+ */
2829
+ declare class STXWebSocket {
2830
+ #private;
2831
+ [ASYNC_DISPOSE]: () => Promise<void>;
2832
+ readonly rest: STX;
2833
+ readonly url: string;
2834
+ readonly heartbeatIntervalMs: number;
2835
+ readonly channelPingIntervalMs: number | null;
2836
+ readonly reconnect: boolean;
2837
+ readonly reconnectPolicy: ReconnectPolicy;
2838
+ onReconnect: (() => void | Promise<void>) | undefined;
2839
+ onAuthError: ((err: STXException) => void) | undefined;
2840
+ /** Why the socket closed itself, when it did: a terminal auth failure. */
2841
+ error: STXException | undefined;
2842
+ readonly joinTimeoutMs: number;
2843
+ readonly queueSize: number;
2844
+ readonly logger: Logger;
2845
+ readonly channels: Map<string, Channel>;
2846
+ /** Successful reconnects so far. */
2847
+ reconnects: number;
2848
+ constructor(opts?: STXWebSocketOptions);
2849
+ toString(): string;
2850
+ get connected(): boolean;
2851
+ get closed(): boolean;
2852
+ /** Open the socket. Idempotent; resolves to this socket. */
2853
+ connect(): Promise<this>;
2854
+ /** Leave every channel and close the socket. Safe to call twice. */
2855
+ close(): Promise<void>;
2856
+ /** Resolve once `close()` is called (or reconnects are exhausted). */
2857
+ runForever(): Promise<void>;
2858
+ /** Your user id, from `userId` or `GET /api/v1/me`. */
2859
+ userId(): Promise<string>;
2860
+ /**
2861
+ * `orderbook`: the aggregated book, one `book` push per market. Each push
2862
+ * is a full snapshot of that market's book; replace what you hold rather
2863
+ * than merging. `marketIds` is required.
2864
+ */
2865
+ orderbook(marketIds: readonly string[], opts?: {
2866
+ onMessage?: MessageHandler;
2867
+ }): Promise<Channel>;
2868
+ /** `ticker`: a `ticker` push whenever a market's price, top of book, volume or open interest moves. */
2869
+ ticker(opts?: {
2870
+ sports?: readonly string[];
2871
+ competitions?: readonly string[];
2872
+ onMessage?: MessageHandler;
2873
+ }): Promise<Channel>;
2874
+ /** `trades`: every execution on the exchange, anonymised. `action` is the taker's side. Not your fills: see `fills`. */
2875
+ trades(opts?: {
2876
+ marketIds?: readonly string[];
2877
+ eventIds?: readonly string[];
2878
+ onMessage?: MessageHandler;
2879
+ }): Promise<Channel>;
2880
+ /**
2881
+ * `markets`: `market_created` and `market_updated` for every market. Each
2882
+ * payload maps market id to a market object; `market_updated` carries only
2883
+ * the changed fields. Prices arrive in cents on the wire and are converted
2884
+ * to dollar strings here.
2885
+ */
2886
+ markets(opts?: {
2887
+ ruleFilters?: readonly string[];
2888
+ messageTypes?: readonly string[];
2889
+ onMessage?: MessageHandler;
2890
+ }): Promise<Channel>;
2891
+ /**
2892
+ * `market_stats`: a price series per market. The history is in the join
2893
+ * reply (`channel.reply.markets`); `market_stats` pushes changed buckets
2894
+ * (upsert by `timestamp_us`) and `market_stats_snapshot` replaces a series.
2895
+ */
2896
+ marketStats(marketIds: readonly string[], opts?: {
2897
+ range?: string;
2898
+ onMessage?: MessageHandler;
2899
+ }): Promise<Channel>;
2900
+ /**
2901
+ * `market_updates`: `created` and `updated` for the markets you watch.
2902
+ * Nothing arrives until you watch something; pass `watch` or call
2903
+ * `channel.watch([...])`. Prices are converted from cents to dollar strings.
2904
+ */
2905
+ marketUpdates(opts?: {
2906
+ watch?: readonly string[];
2907
+ onMessage?: MessageHandler;
2908
+ }): Promise<Channel>;
2909
+ /**
2910
+ * `market:<id>`: one market in full. The join reply (`channel.reply`) is the
2911
+ * market's current state, every market field plus `ob`, its aggregated book
2912
+ * (`{b, o}`, each level `{p, q, l, tc, tl}`). Then `market_update` carries the
2913
+ * fields that changed and `order_book_update` a fresh `{ob}` about every
2914
+ * 200 ms. The event's live status text rides along: `event_brief` and
2915
+ * `detailed_event_brief` (the score and clock while in play, e.g.
2916
+ * `"CHC 3 - 4 BOS : Bottom 8th 1 Outs"`, the start time before), with
2917
+ * `event_status`. `marketId` is the market id or symbol. Prices are
2918
+ * converted from cents to dollar strings; book levels are written as strings.
2919
+ * A resulted or voided market sends one last `market_update` and the server
2920
+ * closes the topic.
2921
+ */
2922
+ market(marketId: string, opts?: {
2923
+ onMessage?: MessageHandler;
2924
+ }): Promise<Channel>;
2925
+ /**
2926
+ * `orders:{user_id}`: `all_orders` on join, then `new_open_order`.
2927
+ *
2928
+ * `cancelOnDisconnect: true` arms cancel-on-disconnect for orders placed
2929
+ * with `cancelOnDisconnect: true`. `pingTimeout` is in milliseconds,
2930
+ * clamped by the server to 5000 to 20000; the granted value is in
2931
+ * `channel.reply.ping_timeout` and the SDK pings at 60% of it for as long
2932
+ * as the channel is joined.
2933
+ */
2934
+ orders(opts?: {
2935
+ marketIds?: readonly string[];
2936
+ cancelOnDisconnect?: boolean;
2937
+ pingTimeout?: number;
2938
+ onMessage?: MessageHandler;
2939
+ }): Promise<Channel>;
2940
+ /** `fills:{user_id}`: `all_trades` on join, then one `trade` per execution or status change. */
2941
+ fills(opts?: {
2942
+ marketIds?: readonly string[];
2943
+ onMessage?: MessageHandler;
2944
+ }): Promise<Channel>;
2945
+ /** `positions:{user_id}`: `all_positions` on join, then `updated_positions` deltas with only the changed positions. */
2946
+ positions(opts?: {
2947
+ marketIds?: readonly string[];
2948
+ onMessage?: MessageHandler;
2949
+ }): Promise<Channel>;
2950
+ /** `settlements:{user_id}`: `new_settlements` as they are recorded. No snapshot; history is `STX.settlements()`. */
2951
+ settlements(opts?: {
2952
+ marketIds?: readonly string[];
2953
+ onMessage?: MessageHandler;
2954
+ }): Promise<Channel>;
2955
+ /** `balances:{user_id}`: `balances` on join, then `update` and `payment_update`. `accountId` picks one of your accounts. */
2956
+ balances(opts?: {
2957
+ accountId?: string;
2958
+ onMessage?: MessageHandler;
2959
+ }): Promise<Channel>;
2960
+ /**
2961
+ * `account:{user_id}`: everything the five channels above carry, on one
2962
+ * join. Do not also join a per-type channel (you would get every message
2963
+ * twice), and use `orders` if you need cancel-on-disconnect.
2964
+ */
2965
+ account(opts?: {
2966
+ marketIds?: readonly string[];
2967
+ onMessage?: MessageHandler;
2968
+ }): Promise<Channel>;
2969
+ /**
2970
+ * A live view of your account: joins `balances`, `orders`, `fills` and
2971
+ * `positions`, seeds each from its join snapshot and applies every pushed
2972
+ * update, re-seeding from the new snapshots after a reconnect. Resolves once
2973
+ * all four snapshots have arrived. See `AccountView`.
2974
+ */
2975
+ accountView(opts?: AccountViewOptions): Promise<AccountView>;
2976
+ /** `user_info:{user_id}`: `user_updated` right after joining, then on every profile change. */
2977
+ userInfo(opts?: {
2978
+ onMessage?: MessageHandler;
2979
+ }): Promise<Channel>;
2980
+ /**
2981
+ * Join `topic` with `payload` and wait for the reply. Rejects with
2982
+ * `STXChannelException` carrying the server's reason (for example
2983
+ * `market_ids_required` or `unauthorized`) if the join is refused.
2984
+ */
2985
+ join(topic: string, payload?: Record<string, unknown>, onMessage?: MessageHandler, opts?: {
2986
+ pingIntervalMs?: number | null;
2987
+ }): Promise<Channel>;
2988
+ /** @internal */
2989
+ _leave(channel: Channel): Promise<void>;
2990
+ /** @internal Send a frame and resolve to the reply's `response`. */
2991
+ _request(topic: string, event: string, payload: unknown, joinRef: string | null, timeoutMs?: number, ref?: string): Promise<any>;
2992
+ }
2993
+
2994
+ /** A `fetch`-compatible function. Defaults to the global `fetch` (Node 18+). */
2995
+ type FetchLike = (input: string, init: RequestInit) => Promise<Response>;
2996
+ /** One value or a list, for filters that take several. */
2997
+ type StrList = string | readonly string[];
2998
+ interface STXOptions {
2999
+ /**
3000
+ * A published environment, `Environments.OntarioDemo`, or its name,
3001
+ * `"ontario-demo"`. Instead of `region` + `env`; `host` still wins.
3002
+ */
3003
+ environment?: STXEnvironment | string;
3004
+ /** A known region, e.g. `"ontario"` or `"us"`. With `env`, picks the host. */
3005
+ region?: string | null;
3006
+ /** `"production"` or `"demo"` (`"prod"` and `"live"` are accepted). */
3007
+ env?: string | null;
3008
+ /** A hostname or URL, overriding region/env: `"demo.stxapp.ca"`, `"http://localhost:4000"`. */
3009
+ host?: string | null;
3010
+ /** The API key id. */
3011
+ keyId?: string | null;
3012
+ /** The Ed25519 private key: PEM text, a path to a PEM file, PEM bytes, or a KeyObject. */
3013
+ privateKey?: PrivateKeyInput | null;
3014
+ /** Instead of `privateKey`: signs message bytes, for keys in an HSM or KMS. */
3015
+ signer?: Signer;
3016
+ /**
3017
+ * Instead of an API key: any auth provider, for example an OAuth bearer
3018
+ * adapter from `@stxapp/stx-typescript/oauth`.
3019
+ */
3020
+ auth?: AuthProvider;
3021
+ /** A section of ~/.stx/credentials to read. */
3022
+ profile?: string | null;
3023
+ /**
3024
+ * Set false only for a local server. Honoured by the WebSocket; for REST,
3025
+ * pass a `fetch` whose dispatcher skips verification (Node's global fetch
3026
+ * has no per-call switch).
3027
+ */
3028
+ verifyTls?: boolean | null;
3029
+ /** A `RetryPolicy`; `NO_RETRY` disables retries. */
3030
+ retry?: RetryPolicy;
3031
+ /** Milliseconds per HTTP request. Default 30000. */
3032
+ timeoutMs?: number;
3033
+ /**
3034
+ * A geolocation packet, or a function returning one, sent as `geo_location`
3035
+ * with every order write. Only needed where the exchange is geo-fenced and
3036
+ * this machine's IP address is not whitelisted for the account.
3037
+ */
3038
+ geoLocation?: GeoLocationProvider;
3039
+ /** Inject a fetch implementation (tests, proxies). */
3040
+ fetch?: FetchLike;
3041
+ /**
3042
+ * Called once per HTTP attempt, after it completes or fails: an audit or
3043
+ * activity log hook. Never throws into the request; an exception here is
3044
+ * swallowed.
3045
+ */
3046
+ onResponse?: (event: ResponseEvent) => void;
3047
+ }
3048
+ /** One HTTP attempt, as reported to `onResponse`. */
3049
+ interface ResponseEvent {
3050
+ operationId: OperationId;
3051
+ method: string;
3052
+ /** Path and query, as sent. */
3053
+ path: string;
3054
+ /** HTTP status, or `null` when no response arrived (timeout, network). */
3055
+ status: number | null;
3056
+ /** 1 for the first attempt; higher after a retry or a token refresh. */
3057
+ attempt: number;
3058
+ durationMs: number;
3059
+ /** The auth provider's `kind`: `api_key`, `oauth`, `oauth_app`. */
3060
+ authKind: string | undefined;
3061
+ /**
3062
+ * The request body as sent (JSON text), or `undefined` for a request
3063
+ * without one. Sensitive: it can carry order details and account data. The
3064
+ * SDK passes it through unredacted; redact before storing or displaying it.
3065
+ */
3066
+ requestBody?: string;
3067
+ /**
3068
+ * The response body as received (usually JSON text), or `null` when no
3069
+ * response arrived. Sensitive: it can carry account data, balances and
3070
+ * orders. The SDK passes it through unredacted and untruncated; redact and
3071
+ * trim before storing or displaying it.
3072
+ */
3073
+ responseBody?: string | null;
3074
+ }
3075
+ /** The per-call geolocation override accepted by every order write. */
3076
+ interface GeoOption {
3077
+ /** Overrides the client's `geoLocation` for this call; `null` sends none. */
3078
+ geoLocation?: string | null;
3079
+ }
3080
+ interface MarketsQuery {
3081
+ marketIds?: StrList;
3082
+ eventIds?: StrList;
3083
+ /** One status or a list, e.g. `["pre_open", "open"]`. */
3084
+ status?: StrList;
3085
+ trading?: boolean;
3086
+ sports?: StrList;
3087
+ competitions?: StrList;
3088
+ /** `"event_start"`. */
3089
+ sortBy?: string;
3090
+ sortDirection?: "asc" | "desc";
3091
+ /** Default 100, maximum 200. */
3092
+ limit?: number;
3093
+ cursor?: string;
3094
+ }
3095
+ interface EventsQuery {
3096
+ eventIds?: StrList;
3097
+ sports?: StrList;
3098
+ competitions?: StrList;
3099
+ eventTypes?: StrList;
3100
+ title?: string;
3101
+ /** `scheduled`, `in_progress`, `completed` or `cancelled`. */
3102
+ status?: string;
3103
+ promoted?: boolean;
3104
+ /** `"start_time"`. */
3105
+ sortBy?: string;
3106
+ sortDirection?: "asc" | "desc";
3107
+ limit?: number;
3108
+ cursor?: string;
3109
+ }
3110
+ interface OrdersQuery {
3111
+ orderIds?: StrList;
3112
+ clientOrderIds?: StrList;
3113
+ marketIds?: StrList;
3114
+ /** One status or a list, e.g. `["open", "delayed"]`. */
3115
+ status?: StrList;
3116
+ limit?: number;
3117
+ cursor?: string;
3118
+ }
3119
+ interface FillsQuery {
3120
+ marketIds?: StrList;
3121
+ orderIds?: StrList;
3122
+ /** `created`, `open`, `settled` or `cancelled`. */
3123
+ status?: string;
3124
+ limit?: number;
3125
+ cursor?: string;
3126
+ }
3127
+ interface MarketStatsQuery {
3128
+ marketIds?: StrList;
3129
+ eventIds?: StrList;
3130
+ excludeZeroSettlements?: boolean;
3131
+ fromTime?: number;
3132
+ toTime?: number;
3133
+ sports?: StrList;
3134
+ competitions?: StrList;
3135
+ limit?: number;
3136
+ cursor?: string;
3137
+ }
3138
+ interface SettlementsQuery {
3139
+ marketIds?: StrList;
3140
+ /** `closed_short`, `closed_long`, `expired_short` or `expired_long`. */
3141
+ type?: string;
3142
+ limit?: number;
3143
+ cursor?: string;
3144
+ }
3145
+ interface PageQuery {
3146
+ limit?: number;
3147
+ cursor?: string;
3148
+ }
3149
+ type WithoutCursor<T> = Omit<T, "cursor">;
3150
+ /** The optional fields of one new order. */
3151
+ interface OrderOptions extends GeoOption {
3152
+ /** Dollars, as a decimal string: `"0.56"`. Required for a limit order. */
3153
+ price?: string;
3154
+ /** Contracts, as a decimal string: `"2"`. */
3155
+ quantity: string;
3156
+ clientOrderId?: string;
3157
+ /** `"good_till_start"` or `"good_till_time"`. */
3158
+ expiration?: string;
3159
+ /** Unix **microseconds**, with `expiration: "good_till_time"`. */
3160
+ expirationTime?: number;
3161
+ cancelOnDisconnect?: boolean;
3162
+ deviceId?: string;
3163
+ }
3164
+ /** One order in a `placeOrders` batch. */
3165
+ interface NewOrderInput extends Omit<OrderOptions, "geoLocation"> {
3166
+ marketId: string;
3167
+ /** `"buy"` or `"sell"`. */
3168
+ action: string;
3169
+ /** `"limit"` or `"market"`. */
3170
+ orderType: string;
3171
+ }
3172
+ interface AcceptTermsOptions {
3173
+ acceptTerms?: boolean;
3174
+ acceptPrivacy?: boolean;
3175
+ acceptHouseRules?: boolean;
3176
+ }
3177
+ /** The JSON body for one new order. Fields left undefined are omitted. */
3178
+ declare function orderBody(marketId: string, action: string, orderType: string, opts: Omit<OrderOptions, "geoLocation">): Record<string, unknown>;
3179
+ /**
3180
+ * The STX REST client. Configuration comes from the options, then
3181
+ * environment variables, then a profile in ~/.stx/credentials:
3182
+ *
3183
+ * const client = new STX({ profile: "ontario-production" });
3184
+ * const me = await client.me();
3185
+ * const page = await client.markets({ status: "open", limit: 10 });
3186
+ */
3187
+ declare class STX {
3188
+ #private;
3189
+ [ASYNC_DISPOSE]: () => Promise<void>;
3190
+ readonly baseUrl: string;
3191
+ readonly socketUrl: string;
3192
+ readonly profile: string;
3193
+ /** The API key, when one is configured. */
3194
+ readonly credentials: ApiKeyCredentials | undefined;
3195
+ /** What authenticates requests: the API key, or the `auth` option. */
3196
+ readonly auth: AuthProvider | undefined;
3197
+ readonly verifyTls: boolean;
3198
+ readonly retry: RetryPolicy;
3199
+ readonly timeoutMs: number;
3200
+ geoLocation: GeoLocationProvider | undefined;
3201
+ onResponse: ((event: ResponseEvent) => void) | undefined;
3202
+ /** Test hook: how retries wait. */
3203
+ _sleep: (ms: number) => Promise<void>;
3204
+ constructor(opts?: STXOptions);
3205
+ toString(): string;
3206
+ /** Nothing to release (fetch pools connections itself); present so `await using` and explicit cleanup work. */
3207
+ close(): Promise<void>;
3208
+ /**
3209
+ * `GET /api/v1/me`: who this key belongs to. Returns the `user_id` the
3210
+ * account channels are keyed by, the `account_id`, and the key's `scope`
3211
+ * (`read_only` or `read_write`).
3212
+ */
3213
+ me(): Promise<Me>;
3214
+ /**
3215
+ * The user id from `me()`, fetched once and cached. An OAuth token granted
3216
+ * without `profile.read` cannot call `me()`; the id then comes from
3217
+ * `balance()` (`balance.read`), which carries the same `user_id`.
3218
+ */
3219
+ userId(): Promise<string>;
3220
+ /**
3221
+ * `GET /api/v1/markets`: one page of markets. Filters combine with AND;
3222
+ * list filters match any value.
3223
+ */
3224
+ markets(query?: MarketsQuery): Promise<Page<Market>>;
3225
+ /** Every market matching the filters, following the cursor. */
3226
+ iterMarkets(query?: WithoutCursor<MarketsQuery>): AsyncGenerator<Market, void, undefined>;
3227
+ /** One market by id. Throws `STXNotFoundException` if there is none. */
3228
+ market(marketId: string): Promise<Market>;
3229
+ /** `GET /api/v1/events`: one page of events. */
3230
+ events(query?: EventsQuery): Promise<Page<Event>>;
3231
+ /** Every event matching the filters, following the cursor. */
3232
+ iterEvents(query?: WithoutCursor<EventsQuery>): AsyncGenerator<Event, void, undefined>;
3233
+ /** `GET /api/v1/orders`: one page of your orders, newest first. */
3234
+ orders(query?: OrdersQuery): Promise<Page<Order>>;
3235
+ /** Every order matching the filters, following the cursor. */
3236
+ iterOrders(query?: WithoutCursor<OrdersQuery>): AsyncGenerator<Order, void, undefined>;
3237
+ /** `GET /api/v1/orders/{order_id}`: one of your orders. */
3238
+ order(orderId: string): Promise<Order>;
3239
+ /**
3240
+ * `POST /api/v1/orders`: place one order.
3241
+ *
3242
+ * `action` is `"buy"` or `"sell"`; `orderType` is `"limit"` or `"market"`.
3243
+ * `price` (dollars, required for a limit order) and `quantity` (contracts)
3244
+ * are decimal strings, e.g. `{ price: "0.56", quantity: "2" }`. Numbers are
3245
+ * refused client-side.
3246
+ *
3247
+ * The exchange validates the order: a bad price step or a fractional
3248
+ * quantity throws `STXValidationException` (400) or `STXRejectedException`
3249
+ * (422) with the API's message; a geo-fencing refusal throws
3250
+ * `STXGeoLocationException`.
3251
+ *
3252
+ * A POST is never retried after a 5xx or a dropped connection; pass
3253
+ * `clientOrderId` so you can look the order up if that happens.
3254
+ */
3255
+ placeOrder(marketId: string, action: string, orderType: string, opts: OrderOptions): Promise<Order>;
3256
+ /**
3257
+ * `POST /api/v1/orders/batched`: place several orders in one call. One geo
3258
+ * check covers the batch. Returns one result per order, in order; a
3259
+ * rejected order has `errors` instead of `order` and does not stop the
3260
+ * others.
3261
+ */
3262
+ placeOrders(orders: readonly NewOrderInput[], opts?: GeoOption): Promise<BatchOrderResult[]>;
3263
+ /**
3264
+ * `DELETE /api/v1/orders/{order_id}`: request a cancel. A cancel is a
3265
+ * request: a fill already in flight can still land.
3266
+ */
3267
+ cancelOrder(orderId: string, opts?: GeoOption): Promise<Cancellation>;
3268
+ /** `DELETE /api/v1/orders/batched`: cancel the named orders. */
3269
+ cancelOrders(orderIds: readonly string[], opts?: GeoOption): Promise<Cancellation[]>;
3270
+ /** `DELETE /api/v1/orders/all`: cancel everything resting on the account. */
3271
+ cancelAllOrders(opts?: GeoOption): Promise<Cancellation[]>;
3272
+ /**
3273
+ * Ask the exchange whether this machine may trade right now, without
3274
+ * placing or cancelling anything.
3275
+ *
3276
+ * Sends `DELETE /api/v1/orders/00000000-0000-0000-0000-000000000000` (an
3277
+ * order id that cannot exist) with the geolocation packet, if one is
3278
+ * configured. The exchange runs its geo check before it looks the order
3279
+ * up, so a 404 means the check passed, and a geo 422 means it did not. On
3280
+ * an exchange without geo-fencing it always passes.
3281
+ *
3282
+ * Needs a `read_write` key (the probe is a write route). The exchange
3283
+ * records a failed check in its geolocation log exactly as it would a real
3284
+ * order from the same place, and may raise a compliance alert, so call it
3285
+ * once at start-up, not in a loop.
3286
+ */
3287
+ geoCheck(opts?: GeoOption): Promise<GeoCheckResult>;
3288
+ /** `GET /api/v1/fills`: one page of your executions. */
3289
+ fills(query?: FillsQuery): Promise<Page<Fill>>;
3290
+ /** Every fill matching the filters, following the cursor. */
3291
+ iterFills(query?: WithoutCursor<FillsQuery>): AsyncGenerator<Fill, void, undefined>;
3292
+ /**
3293
+ * `GET /api/v1/positions`: your open positions, the same objects the
3294
+ * `positions` channel sends on join. `position` is positive when long,
3295
+ * negative when short.
3296
+ */
3297
+ positions(query?: {
3298
+ marketIds?: StrList;
3299
+ }): Promise<Position[]>;
3300
+ /**
3301
+ * `GET /api/v1/account/balance`: balance, liabilities and fee schedule.
3302
+ * The same object the `balances` channel pushes.
3303
+ */
3304
+ balance(): Promise<Balance>;
3305
+ /**
3306
+ * `GET /api/v1/account/market_stats`: your exposure and P&L per market.
3307
+ * Not the public `market_stats` channel, which carries prices.
3308
+ */
3309
+ accountMarketStats(query?: MarketStatsQuery): Promise<Page<MarketStat>>;
3310
+ /** Every per-market stat row, following the cursor. */
3311
+ iterAccountMarketStats(query?: WithoutCursor<MarketStatsQuery>): AsyncGenerator<MarketStat, void, undefined>;
3312
+ /** `GET /api/v1/portfolio/settlements`: settlements on your account. */
3313
+ settlements(query?: SettlementsQuery): Promise<Page<Settlement>>;
3314
+ /** Every settlement, following the cursor. */
3315
+ iterSettlements(query?: WithoutCursor<SettlementsQuery>): AsyncGenerator<Settlement, void, undefined>;
3316
+ /** `GET /api/v1/portfolio/deposits`. */
3317
+ deposits(query?: PageQuery): Promise<Page<PaymentTransaction>>;
3318
+ /** Every deposit, following the cursor. */
3319
+ iterDeposits(query?: {
3320
+ limit?: number;
3321
+ }): AsyncGenerator<PaymentTransaction, void, undefined>;
3322
+ /** `GET /api/v1/portfolio/withdrawals`. */
3323
+ withdrawals(query?: PageQuery): Promise<Page<PaymentTransaction>>;
3324
+ /** Every withdrawal, following the cursor. */
3325
+ iterWithdrawals(query?: {
3326
+ limit?: number;
3327
+ }): AsyncGenerator<PaymentTransaction, void, undefined>;
3328
+ /** `GET /api/v1/portfolio/adjustments`: manual balance adjustments. */
3329
+ adjustments(query?: PageQuery): Promise<Page<PaymentTransaction>>;
3330
+ /** Every adjustment, following the cursor. */
3331
+ iterAdjustments(query?: {
3332
+ limit?: number;
3333
+ }): AsyncGenerator<PaymentTransaction, void, undefined>;
3334
+ /** `GET /api/v1/portfolio/fees`: fee and fee-refund entries. */
3335
+ fees(query?: PageQuery): Promise<Page<FeeTransaction>>;
3336
+ /** Every fee entry, following the cursor. */
3337
+ iterFees(query?: {
3338
+ limit?: number;
3339
+ }): AsyncGenerator<FeeTransaction, void, undefined>;
3340
+ /** `GET /api/v1/portfolio/loyalty`: loyalty entries. */
3341
+ loyalty(query?: PageQuery): Promise<Page<Transaction>>;
3342
+ /** Every loyalty entry, following the cursor. */
3343
+ iterLoyalty(query?: {
3344
+ limit?: number;
3345
+ }): AsyncGenerator<Transaction, void, undefined>;
3346
+ /** `POST /api/v1/tnc/accept`: accept the current terms. Resolves to the server's message. */
3347
+ acceptTerms(deviceId: string, opts?: AcceptTermsOptions): Promise<string>;
3348
+ /**
3349
+ * An `STXWebSocket` using this client's host and key. Account channels
3350
+ * need your user id; the socket fetches it through `me()` on first use.
3351
+ */
3352
+ websocket(opts?: Omit<STXWebSocketOptions, "rest">): STXWebSocket;
3353
+ }
3354
+
3355
+ export { ReconnectPolicy as $, type AcceptTermsOptions as A, type Balance as B, type Cancellation as C, type Me as D, Environment as E, type FeeTransaction as F, type GeoCheckResult as G, HOSTS as H, type MessageHandler as I, type NewOrder as J, KEY_HEADER as K, type Logger as L, type Market as M, NO_RETRY as N, type NewOrderInput as O, OPERATIONS as P, type Operation as Q, type OperationId as R, type Order as S, type OrderOptions as T, type OrdersQuery as U, Page as V, type PageQuery as W, type PaymentTransaction as X, type Position as Y, type PrivateKeyInput as Z, type RecentTrade as _, type AccountChange as a, type ReconnectPolicyOptions as a0, Region as a1, type ResponseEvent as a2, RetryPolicy as a3, type RetryPolicyOptions as a4, SIGNATURE_HEADER as a5, SNAPSHOT_EVENTS as a6, STX as a7, STXAPIException as a8, STXAuthenticationException as a9, USER_AGENT as aA, VERSION as aB, type WebSocketAuthContext as aC, baseUrlFor as aD, buildMessage as aE, environmentNamed as aF, errorForStatus as aG, geoRejection as aH, handshakePath as aI, loadPrivateKey as aJ, models as aK, orderBody as aL, requestPath as aM, resolveHost as aN, signerFromPrivateKey as aO, socketUrlFor as aP, STXChannelException as aa, STXConfigException as ab, type STXEnvironment as ac, STXException as ad, STXForbiddenException as ae, STXGeoLocationException as af, STXInsufficientScopeException as ag, STXInvalidTokenException as ah, STXNotFoundException as ai, type STXOptions as aj, STXRateLimitException as ak, STXRejectedException as al, STXServerException as am, STXTimeoutException as an, STXTransportException as ao, STXValidationException as ap, STXWebSocket as aq, type STXWebSocketOptions as ar, type Settlement as as, type SettlementsQuery as at, type Signer as au, type StatDetail as av, type StrList as aw, TERMINAL_ORDER_STATUSES as ax, TIMESTAMP_HEADER as ay, type Transaction as az, type AccountChangeKind as b, type AccountState as c, AccountView as d, type AccountViewOptions as e, ApiKeyCredentials as f, type AuthProvider as g, type AuthRequest as h, type BatchOrderResult as i, type BookLevel as j, Channel as k, ChannelMessage as l, Environments as m, type Error$1 as n, type Event as o, type EventsQuery as p, type FetchLike as q, type Fill as r, type FillsQuery as s, type GeoLocationProvider as t, type GeoOption as u, type GeoRejection as v, type MarketFilter as w, type MarketStat as x, type MarketStatsQuery as y, type MarketsQuery as z };