nodejs-order-book 8.0.1 → 8.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/README.md +29 -1
- package/dist/cjs/orderbook.js +130 -109
- package/dist/esm/orderbook.js +130 -109
- package/dist/types/orderbook.d.ts +1 -45
- package/dist/types/types.d.ts +53 -15
- package/dist/umd/index.js +1 -1
- package/package.json +9 -5
package/dist/esm/orderbook.js
CHANGED
|
@@ -44,7 +44,16 @@ var OrderBook = /** @class */ (function () {
|
|
|
44
44
|
/* node:coverage ignore next 4 - We don't need test for this */
|
|
45
45
|
if (!_this.experimentalConditionalOrders)
|
|
46
46
|
throw new Error("In order to use conditional orders you need to instantiate the order book with the `experimentalConditionalOrders` option set to true");
|
|
47
|
-
|
|
47
|
+
var response = _this._stopMarket(options);
|
|
48
|
+
if (_this.enableJournaling && response.err === null) {
|
|
49
|
+
response.log = {
|
|
50
|
+
opId: ++_this._lastOp,
|
|
51
|
+
ts: Date.now(),
|
|
52
|
+
op: "sm",
|
|
53
|
+
o: options,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return response;
|
|
48
57
|
};
|
|
49
58
|
/**
|
|
50
59
|
* Create a stop limit order. See {@link StopLimitOrderOptions} for details.
|
|
@@ -62,7 +71,16 @@ var OrderBook = /** @class */ (function () {
|
|
|
62
71
|
/* node:coverage ignore next 4 - We don't need test for this */
|
|
63
72
|
if (!_this.experimentalConditionalOrders)
|
|
64
73
|
throw new Error("In order to use conditional orders you need to instantiate the order book with the `experimentalConditionalOrders` option set to true");
|
|
65
|
-
|
|
74
|
+
var response = _this._stopLimit(options);
|
|
75
|
+
if (_this.enableJournaling && response.err === null) {
|
|
76
|
+
response.log = {
|
|
77
|
+
opId: ++_this._lastOp,
|
|
78
|
+
ts: Date.now(),
|
|
79
|
+
op: "sl",
|
|
80
|
+
o: options,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return response;
|
|
66
84
|
};
|
|
67
85
|
/**
|
|
68
86
|
* Create an OCO (One-Cancels-the-Other) order.
|
|
@@ -91,7 +109,16 @@ var OrderBook = /** @class */ (function () {
|
|
|
91
109
|
/* node:coverage ignore next 4 - We don't need test for this */
|
|
92
110
|
if (!_this.experimentalConditionalOrders)
|
|
93
111
|
throw new Error("In order to use conditional orders you need to instantiate the order book with the `experimentalConditionalOrders` option set to true");
|
|
94
|
-
|
|
112
|
+
var response = _this._oco(options);
|
|
113
|
+
if (_this.enableJournaling && response.err === null) {
|
|
114
|
+
response.log = {
|
|
115
|
+
opId: ++_this._lastOp,
|
|
116
|
+
ts: Date.now(),
|
|
117
|
+
op: "oco",
|
|
118
|
+
o: options,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
return response;
|
|
95
122
|
};
|
|
96
123
|
/**
|
|
97
124
|
* Modify an existing order with given ID. When an order is modified by price or quantity,
|
|
@@ -225,7 +252,7 @@ var OrderBook = /** @class */ (function () {
|
|
|
225
252
|
};
|
|
226
253
|
this._market = function (options, incomingResponse) {
|
|
227
254
|
var response = incomingResponse !== null && incomingResponse !== void 0 ? incomingResponse : _this.validateMarketOrder(options);
|
|
228
|
-
if (response.err
|
|
255
|
+
if (response.err !== null)
|
|
229
256
|
return response;
|
|
230
257
|
var quantityToTrade = options.size;
|
|
231
258
|
var iter;
|
|
@@ -250,41 +277,19 @@ var OrderBook = /** @class */ (function () {
|
|
|
250
277
|
}
|
|
251
278
|
response.quantityLeft = quantityToTrade;
|
|
252
279
|
_this.executeConditionalOrder(options.side, priceBefore, response);
|
|
253
|
-
if (_this.enableJournaling) {
|
|
254
|
-
response.log = {
|
|
255
|
-
opId: ++_this._lastOp,
|
|
256
|
-
ts: Date.now(),
|
|
257
|
-
op: "m",
|
|
258
|
-
o: { side: options.side, size: options.size },
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
280
|
return response;
|
|
262
281
|
};
|
|
263
282
|
this._limit = function (options, incomingResponse) {
|
|
264
283
|
var _a, _b;
|
|
265
284
|
var response = incomingResponse !== null && incomingResponse !== void 0 ? incomingResponse : _this.validateLimitOrder(options);
|
|
266
|
-
if (response.err
|
|
285
|
+
if (response.err !== null)
|
|
267
286
|
return response;
|
|
268
|
-
|
|
269
|
-
if (_this.enableJournaling && order != null) {
|
|
270
|
-
response.log = {
|
|
271
|
-
opId: ++_this._lastOp,
|
|
272
|
-
ts: Date.now(),
|
|
273
|
-
op: "l",
|
|
274
|
-
o: {
|
|
275
|
-
side: order.side,
|
|
276
|
-
id: order.id,
|
|
277
|
-
size: order.size,
|
|
278
|
-
price: order.price,
|
|
279
|
-
timeInForce: order.timeInForce,
|
|
280
|
-
},
|
|
281
|
-
};
|
|
282
|
-
}
|
|
287
|
+
_this.createLimitOrder(response, options.side, options.id, options.size, options.price, (_a = options.postOnly) !== null && _a !== void 0 ? _a : false, (_b = options.timeInForce) !== null && _b !== void 0 ? _b : TimeInForce.GTC, options.ocoStopPrice);
|
|
283
288
|
return response;
|
|
284
289
|
};
|
|
285
290
|
this._stopMarket = function (options) {
|
|
286
291
|
var response = _this.validateMarketOrder(options);
|
|
287
|
-
if (response.err
|
|
292
|
+
if (response.err !== null)
|
|
288
293
|
return response;
|
|
289
294
|
var stopMarket = OrderFactory.createOrder(__assign(__assign({}, options), { type: OrderType.STOP_MARKET }));
|
|
290
295
|
return _this._stopOrder(stopMarket, response);
|
|
@@ -292,7 +297,7 @@ var OrderBook = /** @class */ (function () {
|
|
|
292
297
|
this._stopLimit = function (options) {
|
|
293
298
|
var _a;
|
|
294
299
|
var response = _this.validateLimitOrder(options);
|
|
295
|
-
if (response.err
|
|
300
|
+
if (response.err !== null)
|
|
296
301
|
return response;
|
|
297
302
|
var stopLimit = OrderFactory.createOrder(__assign(__assign({}, options), { type: OrderType.STOP_LIMIT, timeInForce: (_a = options.timeInForce) !== null && _a !== void 0 ? _a : TimeInForce.GTC }));
|
|
298
303
|
return _this._stopOrder(stopLimit, response);
|
|
@@ -301,7 +306,7 @@ var OrderBook = /** @class */ (function () {
|
|
|
301
306
|
var _a;
|
|
302
307
|
var response = _this.validateLimitOrder(options);
|
|
303
308
|
/* node:coverage ignore next - Already validated with limit test */
|
|
304
|
-
if (response.err
|
|
309
|
+
if (response.err !== null)
|
|
305
310
|
return response;
|
|
306
311
|
if (_this.validateOCOOrder(options)) {
|
|
307
312
|
// We use the same ID for Stop Limit and Limit Order, since
|
|
@@ -315,7 +320,7 @@ var OrderBook = /** @class */ (function () {
|
|
|
315
320
|
ocoStopPrice: options.stopPrice,
|
|
316
321
|
}, response);
|
|
317
322
|
/* node:coverage ignore next - Already validated with limit test */
|
|
318
|
-
if (response.err
|
|
323
|
+
if (response.err !== null)
|
|
319
324
|
return response;
|
|
320
325
|
var stopLimit = OrderFactory.createOrder({
|
|
321
326
|
type: OrderType.STOP_LIMIT,
|
|
@@ -543,21 +548,48 @@ var OrderBook = /** @class */ (function () {
|
|
|
543
548
|
if (side == null || size == null) {
|
|
544
549
|
throw CustomError(ERROR.INVALID_JOURNAL_LOG);
|
|
545
550
|
}
|
|
546
|
-
_this.market(
|
|
551
|
+
_this.market(log.o);
|
|
547
552
|
break;
|
|
548
553
|
}
|
|
549
554
|
case "l": {
|
|
550
|
-
var _b = log.o, side = _b.side, id = _b.id, size = _b.size, price = _b.price
|
|
555
|
+
var _b = log.o, side = _b.side, id = _b.id, size = _b.size, price = _b.price;
|
|
551
556
|
if (side == null || id == null || size == null || price == null) {
|
|
552
557
|
throw CustomError(ERROR.INVALID_JOURNAL_LOG);
|
|
553
558
|
}
|
|
554
|
-
_this.limit(
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
559
|
+
_this.limit(log.o);
|
|
560
|
+
break;
|
|
561
|
+
}
|
|
562
|
+
case "sm": {
|
|
563
|
+
var _c = log.o, side = _c.side, size = _c.size, stopPrice = _c.stopPrice;
|
|
564
|
+
if (side == null || size == null || stopPrice == null) {
|
|
565
|
+
throw CustomError(ERROR.INVALID_JOURNAL_LOG);
|
|
566
|
+
}
|
|
567
|
+
_this.stopMarket(log.o);
|
|
568
|
+
break;
|
|
569
|
+
}
|
|
570
|
+
case "sl": {
|
|
571
|
+
var _d = log.o, side = _d.side, id = _d.id, size = _d.size, price = _d.price, stopPrice = _d.stopPrice;
|
|
572
|
+
if (side == null ||
|
|
573
|
+
id == null ||
|
|
574
|
+
size == null ||
|
|
575
|
+
price == null ||
|
|
576
|
+
stopPrice == null) {
|
|
577
|
+
throw CustomError(ERROR.INVALID_JOURNAL_LOG);
|
|
578
|
+
}
|
|
579
|
+
_this.stopLimit(log.o);
|
|
580
|
+
break;
|
|
581
|
+
}
|
|
582
|
+
case "oco": {
|
|
583
|
+
var _e = log.o, side = _e.side, id = _e.id, size = _e.size, price = _e.price, stopPrice = _e.stopPrice, stopLimitPrice = _e.stopLimitPrice;
|
|
584
|
+
if (side == null ||
|
|
585
|
+
id == null ||
|
|
586
|
+
size == null ||
|
|
587
|
+
price == null ||
|
|
588
|
+
stopPrice == null ||
|
|
589
|
+
stopLimitPrice == null) {
|
|
590
|
+
throw CustomError(ERROR.INVALID_JOURNAL_LOG);
|
|
591
|
+
}
|
|
592
|
+
_this.oco(log.o);
|
|
561
593
|
break;
|
|
562
594
|
}
|
|
563
595
|
case "d":
|
|
@@ -748,40 +780,23 @@ var OrderBook = /** @class */ (function () {
|
|
|
748
780
|
enumerable: false,
|
|
749
781
|
configurable: true
|
|
750
782
|
});
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
// @ts-expect-error
|
|
769
|
-
stopPrice: stopPrice,
|
|
770
|
-
// @ts-expect-error
|
|
771
|
-
stopLimitPrice: stopLimitPrice,
|
|
772
|
-
stopLimitTimeInForce: stopLimitTimeInForce,
|
|
773
|
-
postOnly: postOnly,
|
|
774
|
-
};
|
|
775
|
-
/* node:coverage enable */
|
|
776
|
-
}
|
|
777
|
-
else if (typeof typeOrOptions === "object") {
|
|
778
|
-
options = typeOrOptions;
|
|
779
|
-
/* node:coverage disable */
|
|
780
|
-
}
|
|
781
|
-
else {
|
|
782
|
-
throw new Error("Invalid arguments.");
|
|
783
|
-
}
|
|
784
|
-
/* node:coverage enable */
|
|
783
|
+
/**
|
|
784
|
+
* Create new order. See {@link CreateOrderOptions} for details.
|
|
785
|
+
*
|
|
786
|
+
* @param options
|
|
787
|
+
* @param options.type - `limit` | `market` | 'stop_limit' | 'stop_market' | 'oco'
|
|
788
|
+
* @param options.side - `sell` or `buy`
|
|
789
|
+
* @param options.size - How much of currency you want to trade in units of base currency
|
|
790
|
+
* @param options.price - The price at which the order is to be fullfilled, in units of the quote currency. Param only for limit order
|
|
791
|
+
* @param options.orderID - Unique order ID. Param only for limit order
|
|
792
|
+
* @param options.postOnly - Can be used with 'limit' order and when it's `true` the order will be rejected if immediately matches and trades as a taker. Default is `false`
|
|
793
|
+
* @param options.stopPrice - The price at which the order will be triggered. Used with `stop_limit` and `stop_market` order.
|
|
794
|
+
* @param options.stopLimitPrice - The price at which the order will be triggered. Used with `stop_limit` and `stop_market` order.
|
|
795
|
+
* @param options.timeInForce - Time-in-force supported are: `GTC` (default), `FOK`, `IOC`. Param only for limit order
|
|
796
|
+
* @param options.stopLimitTimeInForce - Time-in-force supported are: `GTC` (default), `FOK`, `IOC`. Param only for limit order
|
|
797
|
+
* @returns An object with the result of the processed order or an error. See {@link IProcessOrder} for the returned data structure
|
|
798
|
+
*/
|
|
799
|
+
OrderBook.prototype.createOrder = function (options) {
|
|
785
800
|
switch (options.type) {
|
|
786
801
|
case OrderType.MARKET:
|
|
787
802
|
return this.market(options);
|
|
@@ -804,43 +819,49 @@ var OrderBook = /** @class */ (function () {
|
|
|
804
819
|
};
|
|
805
820
|
}
|
|
806
821
|
};
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
822
|
+
/**
|
|
823
|
+
* Create a market order. See {@link MarketOrderOptions} for details.
|
|
824
|
+
*
|
|
825
|
+
* @param options
|
|
826
|
+
* @param options.side - `sell` or `buy`
|
|
827
|
+
* @param options.size - How much of currency you want to trade in units of base currency
|
|
828
|
+
* @returns An object with the result of the processed order or an error. See {@link IProcessOrder} for the returned data structure
|
|
829
|
+
*/
|
|
830
|
+
OrderBook.prototype.market = function (options) {
|
|
831
|
+
var response = this._market(options);
|
|
832
|
+
if (this.enableJournaling && response.err === null) {
|
|
833
|
+
response.log = {
|
|
834
|
+
opId: ++this._lastOp,
|
|
835
|
+
ts: Date.now(),
|
|
836
|
+
op: "m",
|
|
837
|
+
o: options,
|
|
838
|
+
};
|
|
817
839
|
}
|
|
818
|
-
|
|
819
|
-
/* node:coverage enable */
|
|
840
|
+
return response;
|
|
820
841
|
};
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
842
|
+
/**
|
|
843
|
+
* Create a limit order. See {@link LimitOrderOptions} for details.
|
|
844
|
+
*
|
|
845
|
+
* @param options
|
|
846
|
+
* @param options.side - `sell` or `buy`
|
|
847
|
+
* @param options.id - Unique order ID
|
|
848
|
+
* @param options.size - How much of currency you want to trade in units of base currency
|
|
849
|
+
* @param options.price - The price at which the order is to be fullfilled, in units of the quote currency
|
|
850
|
+
* @param options.postOnly - When `true` the order will be rejected if immediately matches and trades as a taker. Default is `false`
|
|
851
|
+
* @param options.timeInForce - Time-in-force type supported are: GTC, FOK, IOC. Default is GTC
|
|
852
|
+
* @returns An object with the result of the processed order or an error. See {@link IProcessOrder} for the returned data structure
|
|
853
|
+
*/
|
|
854
|
+
OrderBook.prototype.limit = function (options) {
|
|
855
|
+
var response = this._limit(options);
|
|
856
|
+
if (this.enableJournaling && response.err === null) {
|
|
857
|
+
response.log = {
|
|
858
|
+
opId: ++this._lastOp,
|
|
859
|
+
ts: Date.now(),
|
|
860
|
+
op: "l",
|
|
861
|
+
o: options,
|
|
862
|
+
};
|
|
841
863
|
}
|
|
842
|
-
|
|
843
|
-
/* node:coverage enable */
|
|
864
|
+
return response;
|
|
844
865
|
};
|
|
845
866
|
return OrderBook;
|
|
846
867
|
}());
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type OrderBookError } from "./errors";
|
|
2
2
|
import { type LimitOrder } from "./order";
|
|
3
|
-
import { type CreateOrderOptions, type ICancelOrder, type IProcessOrder, type LimitOrderOptions, type MarketOrderOptions, type OCOOrderOptions, type OrderBookOptions,
|
|
3
|
+
import { type CreateOrderOptions, type ICancelOrder, type IProcessOrder, type LimitOrderOptions, type MarketOrderOptions, type OCOOrderOptions, type OrderBookOptions, type OrderUpdatePrice, type OrderUpdateSize, Side, type Snapshot, type StopLimitOrderOptions, type StopMarketOrderOptions } from "./types";
|
|
4
4
|
export declare class OrderBook {
|
|
5
5
|
private orders;
|
|
6
6
|
private _lastOp;
|
|
@@ -38,25 +38,6 @@ export declare class OrderBook {
|
|
|
38
38
|
* @returns An object with the result of the processed order or an error. See {@link IProcessOrder} for the returned data structure
|
|
39
39
|
*/
|
|
40
40
|
createOrder(options: CreateOrderOptions): IProcessOrder;
|
|
41
|
-
/**
|
|
42
|
-
* @deprecated This implementation has been deprecated and will be removed on v7.0.0.
|
|
43
|
-
* Use createOrder({ type, side, size, price, id, timeInForce }) instead.
|
|
44
|
-
*
|
|
45
|
-
* Create a trade order
|
|
46
|
-
*
|
|
47
|
-
* @param type - `limit` | `market` | 'stop_limit' | 'stop_market' | 'oco'
|
|
48
|
-
* @param side - `sell` or `buy`
|
|
49
|
-
* @param size - How much of currency you want to trade in units of base currency
|
|
50
|
-
* @param price - The price at which the order is to be fullfilled, in units of the quote currency. Param only for limit order
|
|
51
|
-
* @param orderID - Unique order ID. Param only for limit order
|
|
52
|
-
* @param timeInForce - Time-in-force supported are: `GTC` (default), `FOK`, `IOC`. Param only for limit order
|
|
53
|
-
* @param stopPrice - The price at which the order will be triggered. Used with `stop_limit` and `stop_market` order.
|
|
54
|
-
* @param stopLimitPrice - The price at which the order will be triggered. Used with `stop_limit` and `stop_market` order.
|
|
55
|
-
* @param stopLimitTimeInForce - Time-in-force supported are: `GTC` (default), `FOK`, `IOC`. Param only for limit order
|
|
56
|
-
* @param postOnly - Can be used with 'limit' order and when it's `true` the order will be rejected if immediately matches and trades as a taker. Default is `false`
|
|
57
|
-
* @returns An object with the result of the processed order or an error. See {@link IProcessOrder} for the returned data structure
|
|
58
|
-
*/
|
|
59
|
-
createOrder(type: OrderType, side: Side, size: number, price?: number, orderID?: string, timeInForce?: TimeInForce, stopPrice?: number, stopLimitPrice?: number, stopLimitTimeInForce?: TimeInForce, postOnly?: boolean): IProcessOrder;
|
|
60
41
|
/**
|
|
61
42
|
* Create a market order. See {@link MarketOrderOptions} for details.
|
|
62
43
|
*
|
|
@@ -66,17 +47,6 @@ export declare class OrderBook {
|
|
|
66
47
|
* @returns An object with the result of the processed order or an error. See {@link IProcessOrder} for the returned data structure
|
|
67
48
|
*/
|
|
68
49
|
market(options: MarketOrderOptions): IProcessOrder;
|
|
69
|
-
/**
|
|
70
|
-
* @deprecated This implementation has been deprecated and will be removed on v7.0.0.
|
|
71
|
-
* Use market({ side, size }) instead.
|
|
72
|
-
*
|
|
73
|
-
* Create a market order
|
|
74
|
-
*
|
|
75
|
-
* @param side - `sell` or `buy`
|
|
76
|
-
* @param size - How much of currency you want to trade in units of base currency
|
|
77
|
-
* @returns An object with the result of the processed order or an error. See {@link IProcessOrder} for the returned data structure
|
|
78
|
-
*/
|
|
79
|
-
market(side: Side, size: number): IProcessOrder;
|
|
80
50
|
/**
|
|
81
51
|
* Create a stop market order. See {@link StopMarketOrderOptions} for details.
|
|
82
52
|
*
|
|
@@ -100,20 +70,6 @@ export declare class OrderBook {
|
|
|
100
70
|
* @returns An object with the result of the processed order or an error. See {@link IProcessOrder} for the returned data structure
|
|
101
71
|
*/
|
|
102
72
|
limit(options: LimitOrderOptions): IProcessOrder;
|
|
103
|
-
/**
|
|
104
|
-
* @deprecated This implementation has been deprecated and will be removed on v7.0.0.
|
|
105
|
-
* Use limit({ id, side, size, price, timeInForce }) instead.
|
|
106
|
-
*
|
|
107
|
-
* Create a limit order
|
|
108
|
-
*
|
|
109
|
-
* @param side - `sell` or `buy`
|
|
110
|
-
* @param orderID - Unique order ID
|
|
111
|
-
* @param size - How much of currency you want to trade in units of base currency
|
|
112
|
-
* @param price - The price at which the order is to be fullfilled, in units of the quote currency
|
|
113
|
-
* @param timeInForce - Time-in-force type supported are: GTC, FOK, IOC. Default is GTC
|
|
114
|
-
* @returns An object with the result of the processed order or an error. See {@link IProcessOrder} for the returned data structure
|
|
115
|
-
*/
|
|
116
|
-
limit(side: Side, orderID: string, size: number, price: number, timeInForce?: TimeInForce): IProcessOrder;
|
|
117
73
|
/**
|
|
118
74
|
* Create a stop limit order. See {@link StopLimitOrderOptions} for details.
|
|
119
75
|
*
|
package/dist/types/types.d.ts
CHANGED
|
@@ -88,7 +88,6 @@ export interface InternalStopLimitOrderOptions extends ILimitOrderOptions {
|
|
|
88
88
|
* Specific options for oco order.
|
|
89
89
|
*/
|
|
90
90
|
export interface OCOOrderOptions extends StopLimitOrderOptions {
|
|
91
|
-
stopPrice: number;
|
|
92
91
|
stopLimitPrice: number;
|
|
93
92
|
stopLimitTimeInForce?: TimeInForce;
|
|
94
93
|
}
|
|
@@ -185,19 +184,10 @@ export interface CancelOrderOptions {
|
|
|
185
184
|
/** Unique identifier of the order. */
|
|
186
185
|
orderID: string;
|
|
187
186
|
}
|
|
188
|
-
/**
|
|
189
|
-
* Represents a cancel order operation.
|
|
190
|
-
*/
|
|
191
|
-
export interface ICancelOrder {
|
|
192
|
-
order: LimitOrder;
|
|
193
|
-
stopOrder?: StopOrder;
|
|
194
|
-
/** Optional log related to the order cancellation. */
|
|
195
|
-
log?: CancelOrderJournalLog;
|
|
196
|
-
}
|
|
197
187
|
/**
|
|
198
188
|
* Represents a log entry for a market order operation.
|
|
199
189
|
*/
|
|
200
|
-
|
|
190
|
+
interface MarketOrderJournalLog {
|
|
201
191
|
/** Incremental ID of the operation */
|
|
202
192
|
opId: number;
|
|
203
193
|
/** Timestamp of the operation. */
|
|
@@ -210,7 +200,7 @@ export interface MarketOrderJournalLog {
|
|
|
210
200
|
/**
|
|
211
201
|
* Represents a log entry for a limit order operation.
|
|
212
202
|
*/
|
|
213
|
-
|
|
203
|
+
interface LimitOrderJournalLog {
|
|
214
204
|
/** Incremental ID of the operation */
|
|
215
205
|
opId: number;
|
|
216
206
|
/** Timestamp of the operation. */
|
|
@@ -220,10 +210,49 @@ export interface LimitOrderJournalLog {
|
|
|
220
210
|
/** Specific options for the limit order. */
|
|
221
211
|
o: LimitOrderOptions;
|
|
222
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* Represents a log entry for a stop_market order operation.
|
|
215
|
+
*/
|
|
216
|
+
interface StopMarketOrderJournalLog {
|
|
217
|
+
/** Incremental ID of the operation */
|
|
218
|
+
opId: number;
|
|
219
|
+
/** Timestamp of the operation. */
|
|
220
|
+
ts: number;
|
|
221
|
+
/** Operation type: 'sm' for stop_market order. */
|
|
222
|
+
op: "sm";
|
|
223
|
+
/** Specific options for the stop_market order. */
|
|
224
|
+
o: StopMarketOrderOptions;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Represents a log entry for a stop_limit order operation.
|
|
228
|
+
*/
|
|
229
|
+
interface StopLimitOrderJournalLog {
|
|
230
|
+
/** Incremental ID of the operation */
|
|
231
|
+
opId: number;
|
|
232
|
+
/** Timestamp of the operation. */
|
|
233
|
+
ts: number;
|
|
234
|
+
/** Operation type: 'l' for stop_limit order. */
|
|
235
|
+
op: "sl";
|
|
236
|
+
/** Specific options for the stop_limit order. */
|
|
237
|
+
o: StopLimitOrderOptions;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Represents a log entry for a oco order operation.
|
|
241
|
+
*/
|
|
242
|
+
interface OCOOrderJournalLog {
|
|
243
|
+
/** Incremental ID of the operation */
|
|
244
|
+
opId: number;
|
|
245
|
+
/** Timestamp of the operation. */
|
|
246
|
+
ts: number;
|
|
247
|
+
/** Operation type: 'l' for oco order. */
|
|
248
|
+
op: "oco";
|
|
249
|
+
/** Specific options for the oco order. */
|
|
250
|
+
o: OCOOrderOptions;
|
|
251
|
+
}
|
|
223
252
|
/**
|
|
224
253
|
* Represents a log entry for an order modification operation.
|
|
225
254
|
*/
|
|
226
|
-
|
|
255
|
+
interface ModifyOrderJournalLog {
|
|
227
256
|
/** Incremental ID of the operation */
|
|
228
257
|
opId: number;
|
|
229
258
|
/** Timestamp of the operation. */
|
|
@@ -236,7 +265,7 @@ export interface ModifyOrderJournalLog {
|
|
|
236
265
|
/**
|
|
237
266
|
* Represents a log entry for an order cancellation operation.
|
|
238
267
|
*/
|
|
239
|
-
|
|
268
|
+
interface CancelOrderJournalLog {
|
|
240
269
|
/** Incremental ID of the operation */
|
|
241
270
|
opId: number;
|
|
242
271
|
/** Timestamp of the operation. */
|
|
@@ -249,7 +278,7 @@ export interface CancelOrderJournalLog {
|
|
|
249
278
|
/**
|
|
250
279
|
* Discriminated union of all journaling log types.
|
|
251
280
|
*/
|
|
252
|
-
export type JournalLog = MarketOrderJournalLog | LimitOrderJournalLog | ModifyOrderJournalLog | CancelOrderJournalLog;
|
|
281
|
+
export type JournalLog = MarketOrderJournalLog | LimitOrderJournalLog | StopMarketOrderJournalLog | StopLimitOrderJournalLog | OCOOrderJournalLog | ModifyOrderJournalLog | CancelOrderJournalLog;
|
|
253
282
|
export type CreateOrderOptions = ({
|
|
254
283
|
type: OrderType.MARKET;
|
|
255
284
|
} & MarketOrderOptions) | ({
|
|
@@ -261,6 +290,15 @@ export type CreateOrderOptions = ({
|
|
|
261
290
|
} & StopLimitOrderOptions) | ({
|
|
262
291
|
type: OrderType.OCO;
|
|
263
292
|
} & OCOOrderOptions);
|
|
293
|
+
/**
|
|
294
|
+
* Represents a cancel order operation.
|
|
295
|
+
*/
|
|
296
|
+
export interface ICancelOrder {
|
|
297
|
+
order: LimitOrder;
|
|
298
|
+
stopOrder?: StopOrder;
|
|
299
|
+
/** Optional log related to the order cancellation. */
|
|
300
|
+
log?: CancelOrderJournalLog;
|
|
301
|
+
}
|
|
264
302
|
/**
|
|
265
303
|
* Options for configuring the order book.
|
|
266
304
|
*/
|