@flexemarkets/fm-sdk 0.17.0 → 0.19.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/README.md +1 -1
- package/dist/client.d.ts +47 -10
- package/dist/client.js +248 -80
- package/dist/client.js.map +1 -1
- package/dist/desk.d.ts +50 -5
- package/dist/desk.js +110 -35
- package/dist/desk.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/order-stream.js +1 -2
- package/dist/order-stream.js.map +1 -1
- package/dist/orderbook.js +5 -0
- package/dist/orderbook.js.map +1 -1
- package/dist/rest-orders.d.ts +52 -0
- package/dist/rest-orders.js +102 -0
- package/dist/rest-orders.js.map +1 -0
- package/dist/stomp.d.ts +26 -4
- package/dist/stomp.js +82 -18
- package/dist/stomp.js.map +1 -1
- package/dist/types.d.ts +10 -0
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ TypeScript / JavaScript SDK for the [Flexemarkets](https://api.flexemarkets.com)
|
|
|
13
13
|
>
|
|
14
14
|
> Pin an exact version rather than a range (`"@flexemarkets/fm-sdk": "0.2.0"`,
|
|
15
15
|
> not `^0.2.0`), read the
|
|
16
|
-
> [upgrade notes](https://github.com/flexemarkets/fm-sdk/
|
|
16
|
+
> [upgrade notes](https://github.com/flexemarkets/fm-sdk/blob/main/docs/UPGRADING.md) for the
|
|
17
17
|
> release you are moving to, and expect to change code when you move.
|
|
18
18
|
>
|
|
19
19
|
> Not recommended for production use.
|
package/dist/client.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Port of fm.client (Python) / fm.Flexemarkets (Java).
|
|
5
5
|
*/
|
|
6
|
-
import type { Account, Allotment, CallIndicative, CurrentSession, ClientConnection, Holding, ManagerOtpBundle, Market, MarketCall, Marketplace, Limit, Order, ParticipantState, Person, Security, Session, TickGrid, Token, Widget, WidgetPush, MarketplaceRobot, RobotParameterConfig, RobotParameterControl } from "./types.js";
|
|
6
|
+
import type { Account, Allotment, CallIndicative, CurrentSession, ClientConnection, Holding, ManagerOtpBundle, Market, MarketCall, Marketplace, Limit, Order, OrderRoute, ParticipantState, Person, Security, Session, TickGrid, Token, Widget, WidgetPush, MarketplaceRobot, RobotParameterConfig, RobotParameterControl } from "./types.js";
|
|
7
7
|
import { EventListener, type EventCallback } from "./stomp.js";
|
|
8
8
|
import { PendingOrder } from "./order-stream.js";
|
|
9
9
|
import { type Desk, type Subscription } from "./desk.js";
|
|
@@ -191,6 +191,7 @@ export declare const requestTimeout: {
|
|
|
191
191
|
ms: number;
|
|
192
192
|
};
|
|
193
193
|
export declare class Flexemarkets {
|
|
194
|
+
private readonly _orderRoute;
|
|
194
195
|
private readonly _clientDescription;
|
|
195
196
|
private readonly _endpoint;
|
|
196
197
|
private readonly _baseUrl;
|
|
@@ -211,8 +212,17 @@ export declare class Flexemarkets {
|
|
|
211
212
|
private _user;
|
|
212
213
|
private _eventListener;
|
|
213
214
|
private constructor();
|
|
214
|
-
/**
|
|
215
|
-
|
|
215
|
+
/**
|
|
216
|
+
* Connect to the Flexemarkets API.
|
|
217
|
+
*
|
|
218
|
+
* `options.orderRoute` is how {@link sendLimit} and {@link sendCancel} send
|
|
219
|
+
* this client's orders, for its whole life: `"SOCKET"`, the default, or
|
|
220
|
+
* `"REST"`, batches over REST for a caller that cannot hold a socket open
|
|
221
|
+
* (see {@link OrderRoute}).
|
|
222
|
+
*/
|
|
223
|
+
static connect(credential?: string | null, endpoint?: string | null, clientDescription?: string | null, options?: {
|
|
224
|
+
orderRoute?: OrderRoute | string;
|
|
225
|
+
}): Promise<Flexemarkets>;
|
|
216
226
|
get account(): Account;
|
|
217
227
|
get accountId(): number;
|
|
218
228
|
get accountName(): string;
|
|
@@ -296,9 +306,9 @@ export declare class Flexemarkets {
|
|
|
296
306
|
* V1 approves an account by id; the name is looked up in the account list
|
|
297
307
|
* first, so callers keep naming the account they signed up.
|
|
298
308
|
*/
|
|
299
|
-
approveAccount(accountName: string): Promise<Account
|
|
309
|
+
approveAccount(accountName: string): Promise<Account>;
|
|
300
310
|
/** One account by id. */
|
|
301
|
-
accountById(accountId: number): Promise<Account
|
|
311
|
+
accountById(accountId: number): Promise<Account>;
|
|
302
312
|
/** One user by id. */
|
|
303
313
|
userById(userId: number): Promise<Person>;
|
|
304
314
|
/**
|
|
@@ -483,6 +493,13 @@ export declare class Flexemarkets {
|
|
|
483
493
|
* stays open until {@link close}; at most `MAX_IN_FLIGHT` orders are
|
|
484
494
|
* unanswered at once, and this waits, in turn, while they are. The arguments
|
|
485
495
|
* are {@link submitLimit}'s. See docs/SUBMIT-RATE.md.
|
|
496
|
+
*
|
|
497
|
+
* On a client connected with `orderRoute: "REST"` the order goes over REST
|
|
498
|
+
* instead: one `POST .../orders/batch` is in flight at a time, and the orders
|
|
499
|
+
* sent while it is out -- at most 64 -- go together as the next, in the order
|
|
500
|
+
* sent. Its `result()` is then the order or the refusal, or
|
|
501
|
+
* {@link OrderOutcomeUnknownError} if the request was sent twice without a
|
|
502
|
+
* readable answer. Needs fm-server 4.19.
|
|
486
503
|
*/
|
|
487
504
|
sendLimit(marketplaceId: number, marketId: number, side: string, units: number, price: number, options?: {
|
|
488
505
|
ownerTarget?: string;
|
|
@@ -507,9 +524,18 @@ export declare class Flexemarkets {
|
|
|
507
524
|
* docs/SUBMIT-RATE.md, section 5.
|
|
508
525
|
*/
|
|
509
526
|
submitLimits(marketplaceId: number, limits: readonly Limit[]): Promise<PendingOrder[]>;
|
|
527
|
+
/**
|
|
528
|
+
* One `POST .../orders/batch`, sent once more, whole, if its answer was lost:
|
|
529
|
+
* each order's placed order, or the error its refusal throws.
|
|
530
|
+
*/
|
|
531
|
+
private _postBatch;
|
|
510
532
|
/** The body of a limit order, named with a fresh submission id. */
|
|
511
533
|
private _limitOrder;
|
|
512
|
-
/**
|
|
534
|
+
/**
|
|
535
|
+
* Where the marketplace's sent orders go, by this client's {@link OrderRoute}:
|
|
536
|
+
* its order socket, opened on first use (one open for concurrent first
|
|
537
|
+
* callers), or its REST window.
|
|
538
|
+
*/
|
|
513
539
|
private _orderStream;
|
|
514
540
|
/**
|
|
515
541
|
* Cross the book: buy at the highest price this market allows, sell at the
|
|
@@ -552,11 +578,22 @@ export declare class Flexemarkets {
|
|
|
552
578
|
* {@link submitLimit} answered, its `id`. Unlike {@link submitCancel}'s DELETE,
|
|
553
579
|
* which looks the order up, the socket's CANCEL goes to the exchange as named,
|
|
554
580
|
* and the id of a fragment a split left behind matches nothing -- the CANCEL is
|
|
555
|
-
* recorded, consumed by itself, and nothing is cancelled.
|
|
556
|
-
* answered has no id and cannot be cancelled this way. `marketId` goes on the
|
|
581
|
+
* recorded, consumed by itself, and nothing is cancelled. `marketId` goes on the
|
|
557
582
|
* wire: the socket's CANCEL names its market.
|
|
558
|
-
|
|
559
|
-
|
|
583
|
+
*
|
|
584
|
+
* An order not yet answered has no id, but it has its
|
|
585
|
+
* {@link PendingOrder.submissionId} from the moment it is sent. Given that string
|
|
586
|
+
* in place of an id, which needs fm-server 4.20, the cancel names the order by it
|
|
587
|
+
* alone and can go right behind its {@link sendLimit}: it goes through the same
|
|
588
|
+
* window, and fm-server takes them in the order sent, on the socket and on the
|
|
589
|
+
* REST route alike. A split is no concern, as fm-server finds the order and
|
|
590
|
+
* cancels through its original, and `marketId` is not on the wire, as the order
|
|
591
|
+
* names its own market. Only the caller's own LIMIT orders are found. One it has
|
|
592
|
+
* none of in the marketplace, which includes a limit that was itself refused, is
|
|
593
|
+
* refused as not found: 404 `ORDER_NOT_IN_MARKETPLACE` on either route. fm-server
|
|
594
|
+
* 4.23 and earlier answer it 400 `ORDER_INVALID` on the socket.
|
|
595
|
+
*/
|
|
596
|
+
sendCancel(marketplaceId: number, marketId: number, originalId: number | string): Promise<PendingOrder>;
|
|
560
597
|
/**
|
|
561
598
|
* The active-orders snapshot: every resting limit order on the
|
|
562
599
|
* marketplace's current session, plus the `x-fm-as-of-seq` sequence
|