@stxapp/stx-typescript 0.9.0-alpha.1 → 0.9.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.
- package/CHANGELOG.md +46 -16
- package/README.md +27 -24
- package/dist/{chunk-4CSBA2YV.js → chunk-46XK6VDD.js} +778 -44
- package/dist/chunk-46XK6VDD.js.map +1 -0
- package/dist/{chunk-33AQCUGM.cjs → chunk-R77AZ5UH.cjs} +840 -106
- package/dist/chunk-R77AZ5UH.cjs.map +1 -0
- package/dist/{client-CNkaTuhG.d.ts → client-B-MMKiRt.d.cts} +645 -43
- package/dist/{client-CNkaTuhG.d.cts → client-B-MMKiRt.d.ts} +645 -43
- package/dist/index.cjs +24 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +23 -1
- package/dist/oauth.cjs +244 -107
- package/dist/oauth.cjs.map +1 -1
- package/dist/oauth.d.cts +115 -15
- package/dist/oauth.d.ts +115 -15
- package/dist/oauth.js +206 -69
- package/dist/oauth.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-33AQCUGM.cjs.map +0 -1
- package/dist/chunk-4CSBA2YV.js.map +0 -1
|
@@ -30,6 +30,46 @@ interface WebSocketAuthContext {
|
|
|
30
30
|
reconnect?: boolean;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
/** The features `STX.capabilities()` reports, by stable id. */
|
|
34
|
+
declare const FEATURES: readonly ["oauth", "oauth.member", "oauth.app", "connect", "terms.stx_page", "markets.create", "market_types", "event_players", "leaderboard", "combos"];
|
|
35
|
+
/** A feature id `STX.capabilities()` reports. */
|
|
36
|
+
type Feature = (typeof FEATURES)[number];
|
|
37
|
+
/**
|
|
38
|
+
* Per feature: `true` (the exchange has it), `false` (it does not), or `null`
|
|
39
|
+
* (not known: the check needs credentials this client does not have, or the
|
|
40
|
+
* exchange did not answer).
|
|
41
|
+
*/
|
|
42
|
+
type FeatureMap = Record<Feature, boolean | null>;
|
|
43
|
+
/** What `STX.capabilities()` found on one exchange. */
|
|
44
|
+
declare class Capabilities {
|
|
45
|
+
/** The exchange host, e.g. `"demo.stxapp.io"`. */
|
|
46
|
+
readonly host: string;
|
|
47
|
+
/** `GET /api_version`, e.g. `"3.3.196-rnd.9"`, or null when it did not answer. */
|
|
48
|
+
readonly apiVersion: string | null;
|
|
49
|
+
/** When the checks ran. */
|
|
50
|
+
readonly checkedAt: Date;
|
|
51
|
+
/** The scopes the exchange's OAuth discovery document lists; empty without OAuth. */
|
|
52
|
+
readonly scopesSupported: readonly string[];
|
|
53
|
+
/** Every feature and whether the exchange has it. */
|
|
54
|
+
readonly features: Readonly<FeatureMap>;
|
|
55
|
+
constructor(init: {
|
|
56
|
+
host: string;
|
|
57
|
+
apiVersion: string | null;
|
|
58
|
+
checkedAt: Date;
|
|
59
|
+
scopesSupported: readonly string[];
|
|
60
|
+
features: FeatureMap;
|
|
61
|
+
});
|
|
62
|
+
/** True only when the exchange is known to have `feature`. */
|
|
63
|
+
has(feature: Feature): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Throw `STXNotAvailableException` unless the exchange is known to have
|
|
66
|
+
* `feature`. A feature that could not be checked (`null`) does not throw:
|
|
67
|
+
* the call itself will say.
|
|
68
|
+
*/
|
|
69
|
+
require(feature: Feature): void;
|
|
70
|
+
toJSON(): Record<string, unknown>;
|
|
71
|
+
}
|
|
72
|
+
|
|
33
73
|
declare const Region: {
|
|
34
74
|
readonly US: "us";
|
|
35
75
|
readonly ONTARIO: "ontario";
|
|
@@ -252,7 +292,7 @@ interface EventPlayers {
|
|
|
252
292
|
stats: EventStat[];
|
|
253
293
|
[key: string]: unknown;
|
|
254
294
|
}
|
|
255
|
-
/**
|
|
295
|
+
/** The stats one event type offers, in `STX.marketTypes()`. */
|
|
256
296
|
interface MarketTypeEventType {
|
|
257
297
|
/** The sport, e.g. `"Football"`. */
|
|
258
298
|
sport: string;
|
|
@@ -292,9 +332,13 @@ type MarketTypes = {
|
|
|
292
332
|
} & {
|
|
293
333
|
[rule: string]: MarketType;
|
|
294
334
|
};
|
|
295
|
-
/**
|
|
296
|
-
interface
|
|
297
|
-
|
|
335
|
+
/** One market to create. */
|
|
336
|
+
interface NewMarketInput {
|
|
337
|
+
/**
|
|
338
|
+
* The market rule. `"player_stat_line"`, the only one today and the default;
|
|
339
|
+
* the exchange answers any other with `unsupported_rule`.
|
|
340
|
+
*/
|
|
341
|
+
rule?: "player_stat_line" | (string & {});
|
|
298
342
|
/** From `eventPlayers()`. */
|
|
299
343
|
playerId: string;
|
|
300
344
|
/** One of the event's stats, e.g. `Stats.Basketball.POINTS`. */
|
|
@@ -305,61 +349,76 @@ interface PlayerStatLineMarket {
|
|
|
305
349
|
* are rejected with `invalid_line`.
|
|
306
350
|
*/
|
|
307
351
|
line: number;
|
|
352
|
+
/**
|
|
353
|
+
* @deprecated Not sent. A player stat line is always over/under.
|
|
354
|
+
*/
|
|
355
|
+
propType?: "ou";
|
|
308
356
|
}
|
|
357
|
+
/** A player stat line: over/under one player's stat in one event. The same shape as `NewMarketInput`. */
|
|
358
|
+
type PlayerStatLineMarket = NewMarketInput;
|
|
309
359
|
/**
|
|
310
360
|
* One market to create. `rule` names the market type and decides the other
|
|
311
361
|
* fields; `STX.marketTypes()` lists the rules an app can create. Player stat
|
|
312
362
|
* lines are the only one today.
|
|
313
363
|
*/
|
|
314
|
-
type NewMarket =
|
|
364
|
+
type NewMarket = NewMarketInput;
|
|
315
365
|
/** A rule `STX.createMarkets()` takes. */
|
|
316
|
-
type MarketRule =
|
|
366
|
+
type MarketRule = NonNullable<NewMarketInput["rule"]>;
|
|
317
367
|
/** Why a market was not created. */
|
|
318
368
|
type MarketRejectionReason = "invalid_market" | "unsupported_rule" | "unsupported_stat" | "invalid_line" | "unknown_player" | "event_not_open" | "not_created" | (string & {});
|
|
369
|
+
/** The market a result is for, as it was requested. */
|
|
370
|
+
interface MarketRequestEcho {
|
|
371
|
+
rule?: string;
|
|
372
|
+
player_id?: string;
|
|
373
|
+
stat?: string;
|
|
374
|
+
line?: number;
|
|
375
|
+
[key: string]: unknown;
|
|
376
|
+
}
|
|
319
377
|
/**
|
|
320
378
|
* The outcome for one requested market. `index` is the market's position in
|
|
321
|
-
* the list given to `createMarkets()
|
|
379
|
+
* the list given to `createMarkets()`, and `market` is that market as
|
|
380
|
+
* requested.
|
|
322
381
|
*/
|
|
323
382
|
type CreateMarketResult = {
|
|
324
383
|
index: number;
|
|
325
384
|
status: "created";
|
|
326
385
|
market_id: string;
|
|
327
386
|
reason: null;
|
|
328
|
-
|
|
387
|
+
market: MarketRequestEcho;
|
|
329
388
|
} | {
|
|
330
389
|
index: number;
|
|
331
390
|
status: "exists";
|
|
332
391
|
market_id: string;
|
|
333
392
|
reason: null;
|
|
334
|
-
|
|
393
|
+
market: MarketRequestEcho;
|
|
335
394
|
} | {
|
|
336
395
|
index: number;
|
|
337
396
|
status: "valid";
|
|
338
397
|
market_id: null;
|
|
339
398
|
reason: null;
|
|
340
|
-
|
|
399
|
+
market: MarketRequestEcho;
|
|
341
400
|
} | {
|
|
342
401
|
index: number;
|
|
343
402
|
status: "rejected";
|
|
344
403
|
market_id: null;
|
|
345
404
|
reason: MarketRejectionReason;
|
|
346
|
-
|
|
405
|
+
market: MarketRequestEcho;
|
|
347
406
|
};
|
|
348
407
|
/** Options for `STX.createMarkets()`. */
|
|
349
408
|
interface CreateMarketsOptions {
|
|
350
409
|
/**
|
|
351
|
-
*
|
|
352
|
-
*
|
|
410
|
+
* Check each market against the event's players and stats, and the line
|
|
411
|
+
* rule, before sending. Failing markets come back `rejected` without a
|
|
412
|
+
* request; the rest are sent with the event's own stat key. The exchange
|
|
413
|
+
* checks every market either way. Reads `eventPlayers()`, so the token also
|
|
414
|
+
* needs the `events` scope.
|
|
353
415
|
*/
|
|
354
|
-
|
|
416
|
+
validate?: boolean;
|
|
355
417
|
/**
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
* without a request; the rest are sent with the event's own stat key. The
|
|
359
|
-
* exchange checks every market either way. Reads `eventPlayers()`, so the
|
|
360
|
-
* token also needs the `events` scope.
|
|
418
|
+
* Run every check on the exchange and create nothing. A market that would
|
|
419
|
+
* be created, or a repeat of one, comes back `valid`.
|
|
361
420
|
*/
|
|
362
|
-
|
|
421
|
+
dryRun?: boolean;
|
|
363
422
|
}
|
|
364
423
|
/** The most markets one `createMarkets()` call takes. */
|
|
365
424
|
declare const MAX_MARKETS_PER_REQUEST = 25;
|
|
@@ -2911,6 +2970,29 @@ declare class STXInvalidTokenException extends STXAuthenticationException {
|
|
|
2911
2970
|
*/
|
|
2912
2971
|
declare class STXInsufficientScopeException extends STXForbiddenException {
|
|
2913
2972
|
}
|
|
2973
|
+
/**
|
|
2974
|
+
* 403 on an OAuth bearer request: the member has not accepted the current STX
|
|
2975
|
+
* terms, so the exchange places no orders for them through an app
|
|
2976
|
+
* (`{"error": "terms_required", "terms_url": "..."}`). The connection and the
|
|
2977
|
+
* tokens are fine, and reads and cancels keep working. Send the member's
|
|
2978
|
+
* browser to `termsUrl` (see `termsUrlWithReturn()`); once they have agreed on
|
|
2979
|
+
* the STX page, the same call works with the same tokens.
|
|
2980
|
+
*/
|
|
2981
|
+
declare class STXTermsRequiredException extends STXForbiddenException {
|
|
2982
|
+
/** The STX page where the member accepts the terms, when the answer names it. */
|
|
2983
|
+
readonly termsUrl: string | undefined;
|
|
2984
|
+
constructor(message: string, opts?: STXExceptionOptions & {
|
|
2985
|
+
termsUrl?: string;
|
|
2986
|
+
});
|
|
2987
|
+
}
|
|
2988
|
+
/**
|
|
2989
|
+
* 403 on an OAuth bearer request: the token is fine, but the app's IP
|
|
2990
|
+
* allow-list does not include the address this write came from
|
|
2991
|
+
* (`{"error": "ip_not_allowed"}`). Reads keep working. Send writes from an
|
|
2992
|
+
* address on the allow-list you gave STX for this app. Never retried.
|
|
2993
|
+
*/
|
|
2994
|
+
declare class STXIPNotAllowedException extends STXForbiddenException {
|
|
2995
|
+
}
|
|
2914
2996
|
/** 404: the resource does not exist, or belongs to another account. */
|
|
2915
2997
|
declare class STXNotFoundException extends STXAPIException {
|
|
2916
2998
|
}
|
|
@@ -2970,6 +3052,91 @@ declare class STXChannelException extends STXException {
|
|
|
2970
3052
|
*/
|
|
2971
3053
|
declare class STXTimeoutException extends STXChannelException {
|
|
2972
3054
|
}
|
|
3055
|
+
/** The sentence an `STXNotAvailableException` carries: `Combos are not available on demo.stxapp.ca yet.` */
|
|
3056
|
+
declare function notAvailableMessage(feature: string, host: string): string;
|
|
3057
|
+
/**
|
|
3058
|
+
* This exchange does not have the feature yet: combos on an exchange without
|
|
3059
|
+
* them, OAuth where it is not switched on, a scope the exchange does not offer
|
|
3060
|
+
* in its jurisdiction. Nothing is wrong with the request or the credentials,
|
|
3061
|
+
* and nothing else is affected; the same call works on an exchange that has
|
|
3062
|
+
* the feature. `STX.capabilities()` says up front which features an exchange
|
|
3063
|
+
* has.
|
|
3064
|
+
*
|
|
3065
|
+
* `feature` is a stable id (`oauth`, `oauth.member`, `oauth.app`, `connect`,
|
|
3066
|
+
* `terms.stx_page`, `markets.create`, `market_types`, `event_players`,
|
|
3067
|
+
* `leaderboard`, `combos`, or `scope:<name>`); `host` is the exchange that answered.
|
|
3068
|
+
* `statusCode` and `body` are the HTTP answer the decision came from, when
|
|
3069
|
+
* there was one.
|
|
3070
|
+
*/
|
|
3071
|
+
declare class STXNotAvailableException extends STXAPIException {
|
|
3072
|
+
/** The feature id, e.g. `"combos"`. */
|
|
3073
|
+
readonly feature: string;
|
|
3074
|
+
/** The exchange host that lacks it, e.g. `"demo.stxapp.ca"`. */
|
|
3075
|
+
readonly host: string;
|
|
3076
|
+
constructor(feature: string, host: string, opts?: STXExceptionOptions & {
|
|
3077
|
+
message?: string;
|
|
3078
|
+
});
|
|
3079
|
+
static [Symbol.hasInstance](value: unknown): boolean;
|
|
3080
|
+
}
|
|
3081
|
+
/**
|
|
3082
|
+
* Combos are not available on this exchange: it refused the join to the
|
|
3083
|
+
* player or maker topic with `unmatched topic`. Nothing else is affected.
|
|
3084
|
+
*
|
|
3085
|
+
* A channel exception, as before, and also an `STXNotAvailableException`
|
|
3086
|
+
* (`instanceof` is true for both), with `feature` `"combos"` and `host`.
|
|
3087
|
+
*/
|
|
3088
|
+
declare class STXCombosUnavailableException extends STXChannelException {
|
|
3089
|
+
readonly feature = "combos";
|
|
3090
|
+
/** The exchange host that lacks combos. */
|
|
3091
|
+
readonly host: string;
|
|
3092
|
+
constructor(message: string, opts?: {
|
|
3093
|
+
topic?: string;
|
|
3094
|
+
reply?: unknown;
|
|
3095
|
+
host?: string;
|
|
3096
|
+
});
|
|
3097
|
+
}
|
|
3098
|
+
/**
|
|
3099
|
+
* The exchange refused a combo command or join. `code` is the refusal
|
|
3100
|
+
* (`not_found`, `insufficient_assets`, `player_refused`, ...); for
|
|
3101
|
+
* `player_refused:<reason>` the part after the first colon is in `detail`.
|
|
3102
|
+
* `command` is the event that was refused, e.g. `accept`. `reason` (from
|
|
3103
|
+
* `STXChannelException`) is the full string as sent.
|
|
3104
|
+
*/
|
|
3105
|
+
declare class STXComboRefusedException extends STXChannelException {
|
|
3106
|
+
readonly command: string;
|
|
3107
|
+
readonly code: string;
|
|
3108
|
+
readonly detail: string | undefined;
|
|
3109
|
+
constructor(message: string, opts: {
|
|
3110
|
+
topic?: string;
|
|
3111
|
+
reply?: unknown;
|
|
3112
|
+
command: string;
|
|
3113
|
+
code: string;
|
|
3114
|
+
detail?: string;
|
|
3115
|
+
});
|
|
3116
|
+
}
|
|
3117
|
+
/**
|
|
3118
|
+
* `accept` found nothing live at the accepted amount or better. The request
|
|
3119
|
+
* stays open. `best` is the live best quote now; its fields are null when
|
|
3120
|
+
* nothing is live. Accept again at `best.amount` to take it.
|
|
3121
|
+
*/
|
|
3122
|
+
declare class STXComboPriceMovedException extends STXComboRefusedException {
|
|
3123
|
+
readonly best: {
|
|
3124
|
+
quote_id: string | null;
|
|
3125
|
+
amount: string | null;
|
|
3126
|
+
expires_at: number | null;
|
|
3127
|
+
};
|
|
3128
|
+
constructor(message: string, opts: {
|
|
3129
|
+
topic?: string;
|
|
3130
|
+
reply?: unknown;
|
|
3131
|
+
command: string;
|
|
3132
|
+
code: string;
|
|
3133
|
+
best: {
|
|
3134
|
+
quote_id: string | null;
|
|
3135
|
+
amount: string | null;
|
|
3136
|
+
expires_at: number | null;
|
|
3137
|
+
};
|
|
3138
|
+
});
|
|
3139
|
+
}
|
|
2973
3140
|
/** Build the exception for one non-2xx response. */
|
|
2974
3141
|
declare function errorForStatus(statusCode: number, body: unknown, opts: {
|
|
2975
3142
|
method: string;
|
|
@@ -3071,8 +3238,8 @@ declare class ApiKeyCredentials implements AuthProvider {
|
|
|
3071
3238
|
toString(): string;
|
|
3072
3239
|
}
|
|
3073
3240
|
|
|
3074
|
-
declare const VERSION = "0.9.0
|
|
3075
|
-
declare const USER_AGENT = "stx-typescript/0.9.0
|
|
3241
|
+
declare const VERSION = "0.9.0";
|
|
3242
|
+
declare const USER_AGENT = "stx-typescript/0.9.0";
|
|
3076
3243
|
/**
|
|
3077
3244
|
* `Symbol.asyncDispose` where the runtime has it (Node 20+, Bun), so
|
|
3078
3245
|
* `await using client = new STX()` works there; a registered stand-in on
|
|
@@ -3126,8 +3293,10 @@ declare const CHANNELS: readonly ["balances", "orders", "fills", "positions"];
|
|
|
3126
3293
|
*
|
|
3127
3294
|
* const ws = await client.websocket().connect();
|
|
3128
3295
|
* const view = await ws.accountView({ onChange: (c) => render(c.view.state()) });
|
|
3129
|
-
* view.balance?.available_balance; // "
|
|
3130
|
-
* view.openOrders;
|
|
3296
|
+
* view.balance?.available_balance; // "746.8600"
|
|
3297
|
+
* view.openOrders[0]?.id; // "4702e9b6-211a-4805-a605-0eb0817ee9b3"
|
|
3298
|
+
* view.openOrders[0]?.status; // "open"
|
|
3299
|
+
* view.openOrders[0]?.price; // "0.5800"
|
|
3131
3300
|
*/
|
|
3132
3301
|
declare class AccountView {
|
|
3133
3302
|
#private;
|
|
@@ -3169,6 +3338,363 @@ declare class AccountView {
|
|
|
3169
3338
|
close(): Promise<void>;
|
|
3170
3339
|
}
|
|
3171
3340
|
|
|
3341
|
+
/** What the combination needs of a leg. */
|
|
3342
|
+
type ComboOutcome = "won" | "lost";
|
|
3343
|
+
/** One leg of a quote request. */
|
|
3344
|
+
interface ComboLeg {
|
|
3345
|
+
/** An `open`, ordinary (not combination) market. */
|
|
3346
|
+
marketId: string;
|
|
3347
|
+
outcome: ComboOutcome;
|
|
3348
|
+
}
|
|
3349
|
+
/** Options for `STXWebSocket.comboPlayer()` and `STXWebSocket.comboMaker()`. */
|
|
3350
|
+
interface ComboJoinOptions<E> {
|
|
3351
|
+
/**
|
|
3352
|
+
* A geolocation packet, or a function returning one, sent on every join
|
|
3353
|
+
* where the exchange is geo-fenced. A function is called again on each
|
|
3354
|
+
* rejoin, so a reconnect sends a fresh packet.
|
|
3355
|
+
*/
|
|
3356
|
+
geoLocation?: GeoLocationProvider;
|
|
3357
|
+
/** Called for every typed event, as it arrives. */
|
|
3358
|
+
onEvent?: (event: E) => void | Promise<void>;
|
|
3359
|
+
}
|
|
3360
|
+
/** The join reply on either topic. */
|
|
3361
|
+
interface ComboJoinReply {
|
|
3362
|
+
/** Your account's pseudonym for counterparties. Makers see the player's on requests and quotes. */
|
|
3363
|
+
external_id: string;
|
|
3364
|
+
/** ISO 8601 time the geolocation packet expires, or null when no packet was needed. Rejoin before it. */
|
|
3365
|
+
next_geolocation_at: string | null;
|
|
3366
|
+
}
|
|
3367
|
+
/** `requestQuote()` reply. */
|
|
3368
|
+
interface ComboRequestReply {
|
|
3369
|
+
rfq_id: string;
|
|
3370
|
+
}
|
|
3371
|
+
/** `cashOut()` reply. */
|
|
3372
|
+
interface ComboCashOutReply {
|
|
3373
|
+
rfq_id: string;
|
|
3374
|
+
/** The combination being sold. */
|
|
3375
|
+
market_id: string;
|
|
3376
|
+
/** Contracts to sell, set by the exchange: what you hold less your resting sells. */
|
|
3377
|
+
quantity: string;
|
|
3378
|
+
}
|
|
3379
|
+
/** `accept()` reply: what was placed for the player, not what filled. */
|
|
3380
|
+
interface ComboPlacement {
|
|
3381
|
+
market_id: string;
|
|
3382
|
+
/** The player's order. Its fills arrive on `fills`. */
|
|
3383
|
+
order_id: string;
|
|
3384
|
+
quantity: string;
|
|
3385
|
+
price: string;
|
|
3386
|
+
}
|
|
3387
|
+
/** `cancel()` reply. */
|
|
3388
|
+
interface ComboCancelReply {
|
|
3389
|
+
/** The `rfq_id` that was cancelled. */
|
|
3390
|
+
cancelled: string;
|
|
3391
|
+
}
|
|
3392
|
+
/** The best live quote. All three fields are null when nothing is live. */
|
|
3393
|
+
interface ComboBestQuote {
|
|
3394
|
+
quote_id: string | null;
|
|
3395
|
+
amount: string | null;
|
|
3396
|
+
/** Microseconds since the Unix epoch. */
|
|
3397
|
+
expires_at: number | null;
|
|
3398
|
+
}
|
|
3399
|
+
/** `snapshot()` reply. */
|
|
3400
|
+
interface ComboSnapshot {
|
|
3401
|
+
rfq_id: string;
|
|
3402
|
+
/** Null on a buy until a bind places; the combination on a cash out. */
|
|
3403
|
+
market_id: string | null;
|
|
3404
|
+
/** `binding` while an acceptance waits for its next bind attempt. */
|
|
3405
|
+
status: "open" | "binding";
|
|
3406
|
+
/** The player's side: `buy` for a request, `sell` for a cash out. */
|
|
3407
|
+
side: "buy" | "sell";
|
|
3408
|
+
/** The stake on a buy; null on a cash out. */
|
|
3409
|
+
amount: string | null;
|
|
3410
|
+
/** The size on a cash out; null on a buy. */
|
|
3411
|
+
quantity: string | null;
|
|
3412
|
+
/** When the request ends, in microseconds since the Unix epoch. */
|
|
3413
|
+
expires_at: number;
|
|
3414
|
+
best_quote: ComboBestQuote;
|
|
3415
|
+
}
|
|
3416
|
+
/** `quote()` reply. It carries no price or size: the bind sets those. */
|
|
3417
|
+
interface ComboQuoteReply {
|
|
3418
|
+
quote_id: string;
|
|
3419
|
+
/** The amount as recorded. */
|
|
3420
|
+
amount: string;
|
|
3421
|
+
/** The player's `external_id`. */
|
|
3422
|
+
external_id: string;
|
|
3423
|
+
}
|
|
3424
|
+
/** `withdrawQuote()` reply. */
|
|
3425
|
+
interface ComboWithdrawReply {
|
|
3426
|
+
/** The `quote_id` that was withdrawn. */
|
|
3427
|
+
withdrawn: string;
|
|
3428
|
+
}
|
|
3429
|
+
/** Why a player's request ended without placing. */
|
|
3430
|
+
type ComboRequestClosedReason = "cancelled" | "expired" | "leg_not_quotable" | "unknown_leg" | "player_refused" | "maker_refused";
|
|
3431
|
+
/** `best_quote`: the best quote changed. */
|
|
3432
|
+
interface ComboBestQuoteEvent extends ComboBestQuote {
|
|
3433
|
+
rfq_id: string;
|
|
3434
|
+
market_id: string | null;
|
|
3435
|
+
}
|
|
3436
|
+
/** `placed`: the bind placed. The `accept()` reply plus `rfq_id`. */
|
|
3437
|
+
interface ComboPlacedEvent extends ComboPlacement {
|
|
3438
|
+
rfq_id: string;
|
|
3439
|
+
}
|
|
3440
|
+
/** `negotiation_closed` to the player: the request ended without placing. */
|
|
3441
|
+
interface ComboRequestClosedEvent {
|
|
3442
|
+
rfq_id: string;
|
|
3443
|
+
market_id: string | null;
|
|
3444
|
+
reason: ComboRequestClosedReason;
|
|
3445
|
+
}
|
|
3446
|
+
/** An event on the player's topic. Narrow on `event`. */
|
|
3447
|
+
type ComboPlayerEvent = {
|
|
3448
|
+
event: "best_quote";
|
|
3449
|
+
payload: ComboBestQuoteEvent;
|
|
3450
|
+
} | {
|
|
3451
|
+
event: "placed";
|
|
3452
|
+
payload: ComboPlacedEvent;
|
|
3453
|
+
} | {
|
|
3454
|
+
event: "negotiation_closed";
|
|
3455
|
+
payload: ComboRequestClosedEvent;
|
|
3456
|
+
};
|
|
3457
|
+
/** One leg as makers see it. */
|
|
3458
|
+
interface ComboRfqLeg {
|
|
3459
|
+
market_id: string;
|
|
3460
|
+
outcome: ComboOutcome;
|
|
3461
|
+
/** Display name of the leg's market. Null when the exchange has no name for it. */
|
|
3462
|
+
short_name: string | null;
|
|
3463
|
+
}
|
|
3464
|
+
/** `rfq_opened`: a player opened a request. */
|
|
3465
|
+
interface ComboRfqOpenedEvent {
|
|
3466
|
+
rfq_id: string;
|
|
3467
|
+
/** Null on a buy; the combination on a cash out. */
|
|
3468
|
+
market_id: string | null;
|
|
3469
|
+
/** The player's pseudonym. */
|
|
3470
|
+
external_id: string;
|
|
3471
|
+
/** The player's side; the maker takes the other. */
|
|
3472
|
+
side: "buy" | "sell";
|
|
3473
|
+
/** The stake on a buy; null on a cash out. */
|
|
3474
|
+
amount: string | null;
|
|
3475
|
+
/** The size on a cash out; null on a buy. */
|
|
3476
|
+
quantity: string | null;
|
|
3477
|
+
/** Price against this, not a constant. */
|
|
3478
|
+
max_price: string;
|
|
3479
|
+
/** Price against this, not a constant. */
|
|
3480
|
+
tick_size: string;
|
|
3481
|
+
expires_at: number;
|
|
3482
|
+
legs: ComboRfqLeg[];
|
|
3483
|
+
}
|
|
3484
|
+
/** Why a request ended, as the feed reports it. */
|
|
3485
|
+
type ComboRfqClosedReason = "placed" | "cancelled" | "expired" | "leg_not_quotable" | "unknown_leg" | "player_refused" | "maker_refused" | "ended";
|
|
3486
|
+
/** `rfq_closed`: a request ended. */
|
|
3487
|
+
interface ComboRfqClosedEvent {
|
|
3488
|
+
rfq_id: string;
|
|
3489
|
+
market_id: string | null;
|
|
3490
|
+
reason: ComboRfqClosedReason;
|
|
3491
|
+
}
|
|
3492
|
+
/** `quote_accepted`: this quote is about to be bound. */
|
|
3493
|
+
interface ComboQuoteAcceptedEvent {
|
|
3494
|
+
rfq_id: string;
|
|
3495
|
+
market_id: string | null;
|
|
3496
|
+
external_id: string;
|
|
3497
|
+
quote_id: string;
|
|
3498
|
+
}
|
|
3499
|
+
/** `placed` to the maker: this quote bound and the maker's order was placed. Both orders share the size and price. */
|
|
3500
|
+
interface ComboMakerPlacedEvent {
|
|
3501
|
+
rfq_id: string;
|
|
3502
|
+
market_id: string;
|
|
3503
|
+
external_id: string;
|
|
3504
|
+
quote_id: string;
|
|
3505
|
+
/** The maker's order. Its fills arrive on `fills`. */
|
|
3506
|
+
order_id: string;
|
|
3507
|
+
quantity: string;
|
|
3508
|
+
price: string;
|
|
3509
|
+
}
|
|
3510
|
+
/** Why one of the maker's quotes stopped standing. */
|
|
3511
|
+
type ComboQuoteClosedReason = "placed_elsewhere" | "maker_refused" | "cancelled" | "expired" | "leg_not_quotable" | "unknown_leg" | "player_refused";
|
|
3512
|
+
/** `negotiation_closed` to the maker: this quote stopped standing. */
|
|
3513
|
+
interface ComboQuoteClosedEvent {
|
|
3514
|
+
rfq_id: string;
|
|
3515
|
+
market_id: string | null;
|
|
3516
|
+
external_id: string;
|
|
3517
|
+
quote_id: string;
|
|
3518
|
+
reason: ComboQuoteClosedReason;
|
|
3519
|
+
}
|
|
3520
|
+
/** An event on the maker's topic. Narrow on `event`. */
|
|
3521
|
+
type ComboMakerEvent = {
|
|
3522
|
+
event: "rfq_opened";
|
|
3523
|
+
payload: ComboRfqOpenedEvent;
|
|
3524
|
+
} | {
|
|
3525
|
+
event: "rfq_closed";
|
|
3526
|
+
payload: ComboRfqClosedEvent;
|
|
3527
|
+
} | {
|
|
3528
|
+
event: "quote_accepted";
|
|
3529
|
+
payload: ComboQuoteAcceptedEvent;
|
|
3530
|
+
} | {
|
|
3531
|
+
event: "placed";
|
|
3532
|
+
payload: ComboMakerPlacedEvent;
|
|
3533
|
+
} | {
|
|
3534
|
+
event: "negotiation_closed";
|
|
3535
|
+
payload: ComboQuoteClosedEvent;
|
|
3536
|
+
};
|
|
3537
|
+
/**
|
|
3538
|
+
* A refusal `reason` the exchange documents for combo commands. The type stays
|
|
3539
|
+
* open (`string`) because a few reasons are sentences passed through verbatim.
|
|
3540
|
+
*/
|
|
3541
|
+
type ComboRefusalReason = "malformed_payload" | "malformed_id" | "malformed_money" | "malformed_leg" | "malformed_client_order_id" | "unknown_command" | "not_found" | "timeout" | "request_unavailable" | "not_the_requester" | "combo_minimum_two_markets_needed" | "combo_maximum_legs_exceeded" | "unknown_outcome" | "non_positive_amount" | "sub_cent_amount" | "insufficient_assets" | "draining" | "account_unreachable" | "unknown_leg" | "leg_not_quotable" | "duplicate_legs" | "request_not_started" | "unknown_combination" | "market_not_quotable" | "combination_unavailable" | "nothing_to_sell" | "price_moved" | "player_refused" | "maker_refused" | "market_not_trading" | "market_unavailable" | "price_out_of_range" | "below_one_contract" | "bind_in_progress" | "cancelled" | "expired" | "expires_at_required" | "cannot_quote_own_request" | "unknown_quote" | "unauthorized" | "insufficient_scope" | (string & {});
|
|
3542
|
+
/** What the player and maker sessions share: the joined channel, typed events and waiting. */
|
|
3543
|
+
declare abstract class ComboSession<E extends {
|
|
3544
|
+
event: string;
|
|
3545
|
+
payload: {
|
|
3546
|
+
rfq_id: string;
|
|
3547
|
+
};
|
|
3548
|
+
}> implements AsyncIterable<E> {
|
|
3549
|
+
#private;
|
|
3550
|
+
/** The underlying channel. Its `reply` is the latest join reply. */
|
|
3551
|
+
readonly channel: Channel;
|
|
3552
|
+
/** @internal */
|
|
3553
|
+
constructor(channel: Channel, events: ReadonlySet<string>, onEvent: ((event: E) => void | Promise<void>) | undefined);
|
|
3554
|
+
/** Your account's pseudonym for counterparties, from the join reply. */
|
|
3555
|
+
get externalId(): string;
|
|
3556
|
+
/** When the geolocation packet this join used expires (ISO 8601), or null. Rejoin before it. */
|
|
3557
|
+
get nextGeolocationAt(): string | null;
|
|
3558
|
+
/** @internal */
|
|
3559
|
+
_typed(msg: ChannelMessage): E | undefined;
|
|
3560
|
+
/** @internal Called for every message on the channel, before it is queued. */
|
|
3561
|
+
_receive(msg: ChannelMessage): Promise<void>;
|
|
3562
|
+
/** The events received so far (the latest 1000), oldest first. */
|
|
3563
|
+
get events(): readonly E[];
|
|
3564
|
+
/**
|
|
3565
|
+
* The next event, in arrival order. Rejects with `STXTimeoutException` when
|
|
3566
|
+
* none arrives within `timeoutMs`, and with `STXChannelException` once the
|
|
3567
|
+
* channel is closed. Use either this or `for await`, not both.
|
|
3568
|
+
*/
|
|
3569
|
+
next(timeoutMs?: number | null): Promise<E>;
|
|
3570
|
+
[Symbol.asyncIterator](): AsyncIterator<E>;
|
|
3571
|
+
/**
|
|
3572
|
+
* Resolve with the first event named `event` (or one of several) for
|
|
3573
|
+
* `rfqId`, looking first at events already received. Unlike `next()`, it
|
|
3574
|
+
* takes nothing from the queue. Rejects with `STXTimeoutException` after
|
|
3575
|
+
* `timeoutMs` (default 10000).
|
|
3576
|
+
*
|
|
3577
|
+
* @param event An event name, or several.
|
|
3578
|
+
* @param opts.rfqId Only events for this request.
|
|
3579
|
+
* @param opts.quoteId Only events for this quote (maker events).
|
|
3580
|
+
* @param opts.timeoutMs Milliseconds to wait. Default 10000.
|
|
3581
|
+
*/
|
|
3582
|
+
waitFor<K extends E["event"]>(event: K | readonly K[], opts?: {
|
|
3583
|
+
rfqId?: string;
|
|
3584
|
+
quoteId?: string;
|
|
3585
|
+
timeoutMs?: number;
|
|
3586
|
+
}): Promise<Extract<E, {
|
|
3587
|
+
event: K;
|
|
3588
|
+
}>>;
|
|
3589
|
+
/**
|
|
3590
|
+
* Leave the topic. Requests opened and quotes placed on this channel end
|
|
3591
|
+
* (`cancelled`), as on any close, and delivery on this channel stops when
|
|
3592
|
+
* `leave()` resolves: the exchange's `negotiation_closed` for those requests
|
|
3593
|
+
* arrives after the channel has closed and is not passed to `onEvent` or to
|
|
3594
|
+
* an iterator. Treat every request still open here as cancelled once
|
|
3595
|
+
* `leave()` resolves. To see each request's own close first, `cancel()` it
|
|
3596
|
+
* and wait for its `negotiation_closed` before leaving. Other connections of
|
|
3597
|
+
* the same member still receive the close.
|
|
3598
|
+
*/
|
|
3599
|
+
leave(): Promise<void>;
|
|
3600
|
+
/** @internal Send a command and map a refusal to the combo exceptions. */
|
|
3601
|
+
_command<T>(command: string, payload: Record<string, unknown>, timeoutMs?: number): Promise<T>;
|
|
3602
|
+
}
|
|
3603
|
+
/**
|
|
3604
|
+
* The player's side of combos, on `rfq:<user_id>`. Get one with
|
|
3605
|
+
* `ws.comboPlayer()`.
|
|
3606
|
+
*
|
|
3607
|
+
* Available on US demo.
|
|
3608
|
+
*
|
|
3609
|
+
* A request belongs to this channel: leaving, a dropped socket or a geo lapse
|
|
3610
|
+
* ends it `cancelled`, and the SDK's automatic rejoin does not bring it back.
|
|
3611
|
+
* Every refusal throws `STXComboRefusedException` with the exchange's
|
|
3612
|
+
* `reason` in `code`.
|
|
3613
|
+
*/
|
|
3614
|
+
declare class ComboPlayer extends ComboSession<ComboPlayerEvent> {
|
|
3615
|
+
/** @internal */
|
|
3616
|
+
constructor(channel: Channel, onEvent?: (event: ComboPlayerEvent) => void | Promise<void>);
|
|
3617
|
+
/**
|
|
3618
|
+
* `request_quote`: ask makers to quote on these legs for a stake. `amount`
|
|
3619
|
+
* is the stake as a decimal string in whole cents, e.g. `"250.00"`. Makers
|
|
3620
|
+
* quote what you win; quotes arrive as `best_quote` events.
|
|
3621
|
+
*
|
|
3622
|
+
* @param legs Two or more `open` markets and the outcome the combination needs of each.
|
|
3623
|
+
* @param amount The stake in dollars, e.g. `"250.00"`.
|
|
3624
|
+
*/
|
|
3625
|
+
requestQuote(legs: readonly ComboLeg[], amount: string): Promise<ComboRequestReply>;
|
|
3626
|
+
/**
|
|
3627
|
+
* `cash_out`: ask makers to quote for what you hold of a combination, by the
|
|
3628
|
+
* `market_id` from `placed`. The exchange sets the size.
|
|
3629
|
+
*
|
|
3630
|
+
* @param marketId The combination's market id.
|
|
3631
|
+
*/
|
|
3632
|
+
cashOut(marketId: string): Promise<ComboCashOutReply>;
|
|
3633
|
+
/**
|
|
3634
|
+
* `accept`: bind the request at `amount` or more, normally the amount
|
|
3635
|
+
* `best_quote` showed. The best live quote binds whoever made it, so the
|
|
3636
|
+
* placement can be better than `amount`. Waits up to 35 s.
|
|
3637
|
+
*
|
|
3638
|
+
* Throws `STXComboPriceMovedException` (with the live `best`) when nothing
|
|
3639
|
+
* at least as good is live; the request stays open and you can accept again.
|
|
3640
|
+
* The reply says what was placed; fills arrive on `fills`.
|
|
3641
|
+
*
|
|
3642
|
+
* @param rfqId The request.
|
|
3643
|
+
* @param quoteId The quote you saw, normally from `best_quote`.
|
|
3644
|
+
* @param amount The least amount you take, e.g. `"1750.00"`.
|
|
3645
|
+
*/
|
|
3646
|
+
accept(rfqId: string, quoteId: string, amount: string): Promise<ComboPlacement>;
|
|
3647
|
+
/**
|
|
3648
|
+
* `cancel`: end the request and drop every quote on it.
|
|
3649
|
+
*
|
|
3650
|
+
* @param rfqId The request.
|
|
3651
|
+
*/
|
|
3652
|
+
cancel(rfqId: string): Promise<ComboCancelReply>;
|
|
3653
|
+
/**
|
|
3654
|
+
* `snapshot`: the request now, with the live best quote. Not delayed like `best_quote` events.
|
|
3655
|
+
*
|
|
3656
|
+
* @param rfqId The request.
|
|
3657
|
+
*/
|
|
3658
|
+
snapshot(rfqId: string): Promise<ComboSnapshot>;
|
|
3659
|
+
}
|
|
3660
|
+
/**
|
|
3661
|
+
* The maker's side of combos, on `combo_quote:<user_id>`. Get one with
|
|
3662
|
+
* `ws.comboMaker()`. Joining subscribes to every request opened after the
|
|
3663
|
+
* join (`rfq_opened`); earlier requests are not replayed.
|
|
3664
|
+
*
|
|
3665
|
+
* Available on US demo.
|
|
3666
|
+
*
|
|
3667
|
+
* A quote belongs to this channel: leaving or a dropped socket withdraws it.
|
|
3668
|
+
* Every refusal throws `STXComboRefusedException` with the exchange's
|
|
3669
|
+
* `reason` in `code`.
|
|
3670
|
+
*/
|
|
3671
|
+
declare class ComboMaker extends ComboSession<ComboMakerEvent> {
|
|
3672
|
+
/** @internal */
|
|
3673
|
+
constructor(channel: Channel, onEvent?: (event: ComboMakerEvent) => void | Promise<void>);
|
|
3674
|
+
/**
|
|
3675
|
+
* `quote`: offer `amount` on a request. On a buy it is what the player wins;
|
|
3676
|
+
* on a cash out, what you pay for the whole size. Price it against the
|
|
3677
|
+
* request's `max_price` and `tick_size`. `expiresInMs` (a positive integer)
|
|
3678
|
+
* counts from receipt; the quote ends no later than its request.
|
|
3679
|
+
* `clientOrderId` (at most 255 bytes) is copied onto your order if it binds.
|
|
3680
|
+
*
|
|
3681
|
+
* @param rfqId The request, from `rfq_opened`.
|
|
3682
|
+
* @param amount In dollars, e.g. `"1750.00"`.
|
|
3683
|
+
* @param expiresInMs How long the quote stands, in milliseconds.
|
|
3684
|
+
* @param opts.clientOrderId Copied onto your order if the quote binds.
|
|
3685
|
+
*/
|
|
3686
|
+
quote(rfqId: string, amount: string, expiresInMs: number, opts?: {
|
|
3687
|
+
clientOrderId?: string | null;
|
|
3688
|
+
}): Promise<ComboQuoteReply>;
|
|
3689
|
+
/**
|
|
3690
|
+
* `withdraw_quote`: remove one of your quotes.
|
|
3691
|
+
*
|
|
3692
|
+
* @param rfqId The request.
|
|
3693
|
+
* @param quoteId Your quote, from the `quote()` reply.
|
|
3694
|
+
*/
|
|
3695
|
+
withdrawQuote(rfqId: string, quoteId: string): Promise<ComboWithdrawReply>;
|
|
3696
|
+
}
|
|
3697
|
+
|
|
3172
3698
|
/** Events that carry state on join, by channel name (topic prefix). */
|
|
3173
3699
|
declare const SNAPSHOT_EVENTS: Readonly<Record<string, readonly string[]>>;
|
|
3174
3700
|
/** One pushed frame. */
|
|
@@ -3207,7 +3733,6 @@ declare class ReconnectPolicy {
|
|
|
3207
3733
|
constructor(opts?: ReconnectPolicyOptions);
|
|
3208
3734
|
delayMs(attempt: number): number;
|
|
3209
3735
|
}
|
|
3210
|
-
/** One joined topic. */
|
|
3211
3736
|
declare class Channel implements AsyncIterable<ChannelMessage> {
|
|
3212
3737
|
#private;
|
|
3213
3738
|
/** The wire topic, e.g. `orders:<user_id>`. */
|
|
@@ -3227,6 +3752,8 @@ declare class Channel implements AsyncIterable<ChannelMessage> {
|
|
|
3227
3752
|
joinRef: string | null;
|
|
3228
3753
|
joined: boolean;
|
|
3229
3754
|
closed: boolean;
|
|
3755
|
+
/** @internal Runs before every (re)join, e.g. to refresh a geolocation packet in `joinPayload`. */
|
|
3756
|
+
_beforeJoin: (() => Promise<void>) | undefined;
|
|
3230
3757
|
constructor(ws: STXWebSocket, topic: string, joinPayload: Record<string, unknown>, onMessage: MessageHandler | undefined, opts: {
|
|
3231
3758
|
pingIntervalMs: number | null;
|
|
3232
3759
|
queueSize: number;
|
|
@@ -3305,9 +3832,11 @@ interface STXWebSocketOptions extends Pick<STXOptions, "environment" | "region"
|
|
|
3305
3832
|
/** Milliseconds between socket heartbeats. The server closes a socket silent for 60 s. Default 25000. */
|
|
3306
3833
|
heartbeatIntervalMs?: number;
|
|
3307
3834
|
/**
|
|
3308
|
-
* Milliseconds between channel `ping` frames on every joined topic
|
|
3309
|
-
* disables them. `orders` with cancel-on-disconnect
|
|
3310
|
-
* granted timeout. Default 30000.
|
|
3835
|
+
* Milliseconds between channel `ping` frames on every joined topic that
|
|
3836
|
+
* answers them; `null` disables them. `orders` with cancel-on-disconnect
|
|
3837
|
+
* pings faster, from the granted timeout. Default 30000. The `market:<id>`,
|
|
3838
|
+
* `rfq:` and `combo_quote:` topics have no `ping` command and are never
|
|
3839
|
+
* pinged; the socket heartbeat keeps them alive.
|
|
3311
3840
|
*/
|
|
3312
3841
|
channelPingIntervalMs?: number | null;
|
|
3313
3842
|
/** Reconnect after a drop. Default true. */
|
|
@@ -3336,7 +3865,7 @@ interface STXWebSocketOptions extends Pick<STXOptions, "environment" | "region"
|
|
|
3336
3865
|
*
|
|
3337
3866
|
* const client = new STX();
|
|
3338
3867
|
* const ws = await client.websocket().connect();
|
|
3339
|
-
* const book = await ws.orderbook(["
|
|
3868
|
+
* const book = await ws.orderbook(["e00651a3-10cb-4bc1-9e1f-c5ea1796c83b"], { onMessage: console.log });
|
|
3340
3869
|
* const orders = await ws.orders();
|
|
3341
3870
|
* console.log(await orders.waitSnapshot());
|
|
3342
3871
|
* await ws.runForever();
|
|
@@ -3494,6 +4023,25 @@ declare class STXWebSocket {
|
|
|
3494
4023
|
userInfo(opts?: {
|
|
3495
4024
|
onMessage?: MessageHandler;
|
|
3496
4025
|
}): Promise<Channel>;
|
|
4026
|
+
/**
|
|
4027
|
+
* Join `rfq:{user_id}` and return a `ComboPlayer`: request quotes on a
|
|
4028
|
+
* combination, cash one out, accept, cancel and read a request.
|
|
4029
|
+
*
|
|
4030
|
+
* Available on US demo.
|
|
4031
|
+
* Where combos are not available, rejects with
|
|
4032
|
+
* `STXCombosUnavailableException`. Other join refusals (a read-only key, an
|
|
4033
|
+
* account that may not trade) reject with `STXComboRefusedException`.
|
|
4034
|
+
*/
|
|
4035
|
+
comboPlayer(opts?: ComboJoinOptions<ComboPlayerEvent>): Promise<ComboPlayer>;
|
|
4036
|
+
/**
|
|
4037
|
+
* Join `combo_quote:{user_id}` and return a `ComboMaker`: receive every
|
|
4038
|
+
* request opened from now on (`rfq_opened`), quote and withdraw quotes.
|
|
4039
|
+
*
|
|
4040
|
+
* Available on US demo.
|
|
4041
|
+
* Where combos are not available, rejects with
|
|
4042
|
+
* `STXCombosUnavailableException`.
|
|
4043
|
+
*/
|
|
4044
|
+
comboMaker(opts?: ComboJoinOptions<ComboMakerEvent>): Promise<ComboMaker>;
|
|
3497
4045
|
/**
|
|
3498
4046
|
* Join `topic` with `payload` and wait for the reply. Rejects with
|
|
3499
4047
|
* `STXChannelException` carrying the server's reason (for example
|
|
@@ -3660,6 +4208,15 @@ interface SettlementsQuery {
|
|
|
3660
4208
|
limit?: number;
|
|
3661
4209
|
cursor?: string;
|
|
3662
4210
|
}
|
|
4211
|
+
interface LeaderboardQuery {
|
|
4212
|
+
/** `daily`, `weekly`, `monthly`, `yearly` or `all`. */
|
|
4213
|
+
period?: "daily" | "weekly" | "monthly" | "yearly" | "all" | (string & {});
|
|
4214
|
+
/** `all` or a sport key. */
|
|
4215
|
+
category?: string;
|
|
4216
|
+
/** `volume`, `profit`, `predictions`, `markets`, `win_rate`, `biggest_win`, `return` or `streak`. */
|
|
4217
|
+
metric?: string;
|
|
4218
|
+
limit?: number;
|
|
4219
|
+
}
|
|
3663
4220
|
interface PageQuery {
|
|
3664
4221
|
limit?: number;
|
|
3665
4222
|
cursor?: string;
|
|
@@ -3667,9 +4224,9 @@ interface PageQuery {
|
|
|
3667
4224
|
type WithoutCursor<T> = Omit<T, "cursor">;
|
|
3668
4225
|
/** The optional fields of one new order. */
|
|
3669
4226
|
interface OrderOptions extends GeoOption {
|
|
3670
|
-
/** Dollars, as a decimal string: `"0.
|
|
4227
|
+
/** Dollars, as a decimal string: `"0.58"`. Required for a limit order. */
|
|
3671
4228
|
price?: string;
|
|
3672
|
-
/** Contracts, as a decimal string: `"
|
|
4229
|
+
/** Contracts, as a decimal string: `"100"`. */
|
|
3673
4230
|
quantity: string;
|
|
3674
4231
|
clientOrderId?: string;
|
|
3675
4232
|
/** `"good_till_start"` or `"good_till_time"`. */
|
|
@@ -3700,7 +4257,9 @@ declare function orderBody(marketId: string, action: string, orderType: string,
|
|
|
3700
4257
|
*
|
|
3701
4258
|
* const client = new STX();
|
|
3702
4259
|
* const me = await client.me();
|
|
4260
|
+
* me.user_id; // "e6528824-b4e0-4ff8-bd70-36e5904738d1"
|
|
3703
4261
|
* const page = await client.markets({ status: "open", limit: 10 });
|
|
4262
|
+
* page.items[0]?.symbol; // "STXNHL-26OCT101600EDMSJ-GAMEEDM"
|
|
3704
4263
|
*/
|
|
3705
4264
|
declare class STX {
|
|
3706
4265
|
#private;
|
|
@@ -3721,6 +4280,26 @@ declare class STX {
|
|
|
3721
4280
|
_sleep: (ms: number) => Promise<void>;
|
|
3722
4281
|
constructor(opts?: STXOptions);
|
|
3723
4282
|
toString(): string;
|
|
4283
|
+
/** The exchange host, e.g. `"demo.stxapp.io"`: the name `STXNotAvailableException` and `capabilities()` report. */
|
|
4284
|
+
get host(): string;
|
|
4285
|
+
/**
|
|
4286
|
+
* Which features this exchange has, from what it publishes: its OAuth
|
|
4287
|
+
* discovery document, `/api_version`, a signed GET of the routes that not
|
|
4288
|
+
* every exchange has yet, and a join of a combos topic nobody owns. Nothing
|
|
4289
|
+
* is created or changed. Checked once per client and cached; pass
|
|
4290
|
+
* `{ refresh: true }` to check again.
|
|
4291
|
+
*
|
|
4292
|
+
* const caps = await stx.capabilities();
|
|
4293
|
+
* caps.features.combos; // false on demo.stxapp.ca
|
|
4294
|
+
* caps.require("combos"); // throws STXNotAvailableException there
|
|
4295
|
+
*
|
|
4296
|
+
* Each feature is `true`, `false`, or `null` when it could not be checked
|
|
4297
|
+
* (no credentials for a signed check, or no answer). A missing feature never
|
|
4298
|
+
* throws here; the call that needs it throws `STXNotAvailableException`.
|
|
4299
|
+
*/
|
|
4300
|
+
capabilities(opts?: {
|
|
4301
|
+
refresh?: boolean;
|
|
4302
|
+
}): Promise<Capabilities>;
|
|
3724
4303
|
/** Nothing to release (fetch pools connections itself); present so `await using` and explicit cleanup work. */
|
|
3725
4304
|
close(): Promise<void>;
|
|
3726
4305
|
/**
|
|
@@ -3773,16 +4352,18 @@ declare class STX {
|
|
|
3773
4352
|
* which STX grants, from an address on the client's IP allow-list (it
|
|
3774
4353
|
* applies to every call that client makes).
|
|
3775
4354
|
*
|
|
3776
|
-
* Returns one result per market, in
|
|
3777
|
-
* `
|
|
3778
|
-
*
|
|
3779
|
-
*
|
|
3780
|
-
*
|
|
3781
|
-
*
|
|
4355
|
+
* Returns one result per market, in order: `created` or `exists` (both with
|
|
4356
|
+
* `market_id`), `valid` with `dryRun`, or `rejected` with a `reason`. Each
|
|
4357
|
+
* result's `index` is its position in `markets`, and `market` is that market
|
|
4358
|
+
* as requested. A rejected market is a
|
|
4359
|
+
* result, not an error, and resending is safe: a market that is already
|
|
4360
|
+
* listed comes back `exists`. A refused request throws (`403` without
|
|
4361
|
+
* `markets.write`, `404` unknown event, `422` event not open).
|
|
3782
4362
|
*
|
|
3783
|
-
* `
|
|
3784
|
-
* `MAX_MARKETS_PER_REQUEST` markets throws `TypeError` before any
|
|
3785
|
-
* `
|
|
4363
|
+
* Each `line` must be a positive number ending in `.5`, e.g. `18.5`. More
|
|
4364
|
+
* than `MAX_MARKETS_PER_REQUEST` markets throws `TypeError` before any
|
|
4365
|
+
* request. `dryRun` runs every check and creates nothing. `validate` also
|
|
4366
|
+
* needs the `events` scope.
|
|
3786
4367
|
*/
|
|
3787
4368
|
createMarkets(eventId: string, markets: readonly NewMarket[], opts?: CreateMarketsOptions): Promise<CreateMarketResult[]>;
|
|
3788
4369
|
/** `GET /api/v1/orders`: one page of your orders, newest first. */
|
|
@@ -3796,7 +4377,7 @@ declare class STX {
|
|
|
3796
4377
|
*
|
|
3797
4378
|
* `action` is `"buy"` or `"sell"`; `orderType` is `"limit"` or `"market"`.
|
|
3798
4379
|
* `price` (dollars, required for a limit order) and `quantity` (contracts)
|
|
3799
|
-
* are decimal strings, e.g. `{ price: "0.
|
|
4380
|
+
* are decimal strings, e.g. `{ price: "0.58", quantity: "100" }`. Numbers are
|
|
3800
4381
|
* refused client-side.
|
|
3801
4382
|
*
|
|
3802
4383
|
* The exchange validates the order: a bad price step or a fractional
|
|
@@ -3898,7 +4479,28 @@ declare class STX {
|
|
|
3898
4479
|
iterLoyalty(query?: {
|
|
3899
4480
|
limit?: number;
|
|
3900
4481
|
}): AsyncGenerator<Transaction, void, undefined>;
|
|
3901
|
-
/**
|
|
4482
|
+
/**
|
|
4483
|
+
* `GET /api/v1/leaderboard`: ranked members for a period, sport and metric.
|
|
4484
|
+
* Rows carry a public handle and avatar, never an account id. Throws
|
|
4485
|
+
* `STXNotAvailableException` (feature `leaderboard`) where the exchange does
|
|
4486
|
+
* not have the leaderboard.
|
|
4487
|
+
*/
|
|
4488
|
+
leaderboard(query?: LeaderboardQuery): Promise<Leaderboard>;
|
|
4489
|
+
/** `GET /api/v1/leaderboard/me`: your own standing, including your rank outside the list. */
|
|
4490
|
+
leaderboardMe(query?: Pick<LeaderboardQuery, "period" | "category">): Promise<LeaderboardStanding>;
|
|
4491
|
+
/**
|
|
4492
|
+
* `PATCH /api/v1/me/profile`: change your public handle, avatar or
|
|
4493
|
+
* leaderboard opt-in. Resolves to the updated `me`.
|
|
4494
|
+
*/
|
|
4495
|
+
updateProfile(update: ProfileUpdate): Promise<Me>;
|
|
4496
|
+
/**
|
|
4497
|
+
* `POST /api/v1/tnc/accept`: accept the current terms for your own account,
|
|
4498
|
+
* with your own API key. Resolves to the server's message.
|
|
4499
|
+
*
|
|
4500
|
+
* An app cannot accept the terms for a member: called with a member's OAuth
|
|
4501
|
+
* access token, the exchange answers 403 `terms_not_delegable`
|
|
4502
|
+
* (`STXForbiddenException`). The member accepts on an STX page instead.
|
|
4503
|
+
*/
|
|
3902
4504
|
acceptTerms(deviceId: string, opts?: AcceptTermsOptions): Promise<string>;
|
|
3903
4505
|
/**
|
|
3904
4506
|
* An `STXWebSocket` using this client's host and key. Account channels
|
|
@@ -3907,4 +4509,4 @@ declare class STX {
|
|
|
3907
4509
|
websocket(opts?: Omit<STXWebSocketOptions, "rest">): STXWebSocket;
|
|
3908
4510
|
}
|
|
3909
4511
|
|
|
3910
|
-
export { type
|
|
4512
|
+
export { type EventPlayers as $, type AcceptTermsOptions as A, type Balance as B, type Cancellation as C, ComboPlayer as D, type ComboPlayerEvent as E, type ComboQuoteAcceptedEvent as F, type ComboQuoteClosedEvent as G, type ComboQuoteClosedReason as H, type ComboQuoteReply as I, type ComboRefusalReason as J, type ComboRequestClosedEvent as K, type ComboRequestClosedReason as L, type ComboRequestReply as M, type ComboRfqClosedEvent as N, type ComboRfqClosedReason as O, type ComboRfqLeg as P, type ComboRfqOpenedEvent as Q, type ComboSnapshot as R, type ComboWithdrawReply as S, type CreatableMarketType as T, type CreateMarketResult as U, type CreateMarketsOptions as V, Environment as W, Environments as X, type Error$1 as Y, type Event as Z, type EventPlayer as _, type AccountChange as a, SIGNATURE_HEADER as a$, type EventStat as a0, type EventTeam as a1, type EventsQuery as a2, FEATURES as a3, type Feature as a4, type FeatureMap as a5, type FeeTransaction as a6, type FetchLike as a7, type Fill as a8, type FillsQuery as a9, type Me as aA, type MessageHandler as aB, NO_RETRY as aC, type NewMarket as aD, type NewMarketInput as aE, type NewOrder as aF, type NewOrderInput as aG, OPERATIONS as aH, type Operation as aI, type OperationId as aJ, type Order as aK, type OrderOptions as aL, type OrdersQuery as aM, Page as aN, type PageQuery as aO, type PaymentTransaction as aP, type PlayerStatLineMarket as aQ, type Position as aR, type PrivateKeyInput as aS, type ProfileUpdate as aT, type RecentTrade as aU, ReconnectPolicy as aV, type ReconnectPolicyOptions as aW, Region as aX, type ResponseEvent as aY, RetryPolicy as aZ, type RetryPolicyOptions as a_, type GeoCheckResult as aa, type GeoLocationProvider as ab, type GeoOption as ac, type GeoRejection as ad, HOSTS as ae, KEY_HEADER as af, type KnownStat as ag, type Leaderboard as ah, type LeaderboardEntry as ai, type LeaderboardQuery as aj, type LeaderboardStanding as ak, type ListedMarketType as al, type Logger as am, MAX_MARKETS_PER_REQUEST as an, type Market as ao, type MarketFilter as ap, type MarketRejectionReason as aq, type MarketRequestEcho as ar, type MarketRule as as, type MarketStat as at, type MarketStatsQuery as au, type MarketType as av, type MarketTypeEventType as aw, type MarketTypeField as ax, type MarketTypes as ay, type MarketsQuery as az, type AccountChangeKind as b, SNAPSHOT_EVENTS as b0, STX as b1, STXAPIException as b2, STXAuthenticationException as b3, STXChannelException as b4, STXComboPriceMovedException as b5, STXComboRefusedException as b6, STXCombosUnavailableException as b7, STXConfigException as b8, type STXEnvironment as b9, TIMESTAMP_HEADER as bA, type Transaction as bB, USER_AGENT as bC, VERSION as bD, type WebSocketAuthContext as bE, baseUrlFor as bF, buildMessage as bG, environmentNamed as bH, errorForStatus as bI, geoRejection as bJ, handshakePath as bK, isValidLine as bL, loadPrivateKey as bM, models as bN, notAvailableMessage as bO, orderBody as bP, requestPath as bQ, resolveHost as bR, signerFromPrivateKey as bS, socketUrlFor as bT, STXException as ba, STXForbiddenException as bb, STXGeoLocationException as bc, STXIPNotAllowedException as bd, STXInsufficientScopeException as be, STXInvalidTokenException as bf, STXNotAvailableException as bg, STXNotFoundException as bh, type STXOptions as bi, STXRateLimitException as bj, STXRejectedException as bk, STXServerException as bl, STXTermsRequiredException as bm, STXTimeoutException as bn, STXTransportException as bo, STXValidationException as bp, STXWebSocket as bq, type STXWebSocketOptions as br, type Settlement as bs, type SettlementsQuery as bt, type Signer as bu, type Stat as bv, type StatDetail as bw, Stats as bx, type StrList as by, TERMINAL_ORDER_STATUSES as bz, 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, Capabilities as k, Channel as l, ChannelMessage as m, type ComboBestQuote as n, type ComboBestQuoteEvent as o, type ComboCancelReply as p, type ComboCashOutReply as q, type ComboJoinOptions as r, type ComboJoinReply as s, type ComboLeg as t, ComboMaker as u, type ComboMakerEvent as v, type ComboMakerPlacedEvent as w, type ComboOutcome as x, type ComboPlacedEvent as y, type ComboPlacement as z };
|