@@ -19,7 +19,7 @@ Ultra-fast matching engine written in TypeScript
19
19
20
20
- Standard price-time priority
21
21
- Supports both market and limit orders
22
- - Supports conditional orders (Stop Market and Stop Limit)
22
+ - Supports conditional orders (Stop Market, Stop Limit and OCO )
23
23
- Supports time in force GTC, FOK and IOC
24
24
- Supports order cancelling
25
25
- Supports order price and/or size updating
@@ -57,14 +57,16 @@ const lob = new OrderBook()
57
57
Then you'll be able to use next primary functions:
58
58
59
59
``` js
60
- lob .createOrder ({ type: ' limit' | ' market' | ' stop_limit' | ' stop_market' , side: ' buy' | ' sell' , size: number, price?: number, id?: string, stopPrice?: number, timeInForce?: ' GTC' | ' FOK' | ' IOC' })
60
+ lob .createOrder ({ type: ' limit' | ' market' | ' stop_limit' | ' stop_market' | ' oco ' , side: ' buy' | ' sell' , size: number, price?: number, id?: string, stopPrice?: number, timeInForce?: ' GTC' | ' FOK' | ' IOC' })
61
61
62
62
lob .limit ({ id: string, side: ' buy' | ' sell' , size: number, price: number, timeInForce?: ' GTC' | ' FOK' | ' IOC' })
63
63
64
64
lob .market ({ side: ' buy' | ' sell' , size: number })
65
65
66
66
lob .stopLimit ({ id: string, side: ' buy' | ' sell' , size: number, price: number, stopPrice: number, timeInForce?: ' GTC' | ' FOK' | ' IOC' })
67
67
68
+ lob .oco ({ id: string, side: ' buy' | ' sell' , size: number, price: number, stopPrice: number, stopLimitPrice: number, timeInForce?: ' GTC' | ' FOK' | ' IOC' , stopLimitTimeInForce?: ' GTC' | ' FOK' | ' IOC' })
69
+
68
70
lob .stopMarket ({ side: ' buy' | ' sell' , size: number, stopPrice: number })
69
71
70
72
lob .modify (orderID: string, { side: ' buy' | ' sell' , size: number, price: number })
@@ -79,17 +81,20 @@ To add an order to the order book you can call the general `createOrder()` funct
79
81
### Create Order
80
82
81
83
``` js
82
- // Create a limit order
84
+ // Create limit order
83
85
createOrder ({ type: ' limit' , side: ' buy' | ' sell' , size: number, price: number, id: string, timeInForce?: ' GTC' | ' FOK' | ' IOC' })
84
86
85
- // Create a market order
87
+ // Create market order
86
88
createOrder ({ type: ' market' , side: ' buy' | ' sell' , size: number })
87
89
88
- // Create a stop limit order
90
+ // Create stop limit order
89
91
createOrder ({ type: ' stop_limit' , side: ' buy' | ' sell' , size: number, price: number, id: string, stopPrice: number, timeInForce?: ' GTC' | ' FOK' | ' IOC' })
90
92
91
- // Create a stop market order
93
+ // Create stop market order
92
94
createOrder ({ type: ' stop_market' , side: ' buy' | ' sell' , size: number, stopPrice: number })
95
+
96
+ // Create OCO order
97
+ createOrder ({ type: ' oco' , side: ' buy' | ' sell' , size: number, stopPrice: number, stopLimitPrice: number, timeInForce?: ' GTC' | ' FOK' | ' IOC' , stopLimitTimeInForce?: ' GTC' | ' FOK' | ' IOC' })
93
98
```
94
99
95
100
### Create Limit Order
@@ -228,6 +233,35 @@ stopLimit({ side: 'buy' | 'sell', id: string, size: number, price: number, stopP
228
233
stopMarket ({ side: ' buy' | ' sell' , size: number, stopPrice: number })
229
234
```
230
235
236
+ ### Create OCO (One-Cancels-the-Other) Order
237
+
238
+ ``` js
239
+ /**
240
+ * Create an OCO (One-Cancels-the-Other) order.
241
+ * OCO order combines a `stop_limit` order and a `limit` order, where if stop price
242
+ * is triggered or limit order is fully or partially fulfilled, the other is canceled.
243
+ * Both orders have the same `side` and `size`. If you cancel one of the orders, the
244
+ * entire OCO order pair will be canceled.
245
+ *
246
+ * For BUY orders the `stopPrice` must be above the current price and the `price` below the current price
247
+ * For SELL orders the `stopPrice` must be below the current price and the `price` above the current price
248
+ *
249
+ * See {@link OCOOrderOptions } for details.
250
+ *
251
+ * @param options
252
+ * @param options.side - `sell` or `buy`
253
+ * @param options.id - Unique order ID
254
+ * @param options.size - How much of currency you want to trade in units of base currency
255
+ * @param options.price - The price of the `limit` order at which the order is to be fullfilled, in units of the quote currency
256
+ * @param options.stopPrice - The price at which the `stop_limit` order will be triggered.
257
+ * @param options.stopLimitPrice - The price of the `stop_limit` order at which the order is to be fullfilled, in units of the quote currency.
258
+ * @param options.timeInForce - Time-in-force of the `limit` order. Type supported are: GTC, FOK, IOC. Default is GTC
259
+ * @param options.stopLimitTimeInForce - Time-in-force of the `stop_limit` order. Type supported are: GTC, FOK, IOC. Default is GTC
260
+ * @returns An object with the result of the processed order or an error. See {@link IProcessOrder } for the returned data structure
261
+ */
262
+ oco ({ side: ' buy' | ' sell' , id: string, size: number, price: number, stopPrice: number, stopLimitPrice: number, timeInForce?: ' GTC' | ' FOK' | ' IOC' , stopLimitTimeInForce?: ' GTC' | ' FOK' | ' IOC' })
263
+ ```
264
+
231
265
### Modify an existing order
232
266
233
267
``` js
0 commit comments