@flexemarkets/fm-sdk 0.0.11 → 0.1.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/dist/client.d.ts +213 -15
- package/dist/client.js +486 -62
- package/dist/client.js.map +1 -1
- package/dist/hal.d.ts +15 -0
- package/dist/hal.js +14 -0
- package/dist/hal.js.map +1 -0
- package/dist/index.d.ts +5 -7
- package/dist/index.js +3 -8
- package/dist/index.js.map +1 -1
- package/dist/market-view.d.ts +9 -7
- package/dist/market-view.js +25 -18
- package/dist/market-view.js.map +1 -1
- package/dist/order-utils.d.ts +4 -4
- package/dist/order-utils.js +10 -6
- package/dist/order-utils.js.map +1 -1
- package/dist/stomp.d.ts +32 -5
- package/dist/stomp.js +37 -16
- package/dist/stomp.js.map +1 -1
- package/dist/ticker.js +3 -3
- package/dist/ticker.js.map +1 -1
- package/dist/timestamps.d.ts +30 -0
- package/dist/timestamps.js +39 -0
- package/dist/timestamps.js.map +1 -0
- package/dist/types.d.ts +144 -22
- package/dist/types.js +93 -14
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/dist/stomp.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* EventListener / Java StompListener behaviour.
|
|
6
6
|
*/
|
|
7
7
|
import WebSocket from "ws";
|
|
8
|
+
import { toInstant } from "./timestamps.js";
|
|
8
9
|
const HEARTBEAT_MS = 30_000;
|
|
9
10
|
const NULL = "\x00";
|
|
10
11
|
/**
|
|
@@ -112,7 +113,7 @@ function parseVersion(data) {
|
|
|
112
113
|
}
|
|
113
114
|
return { version: typeof data === "number" ? data : 0 };
|
|
114
115
|
}
|
|
115
|
-
function parseSession(data) {
|
|
116
|
+
export function parseSession(data) {
|
|
116
117
|
return {
|
|
117
118
|
marketplaceId: data.marketplaceId ?? 0,
|
|
118
119
|
allocationId: data.allocationId ?? 0,
|
|
@@ -121,8 +122,8 @@ function parseSession(data) {
|
|
|
121
122
|
state: data.state ?? null,
|
|
122
123
|
name: data.name ?? null,
|
|
123
124
|
description: data.description ?? null,
|
|
124
|
-
openDate: data.openDate
|
|
125
|
-
closeDate: data.closeDate
|
|
125
|
+
openDate: toInstant(data.openDate),
|
|
126
|
+
closeDate: toInstant(data.closeDate),
|
|
126
127
|
};
|
|
127
128
|
}
|
|
128
129
|
function parseSessionList(data) {
|
|
@@ -151,6 +152,7 @@ export class EventListener {
|
|
|
151
152
|
_ws = null;
|
|
152
153
|
_closed = false;
|
|
153
154
|
_subscriptionCounter = 0;
|
|
155
|
+
_reconnecting = false;
|
|
154
156
|
constructor(wsUrl, bearerToken, marketplaceId, callback, clientDescription, parseHolding, parseOrder) {
|
|
155
157
|
this._wsUrl = wsUrl;
|
|
156
158
|
this._bearerToken = bearerToken;
|
|
@@ -190,6 +192,35 @@ export class EventListener {
|
|
|
190
192
|
});
|
|
191
193
|
});
|
|
192
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* React to a dropped stream by restoring it.
|
|
197
|
+
*
|
|
198
|
+
* On success a `Reconnected` is delivered so consumers know their state
|
|
199
|
+
* needs reseeding -- matching Java, where the subscription has always
|
|
200
|
+
* restored itself rather than leaving the caller to notice.
|
|
201
|
+
*
|
|
202
|
+
* The flag is what makes a burst of errors from a dying socket one outage
|
|
203
|
+
* instead of five reconnects; Java uses compareAndSet for the same reason.
|
|
204
|
+
*/
|
|
205
|
+
_onStreamDropped(exception) {
|
|
206
|
+
if (this._closed)
|
|
207
|
+
return;
|
|
208
|
+
this._callback({ kind: "stream-dropped", exception });
|
|
209
|
+
if (this._reconnecting)
|
|
210
|
+
return;
|
|
211
|
+
this._reconnecting = true;
|
|
212
|
+
void (async () => {
|
|
213
|
+
try {
|
|
214
|
+
await this.reconnect();
|
|
215
|
+
if (!this._closed) {
|
|
216
|
+
this._callback({ kind: "reconnected", marketplaceId: this._marketplaceId });
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
finally {
|
|
220
|
+
this._reconnecting = false;
|
|
221
|
+
}
|
|
222
|
+
})();
|
|
223
|
+
}
|
|
193
224
|
async reconnect() {
|
|
194
225
|
while (!this._closed) {
|
|
195
226
|
try {
|
|
@@ -287,7 +318,7 @@ export class EventListener {
|
|
|
287
318
|
}
|
|
288
319
|
else if (frame.command === "ERROR") {
|
|
289
320
|
this._callback({
|
|
290
|
-
kind: "
|
|
321
|
+
kind: "frame-unreadable",
|
|
291
322
|
command: frame.command,
|
|
292
323
|
headers: frame.headers,
|
|
293
324
|
body: frame.body,
|
|
@@ -296,20 +327,10 @@ export class EventListener {
|
|
|
296
327
|
}
|
|
297
328
|
});
|
|
298
329
|
this._ws.on("close", () => {
|
|
299
|
-
|
|
300
|
-
this._callback({
|
|
301
|
-
kind: "transport-error",
|
|
302
|
-
exception: new Error("WebSocket connection closed"),
|
|
303
|
-
});
|
|
304
|
-
}
|
|
330
|
+
this._onStreamDropped(new Error("WebSocket connection closed"));
|
|
305
331
|
});
|
|
306
332
|
this._ws.on("error", (err) => {
|
|
307
|
-
|
|
308
|
-
this._callback({
|
|
309
|
-
kind: "transport-error",
|
|
310
|
-
exception: err,
|
|
311
|
-
});
|
|
312
|
-
}
|
|
333
|
+
this._onStreamDropped(err);
|
|
313
334
|
});
|
|
314
335
|
}
|
|
315
336
|
}
|
package/dist/stomp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stomp.js","sourceRoot":"","sources":["../src/stomp.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,SAAS,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"stomp.js","sourceRoot":"","sources":["../src/stomp.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,SAAS,MAAM,IAAI,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,MAAM,YAAY,GAAG,MAAM,CAAC;AAC5B,MAAM,IAAI,GAAG,MAAM,CAAC;AAEpB;;;;;;;;;;;;G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C,aAAa,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;gBACtE,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;oBACnB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;gBACxB,CAAC;YACH,CAAC;iBAAM,IAAI,KAAK,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;gBACrC,IAAI,CAAC,SAAS,CAAC;oBACb,IAAI,EAAE,kBAAkB;oBACxB,OAAO,EAAE,KAAK,CAAC,OAAO;oBACtB,OAAO,EAAE,KAAK,CAAC,OAAO;oBACtB,IAAI,EAAE,KAAK,CAAC,IAAI;oBAChB,SAAS,EAAE,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,IAAI,aAAa,CAAC;iBAC7D,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,GAAI,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;YACzB,IAAI,CAAC,gBAAgB,CAAC,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,GAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YAC5B,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/dist/ticker.js
CHANGED
|
@@ -56,8 +56,8 @@ function isSession(event) {
|
|
|
56
56
|
"marketplaceId" in event &&
|
|
57
57
|
"allocationId" in event);
|
|
58
58
|
}
|
|
59
|
-
function
|
|
60
|
-
return typeof event === "object" && "kind" in event && event.kind === "
|
|
59
|
+
function isStreamDropped(event) {
|
|
60
|
+
return typeof event === "object" && "kind" in event && event.kind === "stream-dropped";
|
|
61
61
|
}
|
|
62
62
|
async function main() {
|
|
63
63
|
// Parse CLI args
|
|
@@ -99,7 +99,7 @@ async function main() {
|
|
|
99
99
|
process.exit(0);
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
else if (
|
|
102
|
+
else if (isStreamDropped(event)) {
|
|
103
103
|
process.stderr.write(`\nConnection lost: ${event.exception.message}\n`);
|
|
104
104
|
fm.reconnect();
|
|
105
105
|
}
|
package/dist/ticker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ticker.js","sourceRoot":"","sources":["../src/ticker.ts"],"names":[],"mappings":";AACA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIhD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElD,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAE9B,SAAS,KAAK,CAAC,KAAa;IAC1B,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,QAAQ,CAAC;IAC/B,OAAO,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;AACpD,CAAC;AAED,SAAS,MAAM,CAAC,GAAW,EAAE,GAAW;IACtC,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC;QAAE,OAAO,QAAQ,CAAC;IACxC,OAAO,IAAI,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1D,CAAC;AAED,SAAS,WAAW,CAAC,MAAgB,EAAE,KAAa;IAClD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IACr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ACzB,MAAM,IAAI,OAAO,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAC9B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,EAAE,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading the two ways the server spells a moment.
|
|
3
|
+
*
|
|
4
|
+
* It sends both. Audit fields — `createdDate`, `lastModifiedDate`, a session's
|
|
5
|
+
* `openDate` — come from a Java `LocalDateTime` and arrive bare:
|
|
6
|
+
* `"2017-04-11T00:54:35.135"`, no zone, with three to nine fractional digits.
|
|
7
|
+
* `expiresAt` comes from a real `Instant` and arrives `"2026-08-15T18:00:00Z"`.
|
|
8
|
+
*
|
|
9
|
+
* **A bare timestamp is UTC.** The server writes them from a clock running UTC.
|
|
10
|
+
*
|
|
11
|
+
* This matters more in JavaScript than anywhere else, because the language gets
|
|
12
|
+
* it wrong by default. `new Date("2017-04-11T00:54:35.135")` is specified to
|
|
13
|
+
* read a date-time with no zone as *local*, so in Denver it yields
|
|
14
|
+
* `2017-04-11T06:54:35.135Z` — six hours adrift. It is right in UTC, right in
|
|
15
|
+
* CI, and wrong on the laptop of anyone west of Greenwich, which is the worst
|
|
16
|
+
* way for a bug to be distributed.
|
|
17
|
+
*
|
|
18
|
+
* So a bare value has its `Z` supplied before parsing, and the ambiguity stops
|
|
19
|
+
* here rather than at each call site.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* The moment a value names, or null if it names none.
|
|
23
|
+
*
|
|
24
|
+
* Null rather than a throw for an unreadable value, the same rule the enums
|
|
25
|
+
* follow: one unparseable field should cost the caller that field, not the
|
|
26
|
+
* whole response it arrived in. An `Invalid Date` is worse than either — it
|
|
27
|
+
* spreads, comparing false against everything and rendering as "Invalid Date"
|
|
28
|
+
* somewhere far from the parse.
|
|
29
|
+
*/
|
|
30
|
+
export declare function toInstant(value: string | null | undefined): Date | null;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading the two ways the server spells a moment.
|
|
3
|
+
*
|
|
4
|
+
* It sends both. Audit fields — `createdDate`, `lastModifiedDate`, a session's
|
|
5
|
+
* `openDate` — come from a Java `LocalDateTime` and arrive bare:
|
|
6
|
+
* `"2017-04-11T00:54:35.135"`, no zone, with three to nine fractional digits.
|
|
7
|
+
* `expiresAt` comes from a real `Instant` and arrives `"2026-08-15T18:00:00Z"`.
|
|
8
|
+
*
|
|
9
|
+
* **A bare timestamp is UTC.** The server writes them from a clock running UTC.
|
|
10
|
+
*
|
|
11
|
+
* This matters more in JavaScript than anywhere else, because the language gets
|
|
12
|
+
* it wrong by default. `new Date("2017-04-11T00:54:35.135")` is specified to
|
|
13
|
+
* read a date-time with no zone as *local*, so in Denver it yields
|
|
14
|
+
* `2017-04-11T06:54:35.135Z` — six hours adrift. It is right in UTC, right in
|
|
15
|
+
* CI, and wrong on the laptop of anyone west of Greenwich, which is the worst
|
|
16
|
+
* way for a bug to be distributed.
|
|
17
|
+
*
|
|
18
|
+
* So a bare value has its `Z` supplied before parsing, and the ambiguity stops
|
|
19
|
+
* here rather than at each call site.
|
|
20
|
+
*/
|
|
21
|
+
/** Ends with `Z`, `+hh:mm` or `-hh:mm` after the time part. */
|
|
22
|
+
const ZONED = /(?:Z|[+-]\d{2}:?\d{2})$/;
|
|
23
|
+
/**
|
|
24
|
+
* The moment a value names, or null if it names none.
|
|
25
|
+
*
|
|
26
|
+
* Null rather than a throw for an unreadable value, the same rule the enums
|
|
27
|
+
* follow: one unparseable field should cost the caller that field, not the
|
|
28
|
+
* whole response it arrived in. An `Invalid Date` is worse than either — it
|
|
29
|
+
* spreads, comparing false against everything and rendering as "Invalid Date"
|
|
30
|
+
* somewhere far from the parse.
|
|
31
|
+
*/
|
|
32
|
+
export function toInstant(value) {
|
|
33
|
+
const trimmed = value?.trim();
|
|
34
|
+
if (!trimmed)
|
|
35
|
+
return null;
|
|
36
|
+
const parsed = new Date(ZONED.test(trimmed) ? trimmed : `${trimmed}Z`);
|
|
37
|
+
return Number.isNaN(parsed.getTime()) ? null : parsed;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=timestamps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timestamps.js","sourceRoot":"","sources":["../src/timestamps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,+DAA+D;AAC/D,MAAM,KAAK,GAAG,yBAAyB,CAAC;AAExC;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CAAC,KAAgC;IACxD,MAAM,OAAO,GAAG,KAAK,EAAE,IAAI,EAAE,CAAC;IAC9B,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAE1B,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,GAAG,CAAC,CAAC;IACvE,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;AACxD,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -7,18 +7,18 @@ export interface Person {
|
|
|
7
7
|
email: string | null;
|
|
8
8
|
roles: string[];
|
|
9
9
|
accountOwner: boolean;
|
|
10
|
-
createdDate:
|
|
11
|
-
lastModifiedDate:
|
|
10
|
+
createdDate: Date | null;
|
|
11
|
+
lastModifiedDate: Date | null;
|
|
12
12
|
}
|
|
13
13
|
export interface Account {
|
|
14
14
|
id: number | null;
|
|
15
15
|
name: string | null;
|
|
16
16
|
description: string | null;
|
|
17
17
|
owner: Person | null;
|
|
18
|
-
approval: boolean;
|
|
18
|
+
approval: boolean | null;
|
|
19
19
|
approvalDescription: string | null;
|
|
20
|
-
createdDate:
|
|
21
|
-
lastModifiedDate:
|
|
20
|
+
createdDate: Date | null;
|
|
21
|
+
lastModifiedDate: Date | null;
|
|
22
22
|
}
|
|
23
23
|
export interface Token {
|
|
24
24
|
requestUrl: string | null;
|
|
@@ -74,7 +74,30 @@ export interface Holding {
|
|
|
74
74
|
availableCash: number;
|
|
75
75
|
securities: Security[];
|
|
76
76
|
}
|
|
77
|
-
|
|
77
|
+
/**
|
|
78
|
+
* The position in one market, or null if the holder has none.
|
|
79
|
+
*
|
|
80
|
+
* Was a throw. Having no position in a market is ordinary — it is what every
|
|
81
|
+
* holding looks like before the first allocation — so asking is a question, not
|
|
82
|
+
* a mistake, and an Error said the caller had erred when they had only asked.
|
|
83
|
+
*/
|
|
84
|
+
export declare function getSecurity(holding: Holding, marketId: number): Security | null;
|
|
85
|
+
/**
|
|
86
|
+
* Positions in market order, never null.
|
|
87
|
+
*
|
|
88
|
+
* Applied where a Holding is built, so `securities` is already ordered by the
|
|
89
|
+
* time a caller sees it — reading it and reading `holdingUnits` cannot disagree,
|
|
90
|
+
* and two holdings of the same positions compare the same way.
|
|
91
|
+
*/
|
|
92
|
+
export declare function orderedSecurities(securities: Security[] | null | undefined): Security[];
|
|
93
|
+
/**
|
|
94
|
+
* Approved, treating "not yet decided" as not approved.
|
|
95
|
+
*
|
|
96
|
+
* The third state is kept on the field and folded away here, at the point of
|
|
97
|
+
* asking. Folding it in the parser would lose the difference between a pending
|
|
98
|
+
* account and a suspended one for every caller at once.
|
|
99
|
+
*/
|
|
100
|
+
export declare function isApproved(account: Account): boolean;
|
|
78
101
|
export declare function holdingUnits(holding: Holding): number[];
|
|
79
102
|
export interface Market {
|
|
80
103
|
id: number;
|
|
@@ -90,7 +113,50 @@ export interface Market {
|
|
|
90
113
|
unitMaximum: number;
|
|
91
114
|
unitTick: number;
|
|
92
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* The legal values for one dimension of a market: a range, and a step.
|
|
118
|
+
*
|
|
119
|
+
* A market has two of these, and the server enforces both the same way — a
|
|
120
|
+
* value must lie within the bounds and satisfy `(value - minimum) % tick`.
|
|
121
|
+
* Naming the pair is what stops `createMarket` taking six adjacent numbers,
|
|
122
|
+
* where transposing the price tick and the unit minimum would post cleanly and
|
|
123
|
+
* produce a market nobody could trade in.
|
|
124
|
+
*
|
|
125
|
+
* A `tick` of zero marks a fixed dimension: the bounds are equal and there is
|
|
126
|
+
* one legal value.
|
|
127
|
+
*/
|
|
128
|
+
export interface TickGrid {
|
|
129
|
+
minimum: number;
|
|
130
|
+
maximum: number;
|
|
131
|
+
tick: number;
|
|
132
|
+
}
|
|
133
|
+
/** The usual unit dimension: whole units, one to a hundred. */
|
|
134
|
+
export declare function unitGrid(): TickGrid;
|
|
135
|
+
/** `value` moved down onto `grid`, clamped to it. */
|
|
136
|
+
export declare function gridRound(grid: TickGrid, value: number): number;
|
|
137
|
+
/**
|
|
138
|
+
* A value moved down onto a bounded tick grid.
|
|
139
|
+
*
|
|
140
|
+
* The server applies this rule twice, to price and to units, spelling it the
|
|
141
|
+
* same way both times: a value must lie within its bounds and satisfy
|
|
142
|
+
* `(value - minimum) % tick`. So the grid is anchored at the *minimum*, not at
|
|
143
|
+
* zero — this used to subtract `value % tick`, right whenever the floor happens
|
|
144
|
+
* to be a multiple of the tick and wrong for the rest in a way that yields a
|
|
145
|
+
* plausible number rather than an error.
|
|
146
|
+
*
|
|
147
|
+
* The ceiling is the highest legal tick rather than `maximum` itself, and a
|
|
148
|
+
* tick of zero marks a fixed dimension — which used to return NaN.
|
|
149
|
+
*/
|
|
150
|
+
export declare function tickRound(value: number, minimum: number, maximum: number, tick: number): number;
|
|
151
|
+
/** `price` moved down to the nearest price this market will accept. */
|
|
93
152
|
export declare function priceRound(market: Market, price: number): number;
|
|
153
|
+
/**
|
|
154
|
+
* `units` moved down to the nearest size this market will accept.
|
|
155
|
+
*
|
|
156
|
+
* The counterpart to {@link priceRound}, which did not exist even though the
|
|
157
|
+
* server checks units on exactly the same terms.
|
|
158
|
+
*/
|
|
159
|
+
export declare function unitRound(market: Market, units: number): number;
|
|
94
160
|
export interface Marketplace {
|
|
95
161
|
id: number;
|
|
96
162
|
name: string | null;
|
|
@@ -109,20 +175,57 @@ export interface Session {
|
|
|
109
175
|
state: string | null;
|
|
110
176
|
name: string | null;
|
|
111
177
|
description: string | null;
|
|
112
|
-
openDate:
|
|
113
|
-
closeDate:
|
|
178
|
+
openDate: Date | null;
|
|
179
|
+
closeDate: Date | null;
|
|
114
180
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
181
|
+
/**
|
|
182
|
+
* Which way an order goes.
|
|
183
|
+
*
|
|
184
|
+
* A literal union rather than a TypeScript `enum`: the values stay ordinary
|
|
185
|
+
* strings, so they serialise with no encoder, compare equal to the wire
|
|
186
|
+
* spelling, and a caller who was passing `"BUY"` keeps working. A TS `enum`
|
|
187
|
+
* would be a nominal type and would break every one of those.
|
|
188
|
+
*
|
|
189
|
+
* The invalid case still cannot be written -- `"BYU"` is a type error -- which
|
|
190
|
+
* is what the old `ORDER_SIDE_BUY` constant could only suggest.
|
|
191
|
+
*/
|
|
192
|
+
export type Side = "BUY" | "SELL";
|
|
193
|
+
/** The members, for callers who prefer a name to a literal. */
|
|
194
|
+
export declare const Side: {
|
|
195
|
+
readonly BUY: "BUY";
|
|
196
|
+
readonly SELL: "SELL";
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* What an order is: a bid or offer, or the withdrawal of one.
|
|
200
|
+
*
|
|
201
|
+
* There is no `MARKET`. The server's type switch shares its default with
|
|
202
|
+
* `LIMIT`, so a market order is a limit at the extreme legal price and
|
|
203
|
+
* `submitMarket` sends `LIMIT`; naming a member the exchange does not have
|
|
204
|
+
* would suggest otherwise.
|
|
205
|
+
*/
|
|
206
|
+
export type OrderType = "LIMIT" | "CANCEL";
|
|
207
|
+
export declare const OrderType: {
|
|
208
|
+
readonly LIMIT: "LIMIT";
|
|
209
|
+
readonly CANCEL: "CANCEL";
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
* The side a response names, or null if it names none or one this version does
|
|
213
|
+
* not know.
|
|
214
|
+
*
|
|
215
|
+
* Deliberately lenient, and case-insensitive as the old comparisons were.
|
|
216
|
+
* Refusing an unrecognised value would cost the caller a whole response -- an
|
|
217
|
+
* order list, a holdings snapshot -- over one field they may not read.
|
|
218
|
+
*/
|
|
219
|
+
export declare function toSide(value: string | null | undefined): Side | null;
|
|
220
|
+
/** Lenient for the same reason; the server has emitted `"MARKET"`. */
|
|
221
|
+
export declare function toOrderType(value: string | null | undefined): OrderType | null;
|
|
119
222
|
export interface Order {
|
|
120
223
|
id: number;
|
|
121
224
|
original: number;
|
|
122
225
|
supplier: number;
|
|
123
226
|
consumer: number | null;
|
|
124
|
-
type:
|
|
125
|
-
side:
|
|
227
|
+
type: OrderType | null;
|
|
228
|
+
side: Side | null;
|
|
126
229
|
units: number;
|
|
127
230
|
price: number;
|
|
128
231
|
ownerId: number | null;
|
|
@@ -132,15 +235,15 @@ export interface Order {
|
|
|
132
235
|
marketId: number;
|
|
133
236
|
ownerTarget: string | null;
|
|
134
237
|
clientDescription: string | null;
|
|
135
|
-
createdDate:
|
|
136
|
-
lastModifiedDate:
|
|
238
|
+
createdDate: Date | null;
|
|
239
|
+
lastModifiedDate: Date | null;
|
|
137
240
|
}
|
|
138
241
|
export interface ClientConnection {
|
|
139
242
|
marketplaceId: number;
|
|
140
243
|
connectionId: number;
|
|
141
244
|
ownerId: number;
|
|
142
|
-
established:
|
|
143
|
-
terminated:
|
|
245
|
+
established: Date | null;
|
|
246
|
+
terminated: Date | null;
|
|
144
247
|
description: string | null;
|
|
145
248
|
/**
|
|
146
249
|
* The session the connection was attached during, or null when the
|
|
@@ -150,13 +253,32 @@ export interface ClientConnection {
|
|
|
150
253
|
*/
|
|
151
254
|
sessionId: number | null;
|
|
152
255
|
}
|
|
256
|
+
export interface ManagerOtpEntry {
|
|
257
|
+
userId: number;
|
|
258
|
+
email: string | null;
|
|
259
|
+
otp: string | null;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* One-time passcodes a manager mints on behalf of their users.
|
|
263
|
+
*
|
|
264
|
+
* Credentials, and short-lived: `expiresAt` is when the whole bundle stops
|
|
265
|
+
* working, not a per-entry deadline. This is how a classroom signs in without
|
|
266
|
+
* passwords being handed around, which is also why nothing here should be
|
|
267
|
+
* logged.
|
|
268
|
+
*/
|
|
269
|
+
export interface ManagerOtpBundle {
|
|
270
|
+
expiresAt: Date | null;
|
|
271
|
+
otps: ManagerOtpEntry[];
|
|
272
|
+
}
|
|
273
|
+
/** The server's answer to an approval request. */
|
|
274
|
+
export interface Approval {
|
|
275
|
+
account: Account | null;
|
|
276
|
+
description: string | null;
|
|
277
|
+
approve: boolean | null;
|
|
278
|
+
}
|
|
153
279
|
export interface Version {
|
|
154
280
|
version: number;
|
|
155
281
|
}
|
|
156
|
-
export interface ApiRoot {
|
|
157
|
-
links: Record<string, string>;
|
|
158
|
-
}
|
|
159
|
-
export declare function getLink(root: ApiRoot, name: string): string | undefined;
|
|
160
282
|
export interface ConflictFailure {
|
|
161
283
|
status: string | null;
|
|
162
284
|
error: string | null;
|
package/dist/types.js
CHANGED
|
@@ -1,27 +1,106 @@
|
|
|
1
1
|
/** Flexemarkets domain models. */
|
|
2
|
+
/**
|
|
3
|
+
* The position in one market, or null if the holder has none.
|
|
4
|
+
*
|
|
5
|
+
* Was a throw. Having no position in a market is ordinary — it is what every
|
|
6
|
+
* holding looks like before the first allocation — so asking is a question, not
|
|
7
|
+
* a mistake, and an Error said the caller had erred when they had only asked.
|
|
8
|
+
*/
|
|
2
9
|
export function getSecurity(holding, marketId) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
10
|
+
return holding.securities.find((s) => s.marketId === marketId) ?? null;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Positions in market order, never null.
|
|
14
|
+
*
|
|
15
|
+
* Applied where a Holding is built, so `securities` is already ordered by the
|
|
16
|
+
* time a caller sees it — reading it and reading `holdingUnits` cannot disagree,
|
|
17
|
+
* and two holdings of the same positions compare the same way.
|
|
18
|
+
*/
|
|
19
|
+
export function orderedSecurities(securities) {
|
|
20
|
+
return [...(securities ?? [])].sort((a, b) => a.marketId - b.marketId);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Approved, treating "not yet decided" as not approved.
|
|
24
|
+
*
|
|
25
|
+
* The third state is kept on the field and folded away here, at the point of
|
|
26
|
+
* asking. Folding it in the parser would lose the difference between a pending
|
|
27
|
+
* account and a suspended one for every caller at once.
|
|
28
|
+
*/
|
|
29
|
+
export function isApproved(account) {
|
|
30
|
+
return account.approval === true;
|
|
7
31
|
}
|
|
8
32
|
export function holdingUnits(holding) {
|
|
9
|
-
return
|
|
10
|
-
|
|
11
|
-
|
|
33
|
+
return holding.securities.map((s) => s.units);
|
|
34
|
+
}
|
|
35
|
+
/** The usual unit dimension: whole units, one to a hundred. */
|
|
36
|
+
export function unitGrid() {
|
|
37
|
+
return { minimum: 1, maximum: 100, tick: 1 };
|
|
38
|
+
}
|
|
39
|
+
/** `value` moved down onto `grid`, clamped to it. */
|
|
40
|
+
export function gridRound(grid, value) {
|
|
41
|
+
return tickRound(value, grid.minimum, grid.maximum, grid.tick);
|
|
12
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* A value moved down onto a bounded tick grid.
|
|
45
|
+
*
|
|
46
|
+
* The server applies this rule twice, to price and to units, spelling it the
|
|
47
|
+
* same way both times: a value must lie within its bounds and satisfy
|
|
48
|
+
* `(value - minimum) % tick`. So the grid is anchored at the *minimum*, not at
|
|
49
|
+
* zero — this used to subtract `value % tick`, right whenever the floor happens
|
|
50
|
+
* to be a multiple of the tick and wrong for the rest in a way that yields a
|
|
51
|
+
* plausible number rather than an error.
|
|
52
|
+
*
|
|
53
|
+
* The ceiling is the highest legal tick rather than `maximum` itself, and a
|
|
54
|
+
* tick of zero marks a fixed dimension — which used to return NaN.
|
|
55
|
+
*/
|
|
56
|
+
export function tickRound(value, minimum, maximum, tick) {
|
|
57
|
+
if (tick <= 0)
|
|
58
|
+
return Math.min(Math.max(value, minimum), maximum);
|
|
59
|
+
const highest = minimum + Math.floor((maximum - minimum) / tick) * tick;
|
|
60
|
+
const rounded = minimum + Math.floor((value - minimum) / tick) * tick;
|
|
61
|
+
return Math.min(Math.max(rounded, minimum), highest);
|
|
62
|
+
}
|
|
63
|
+
/** `price` moved down to the nearest price this market will accept. */
|
|
13
64
|
export function priceRound(market, price) {
|
|
14
|
-
return
|
|
65
|
+
return tickRound(price, market.priceMinimum, market.priceMaximum, market.priceTick);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* `units` moved down to the nearest size this market will accept.
|
|
69
|
+
*
|
|
70
|
+
* The counterpart to {@link priceRound}, which did not exist even though the
|
|
71
|
+
* server checks units on exactly the same terms.
|
|
72
|
+
*/
|
|
73
|
+
export function unitRound(market, units) {
|
|
74
|
+
return tickRound(units, market.unitMinimum, market.unitMaximum, market.unitTick);
|
|
15
75
|
}
|
|
16
76
|
export const SESSION_STATE_INIT = "INIT";
|
|
17
77
|
export const SESSION_STATE_OPEN = "OPEN";
|
|
18
78
|
export const SESSION_STATE_PAUSED = "PAUSED";
|
|
19
79
|
export const SESSION_STATE_CLOSED = "CLOSED";
|
|
20
|
-
|
|
21
|
-
export const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
80
|
+
/** The members, for callers who prefer a name to a literal. */
|
|
81
|
+
export const Side = {
|
|
82
|
+
BUY: "BUY",
|
|
83
|
+
SELL: "SELL",
|
|
84
|
+
};
|
|
85
|
+
export const OrderType = {
|
|
86
|
+
LIMIT: "LIMIT",
|
|
87
|
+
CANCEL: "CANCEL",
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* The side a response names, or null if it names none or one this version does
|
|
91
|
+
* not know.
|
|
92
|
+
*
|
|
93
|
+
* Deliberately lenient, and case-insensitive as the old comparisons were.
|
|
94
|
+
* Refusing an unrecognised value would cost the caller a whole response -- an
|
|
95
|
+
* order list, a holdings snapshot -- over one field they may not read.
|
|
96
|
+
*/
|
|
97
|
+
export function toSide(value) {
|
|
98
|
+
const upper = value?.trim().toUpperCase();
|
|
99
|
+
return upper === "BUY" || upper === "SELL" ? upper : null;
|
|
100
|
+
}
|
|
101
|
+
/** Lenient for the same reason; the server has emitted `"MARKET"`. */
|
|
102
|
+
export function toOrderType(value) {
|
|
103
|
+
const upper = value?.trim().toUpperCase();
|
|
104
|
+
return upper === "LIMIT" || upper === "CANCEL" ? upper : null;
|
|
26
105
|
}
|
|
27
106
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAoFlC,MAAM,UAAU,WAAW,CAAC,OAAgB,EAAE,QAAgB;IAC5D,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAoFlC;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,OAAgB,EAAE,QAAgB;IAC5D,OAAO,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,IAAI,IAAI,CAAC;AACzE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAAyC;IACzE,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,EAAE,CAAC,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