nodejs-order-book 8.0.1 → 9.0.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.
@@ -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
- return _this._stopMarket(options);
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
- return _this._stopLimit(options);
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
- return _this._oco(options);
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,
@@ -160,7 +187,8 @@ var OrderBook = /** @class */ (function () {
160
187
  * @returns The order if exists or `undefined`
161
188
  */
162
189
  this.order = function (orderID) {
163
- return _this.orders[orderID];
190
+ var _a;
191
+ return (_a = _this.orders[orderID]) === null || _a === void 0 ? void 0 : _a.toObject();
164
192
  };
165
193
  // Returns price levels and volume at price level
166
194
  this.depth = function () {
@@ -216,16 +244,16 @@ var OrderBook = /** @class */ (function () {
216
244
  var bids = [];
217
245
  var asks = [];
218
246
  _this.bids.priceTree().forEach(function (price, orders) {
219
- bids.push({ price: price, orders: orders.toArray() });
247
+ bids.push({ price: price, orders: orders.toArray().map(function (o) { return o.toObject(); }) });
220
248
  });
221
249
  _this.asks.priceTree().forEach(function (price, orders) {
222
- asks.push({ price: price, orders: orders.toArray() });
250
+ asks.push({ price: price, orders: orders.toArray().map(function (o) { return o.toObject(); }) });
223
251
  });
224
252
  return { bids: bids, asks: asks, ts: Date.now(), lastOp: _this._lastOp };
225
253
  };
226
254
  this._market = function (options, incomingResponse) {
227
255
  var response = incomingResponse !== null && incomingResponse !== void 0 ? incomingResponse : _this.validateMarketOrder(options);
228
- if (response.err != null)
256
+ if (response.err !== null)
229
257
  return response;
230
258
  var quantityToTrade = options.size;
231
259
  var iter;
@@ -250,41 +278,19 @@ var OrderBook = /** @class */ (function () {
250
278
  }
251
279
  response.quantityLeft = quantityToTrade;
252
280
  _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
281
  return response;
262
282
  };
263
283
  this._limit = function (options, incomingResponse) {
264
284
  var _a, _b;
265
285
  var response = incomingResponse !== null && incomingResponse !== void 0 ? incomingResponse : _this.validateLimitOrder(options);
266
- if (response.err != null)
286
+ if (response.err !== null)
267
287
  return response;
268
- var order = _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);
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
- }
288
+ _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
289
  return response;
284
290
  };
285
291
  this._stopMarket = function (options) {
286
292
  var response = _this.validateMarketOrder(options);
287
- if (response.err != null)
293
+ if (response.err !== null)
288
294
  return response;
289
295
  var stopMarket = OrderFactory.createOrder(__assign(__assign({}, options), { type: OrderType.STOP_MARKET }));
290
296
  return _this._stopOrder(stopMarket, response);
@@ -292,7 +298,7 @@ var OrderBook = /** @class */ (function () {
292
298
  this._stopLimit = function (options) {
293
299
  var _a;
294
300
  var response = _this.validateLimitOrder(options);
295
- if (response.err != null)
301
+ if (response.err !== null)
296
302
  return response;
297
303
  var stopLimit = OrderFactory.createOrder(__assign(__assign({}, options), { type: OrderType.STOP_LIMIT, timeInForce: (_a = options.timeInForce) !== null && _a !== void 0 ? _a : TimeInForce.GTC }));
298
304
  return _this._stopOrder(stopLimit, response);
@@ -301,7 +307,7 @@ var OrderBook = /** @class */ (function () {
301
307
  var _a;
302
308
  var response = _this.validateLimitOrder(options);
303
309
  /* node:coverage ignore next - Already validated with limit test */
304
- if (response.err != null)
310
+ if (response.err !== null)
305
311
  return response;
306
312
  if (_this.validateOCOOrder(options)) {
307
313
  // We use the same ID for Stop Limit and Limit Order, since
@@ -315,7 +321,7 @@ var OrderBook = /** @class */ (function () {
315
321
  ocoStopPrice: options.stopPrice,
316
322
  }, response);
317
323
  /* node:coverage ignore next - Already validated with limit test */
318
- if (response.err != null)
324
+ if (response.err !== null)
319
325
  return response;
320
326
  var stopLimit = OrderFactory.createOrder({
321
327
  type: OrderType.STOP_LIMIT,
@@ -328,7 +334,7 @@ var OrderBook = /** @class */ (function () {
328
334
  isOCO: true,
329
335
  });
330
336
  _this.stopBook.add(stopLimit);
331
- response.done.push(stopLimit);
337
+ response.done.push(stopLimit.toObject());
332
338
  }
333
339
  else {
334
340
  response.err = CustomError(ERROR.INVALID_CONDITIONAL_ORDER);
@@ -338,7 +344,7 @@ var OrderBook = /** @class */ (function () {
338
344
  this._stopOrder = function (stopOrder, response) {
339
345
  if (_this.stopBook.validConditionalOrder(_this._marketPrice, stopOrder)) {
340
346
  _this.stopBook.add(stopOrder);
341
- response.done.push(stopOrder);
347
+ response.done.push(stopOrder.toObject());
342
348
  }
343
349
  else {
344
350
  response.err = CustomError(ERROR.INVALID_CONDITIONAL_ORDER);
@@ -351,16 +357,18 @@ var OrderBook = /** @class */ (function () {
351
357
  var level = _a[_i];
352
358
  for (var _b = 0, _c = level.orders; _b < _c.length; _b++) {
353
359
  var order = _c[_b];
354
- _this.orders[order.id] = order;
355
- _this.bids.append(order);
360
+ var newOrder = OrderFactory.createOrder(order);
361
+ _this.orders[newOrder.id] = newOrder;
362
+ _this.bids.append(newOrder);
356
363
  }
357
364
  }
358
365
  for (var _d = 0, _e = snapshot.asks; _d < _e.length; _d++) {
359
366
  var level = _e[_d];
360
367
  for (var _f = 0, _g = level.orders; _f < _g.length; _f++) {
361
368
  var order = _g[_f];
362
- _this.orders[order.id] = order;
363
- _this.asks.append(order);
369
+ var newOrder = OrderFactory.createOrder(order);
370
+ _this.orders[newOrder.id] = newOrder;
371
+ _this.asks.append(newOrder);
364
372
  }
365
373
  }
366
374
  };
@@ -371,6 +379,7 @@ var OrderBook = /** @class */ (function () {
371
379
  * @returns The removed order if exists or `undefined`
372
380
  */
373
381
  this._cancelOrder = function (orderID, internalDeletion) {
382
+ var _a, _b;
374
383
  if (internalDeletion === void 0) { internalDeletion = false; }
375
384
  var order = _this.orders[orderID];
376
385
  if (order === undefined)
@@ -378,11 +387,12 @@ var OrderBook = /** @class */ (function () {
378
387
  delete _this.orders[orderID];
379
388
  var side = order.side === Side.BUY ? _this.bids : _this.asks;
380
389
  var response = {
381
- order: side.remove(order),
390
+ order: (_a = side.remove(order)) === null || _a === void 0 ? void 0 : _a.toObject(),
382
391
  };
383
392
  // Delete OCO Order only when the delete request comes from user
384
393
  if (!internalDeletion && order.ocoStopPrice !== undefined) {
385
- response.stopOrder = _this.stopBook.remove(order.side, orderID, order.ocoStopPrice);
394
+ response.stopOrder = (_b = _this.stopBook
395
+ .remove(order.side, orderID, order.ocoStopPrice)) === null || _b === void 0 ? void 0 : _b.toObject();
386
396
  }
387
397
  if (_this.enableJournaling) {
388
398
  response.log = {
@@ -455,7 +465,7 @@ var OrderBook = /** @class */ (function () {
455
465
  order = OrderFactory.createOrder(__assign({ type: OrderType.LIMIT, id: orderID, side: side, size: quantityToTrade, origSize: size, price: price, time: Date.now(), timeInForce: timeInForce, postOnly: postOnly, takerQty: takerQty, makerQty: makerQty }, (ocoStopPrice !== undefined ? { ocoStopPrice: ocoStopPrice } : {})));
456
466
  if (response.done.length > 0) {
457
467
  response.partialQuantityProcessed = size - quantityToTrade;
458
- response.partial = order;
468
+ response.partial = order.toObject();
459
469
  }
460
470
  _this.orders[orderID] = sideToAdd.append(order);
461
471
  }
@@ -484,7 +494,7 @@ var OrderBook = /** @class */ (function () {
484
494
  takerQty: takerQty,
485
495
  makerQty: makerQty,
486
496
  });
487
- response.done.push(order);
497
+ response.done.push(order.toObject());
488
498
  }
489
499
  // If IOC order was not matched completely remove from the order book
490
500
  if (timeInForce === TimeInForce.IOC && response.quantityLeft > 0) {
@@ -530,7 +540,7 @@ var OrderBook = /** @class */ (function () {
530
540
  timeInForce: stopOrder.timeInForce,
531
541
  }, response);
532
542
  }
533
- response.activated.push(stopOrder);
543
+ response.activated.push(stopOrder.toObject());
534
544
  });
535
545
  }
536
546
  };
@@ -543,21 +553,48 @@ var OrderBook = /** @class */ (function () {
543
553
  if (side == null || size == null) {
544
554
  throw CustomError(ERROR.INVALID_JOURNAL_LOG);
545
555
  }
546
- _this.market({ side: side, size: size });
556
+ _this.market(log.o);
547
557
  break;
548
558
  }
549
559
  case "l": {
550
- var _b = log.o, side = _b.side, id = _b.id, size = _b.size, price = _b.price, timeInForce = _b.timeInForce;
560
+ var _b = log.o, side = _b.side, id = _b.id, size = _b.size, price = _b.price;
551
561
  if (side == null || id == null || size == null || price == null) {
552
562
  throw CustomError(ERROR.INVALID_JOURNAL_LOG);
553
563
  }
554
- _this.limit({
555
- side: side,
556
- id: id,
557
- size: size,
558
- price: price,
559
- timeInForce: timeInForce,
560
- });
564
+ _this.limit(log.o);
565
+ break;
566
+ }
567
+ case "sm": {
568
+ var _c = log.o, side = _c.side, size = _c.size, stopPrice = _c.stopPrice;
569
+ if (side == null || size == null || stopPrice == null) {
570
+ throw CustomError(ERROR.INVALID_JOURNAL_LOG);
571
+ }
572
+ _this.stopMarket(log.o);
573
+ break;
574
+ }
575
+ case "sl": {
576
+ var _d = log.o, side = _d.side, id = _d.id, size = _d.size, price = _d.price, stopPrice = _d.stopPrice;
577
+ if (side == null ||
578
+ id == null ||
579
+ size == null ||
580
+ price == null ||
581
+ stopPrice == null) {
582
+ throw CustomError(ERROR.INVALID_JOURNAL_LOG);
583
+ }
584
+ _this.stopLimit(log.o);
585
+ break;
586
+ }
587
+ case "oco": {
588
+ var _e = log.o, side = _e.side, id = _e.id, size = _e.size, price = _e.price, stopPrice = _e.stopPrice, stopLimitPrice = _e.stopLimitPrice;
589
+ if (side == null ||
590
+ id == null ||
591
+ size == null ||
592
+ price == null ||
593
+ stopPrice == null ||
594
+ stopLimitPrice == null) {
595
+ throw CustomError(ERROR.INVALID_JOURNAL_LOG);
596
+ }
597
+ _this.oco(log.o);
561
598
  break;
562
599
  }
563
600
  case "d":
@@ -615,10 +652,11 @@ var OrderBook = /** @class */ (function () {
615
652
  var headOrder = orderQueue.head();
616
653
  if (headOrder !== undefined) {
617
654
  if (response.quantityLeft < headOrder.size) {
618
- response.partial = OrderFactory.createOrder(__assign(__assign({}, headOrder.toObject()), { size: headOrder.size - response.quantityLeft }));
619
- _this.orders[headOrder.id] = response.partial;
655
+ var partial = OrderFactory.createOrder(__assign(__assign({}, headOrder.toObject()), { size: headOrder.size - response.quantityLeft }));
656
+ response.partial = partial.toObject();
657
+ _this.orders[headOrder.id] = partial;
620
658
  response.partialQuantityProcessed = response.quantityLeft;
621
- orderQueue.update(headOrder, response.partial);
659
+ orderQueue.update(headOrder, partial);
622
660
  response.quantityLeft = 0;
623
661
  }
624
662
  else {
@@ -748,40 +786,23 @@ var OrderBook = /** @class */ (function () {
748
786
  enumerable: false,
749
787
  configurable: true
750
788
  });
751
- OrderBook.prototype.createOrder = function (typeOrOptions, side, size, price, orderID, timeInForce, stopPrice, stopLimitPrice, stopLimitTimeInForce, postOnly) {
752
- if (timeInForce === void 0) { timeInForce = TimeInForce.GTC; }
753
- if (stopLimitTimeInForce === void 0) { stopLimitTimeInForce = TimeInForce.GTC; }
754
- var options;
755
- // We don't want to test the deprecated signature.
756
- /* node:coverage disable */
757
- if (typeof typeOrOptions === "string" &&
758
- side !== undefined &&
759
- size !== undefined) {
760
- options = {
761
- type: typeOrOptions,
762
- side: side,
763
- size: size,
764
- // @ts-expect-error
765
- price: price,
766
- id: orderID,
767
- timeInForce: timeInForce,
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 */
789
+ /**
790
+ * Create new order. See {@link CreateOrderOptions} for details.
791
+ *
792
+ * @param options
793
+ * @param options.type - `limit` | `market` | 'stop_limit' | 'stop_market' | 'oco'
794
+ * @param options.side - `sell` or `buy`
795
+ * @param options.size - How much of currency you want to trade in units of base currency
796
+ * @param options.price - The price at which the order is to be fullfilled, in units of the quote currency. Param only for limit order
797
+ * @param options.orderID - Unique order ID. Param only for limit order
798
+ * @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`
799
+ * @param options.stopPrice - The price at which the order will be triggered. Used with `stop_limit` and `stop_market` order.
800
+ * @param options.stopLimitPrice - The price at which the order will be triggered. Used with `stop_limit` and `stop_market` order.
801
+ * @param options.timeInForce - Time-in-force supported are: `GTC` (default), `FOK`, `IOC`. Param only for limit order
802
+ * @param options.stopLimitTimeInForce - Time-in-force supported are: `GTC` (default), `FOK`, `IOC`. Param only for limit order
803
+ * @returns An object with the result of the processed order or an error. See {@link IProcessOrder} for the returned data structure
804
+ */
805
+ OrderBook.prototype.createOrder = function (options) {
785
806
  switch (options.type) {
786
807
  case OrderType.MARKET:
787
808
  return this.market(options);
@@ -804,43 +825,49 @@ var OrderBook = /** @class */ (function () {
804
825
  };
805
826
  }
806
827
  };
807
- OrderBook.prototype.market = function (sideOrOptions, size) {
808
- // We don't want to test the deprecated signature.
809
- /* node:coverage disable */
810
- if (typeof sideOrOptions === "string" && size !== undefined) {
811
- return this._market({ side: sideOrOptions, size: size });
812
- /* node:coverage enable */
813
- }
814
- if (typeof sideOrOptions === "object") {
815
- return this._market(sideOrOptions);
816
- /* node:coverage disable */
828
+ /**
829
+ * Create a market order. See {@link MarketOrderOptions} for details.
830
+ *
831
+ * @param options
832
+ * @param options.side - `sell` or `buy`
833
+ * @param options.size - How much of currency you want to trade in units of base currency
834
+ * @returns An object with the result of the processed order or an error. See {@link IProcessOrder} for the returned data structure
835
+ */
836
+ OrderBook.prototype.market = function (options) {
837
+ var response = this._market(options);
838
+ if (this.enableJournaling && response.err === null) {
839
+ response.log = {
840
+ opId: ++this._lastOp,
841
+ ts: Date.now(),
842
+ op: "m",
843
+ o: options,
844
+ };
817
845
  }
818
- throw new Error("Invalid arguments.");
819
- /* node:coverage enable */
846
+ return response;
820
847
  };
821
- OrderBook.prototype.limit = function (sideOrOptions, orderID, size, price, timeInForce) {
822
- if (timeInForce === void 0) { timeInForce = TimeInForce.GTC; }
823
- // We don't want to test the deprecated signature.
824
- /* node:coverage disable */
825
- if (typeof sideOrOptions === "string" &&
826
- orderID !== undefined &&
827
- size !== undefined &&
828
- price !== undefined) {
829
- return this._limit({
830
- id: orderID,
831
- side: sideOrOptions,
832
- size: size,
833
- price: price,
834
- timeInForce: timeInForce,
835
- });
836
- /* node:coverage enable */
837
- }
838
- if (typeof sideOrOptions === "object") {
839
- return this._limit(sideOrOptions);
840
- /* node:coverage disable */
848
+ /**
849
+ * Create a limit order. See {@link LimitOrderOptions} for details.
850
+ *
851
+ * @param options
852
+ * @param options.side - `sell` or `buy`
853
+ * @param options.id - Unique order ID
854
+ * @param options.size - How much of currency you want to trade in units of base currency
855
+ * @param options.price - The price at which the order is to be fullfilled, in units of the quote currency
856
+ * @param options.postOnly - When `true` the order will be rejected if immediately matches and trades as a taker. Default is `false`
857
+ * @param options.timeInForce - Time-in-force type supported are: GTC, FOK, IOC. Default is GTC
858
+ * @returns An object with the result of the processed order or an error. See {@link IProcessOrder} for the returned data structure
859
+ */
860
+ OrderBook.prototype.limit = function (options) {
861
+ var response = this._limit(options);
862
+ if (this.enableJournaling && response.err === null) {
863
+ response.log = {
864
+ opId: ++this._lastOp,
865
+ ts: Date.now(),
866
+ op: "l",
867
+ o: options,
868
+ };
841
869
  }
842
- throw new Error("Invalid arguments.");
843
- /* node:coverage enable */
870
+ return response;
844
871
  };
845
872
  return OrderBook;
846
873
  }());
@@ -0,0 +1,19 @@
1
+ /* node:coverage ignore next - Don't know why this line is uncovered */
2
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
3
+ export var safeStringify = function (value) {
4
+ try {
5
+ return JSON.stringify(value);
6
+ }
7
+ catch (error) {
8
+ return null;
9
+ }
10
+ };
11
+ /* node:coverage ignore next - Don't know why this line is uncovered */
12
+ export var safeParse = function (value) {
13
+ try {
14
+ return JSON.parse(value);
15
+ }
16
+ catch (error) {
17
+ return null;
18
+ }
19
+ };
@@ -35,7 +35,7 @@ export declare class LimitOrder extends BaseOrder {
35
35
  get takerQty(): number;
36
36
  get ocoStopPrice(): number | undefined;
37
37
  toString: () => string;
38
- toJSON: () => string;
38
+ toJSON: () => string | null;
39
39
  toObject: () => ILimitOrder;
40
40
  }
41
41
  export declare class StopMarketOrder extends BaseOrder {
@@ -45,7 +45,7 @@ export declare class StopMarketOrder extends BaseOrder {
45
45
  get type(): OrderType.STOP_MARKET;
46
46
  get stopPrice(): number;
47
47
  toString: () => string;
48
- toJSON: () => string;
48
+ toJSON: () => string | null;
49
49
  toObject: () => IStopMarketOrder;
50
50
  }
51
51
  export declare class StopLimitOrder extends BaseOrder {
@@ -62,7 +62,7 @@ export declare class StopLimitOrder extends BaseOrder {
62
62
  get timeInForce(): TimeInForce;
63
63
  get isOCO(): boolean;
64
64
  toString: () => string;
65
- toJSON: () => string;
65
+ toJSON: () => string | null;
66
66
  toObject: () => IStopLimitOrder;
67
67
  }
68
68
  export declare const OrderFactory: {
@@ -1,6 +1,5 @@
1
1
  import { type OrderBookError } from "./errors";
2
- import { type LimitOrder } from "./order";
3
- import { type CreateOrderOptions, type ICancelOrder, type IProcessOrder, type LimitOrderOptions, type MarketOrderOptions, type OCOOrderOptions, type OrderBookOptions, OrderType, type OrderUpdatePrice, type OrderUpdateSize, Side, type Snapshot, type StopLimitOrderOptions, type StopMarketOrderOptions, TimeInForce } from "./types";
2
+ import { type CreateOrderOptions, type ICancelOrder, type ILimitOrder, type IProcessOrder, type LimitOrderOptions, type MarketOrderOptions, type OCOOrderOptions, type OrderBookOptions, type OrderUpdatePrice, type OrderUpdateSize, Side, type Snapshot, type StopLimitOrderOptions, type StopMarketOrderOptions } from "./types";
4
3
  export declare class OrderBook {
5
4
  private orders;
6
5
  private _lastOp;
@@ -38,25 +37,6 @@ export declare class OrderBook {
38
37
  * @returns An object with the result of the processed order or an error. See {@link IProcessOrder} for the returned data structure
39
38
  */
40
39
  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
40
  /**
61
41
  * Create a market order. See {@link MarketOrderOptions} for details.
62
42
  *
@@ -66,17 +46,6 @@ export declare class OrderBook {
66
46
  * @returns An object with the result of the processed order or an error. See {@link IProcessOrder} for the returned data structure
67
47
  */
68
48
  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
49
  /**
81
50
  * Create a stop market order. See {@link StopMarketOrderOptions} for details.
82
51
  *
@@ -100,20 +69,6 @@ export declare class OrderBook {
100
69
  * @returns An object with the result of the processed order or an error. See {@link IProcessOrder} for the returned data structure
101
70
  */
102
71
  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
72
  /**
118
73
  * Create a stop limit order. See {@link StopLimitOrderOptions} for details.
119
74
  *
@@ -175,7 +130,7 @@ export declare class OrderBook {
175
130
  * @param orderID - The ID of the order to be returned
176
131
  * @returns The order if exists or `undefined`
177
132
  */
178
- order: (orderID: string) => LimitOrder | undefined;
133
+ order: (orderID: string) => ILimitOrder | undefined;
179
134
  depth: () => [Array<[number, number]>, Array<[number, number]>];
180
135
  toString: () => string;
181
136
  calculateMarketPrice: (side: Side, size: number) => {