@@ -92,8 +92,8 @@ void test('test limit', ({ equal, end }) => {
92
92
addDepth ( ob , '' , 2 )
93
93
equal ( ob . marketPrice , 0 )
94
94
const process1 =
95
- // { done, partial, partialQuantityProcessed, quantityLeft, err }
96
- ob . limit ( { side : Side . BUY , id : 'order-b100' , size : 1 , price : 100 } )
95
+ // { done, partial, partialQuantityProcessed, quantityLeft, err }
96
+ ob . limit ( { side : Side . BUY , id : 'order-b100' , size : 1 , price : 100 } )
97
97
98
98
equal ( ob . marketPrice , 100 )
99
99
equal ( process1 . err === null , true )
@@ -103,8 +103,8 @@ void test('test limit', ({ equal, end }) => {
103
103
equal ( process1 . partialQuantityProcessed , 1 )
104
104
105
105
const process2 =
106
- // { done, partial, partialQuantityProcessed, quantityLeft, err } =
107
- ob . limit ( { side : Side . BUY , id : 'order-b150' , size : 10 , price : 150 } )
106
+ // { done, partial, partialQuantityProcessed, quantityLeft, err } =
107
+ ob . limit ( { side : Side . BUY , id : 'order-b150' , size : 10 , price : 150 } )
108
108
equal ( process2 . err === null , true )
109
109
equal ( process2 . done . length , 5 )
110
110
equal ( process2 . partial ?. id , 'order-b150' )
@@ -135,7 +135,6 @@ void test('test limit', ({ equal, end }) => {
135
135
price : 100
136
136
} )
137
137
equal ( process5 . err ?. message , ERROR . ErrInvalidSide )
138
-
139
138
const removed = ob . cancel ( 'order-b100' )
140
139
equal ( removed === undefined , true )
141
140
// Test also the createOrder method
@@ -287,17 +286,17 @@ void test('test market', ({ equal, end }) => {
287
286
addDepth ( ob , '' , 2 )
288
287
289
288
const process1 =
290
- // { done, partial, partialQuantityProcessed, quantityLeft, err }
291
- ob . market ( { side : Side . BUY , size : 3 } )
289
+ // { done, partial, partialQuantityProcessed, quantityLeft, err }
290
+ ob . market ( { side : Side . BUY , size : 3 } )
292
291
293
292
equal ( process1 . err === null , true )
294
293
equal ( process1 . quantityLeft , 0 )
295
294
equal ( process1 . partialQuantityProcessed , 1 )
296
295
297
296
// Test also the createOrder method
298
297
const process3 =
299
- // { done, partial, partialQuantityProcessed, quantityLeft, err } =
300
- ob . createOrder ( { type : OrderType . MARKET , side : Side . SELL , size : 12 } )
298
+ // { done, partial, partialQuantityProcessed, quantityLeft, err } =
299
+ ob . createOrder ( { type : OrderType . MARKET , side : Side . SELL , size : 12 } )
301
300
302
301
equal ( process3 . done . length , 5 )
303
302
equal ( process3 . err === null , true )
@@ -347,10 +346,10 @@ void test('createOrder error', ({ equal, end }) => {
347
346
} )
348
347
349
348
/**
350
- * Stop-Market Order:
351
- * Buy: marketPrice < stopPrice
352
- * Sell: marketPrice > stopPrice
353
- */
349
+ * Stop-Market Order:
350
+ * Buy: marketPrice < stopPrice
351
+ * Sell: marketPrice > stopPrice
352
+ */
354
353
void test ( 'test stop_market order' , ( { equal, end } ) => {
355
354
const ob = new OrderBook ( )
356
355
@@ -374,8 +373,11 @@ void test('test stop_market order', ({ equal, end }) => {
374
373
stopPrice : ob . marketPrice
375
374
} ) // Same as market price
376
375
equal ( wrongStopPrice2 . err ?. message , ERROR . ErrInvalidStopPrice )
377
- // @ts -expect-error invalid side
378
- const wrongOtherOrderOption1 = ob . stopMarket ( { side : 'wrong-side' , size : 1 } )
376
+ const wrongOtherOrderOption1 = ob . stopMarket ( {
377
+ // @ts -expect-error invalid side
378
+ side : 'wrong-side' ,
379
+ size : 1
380
+ } )
379
381
equal ( wrongOtherOrderOption1 . err != null , true )
380
382
381
383
// @ts -expect-error size must be greather than 0
@@ -496,16 +498,28 @@ void test('test stop_limit order', ({ equal, end }) => {
496
498
price : ob . marketPrice
497
499
} ) // Same as market price
498
500
equal ( wrongStopPrice2 . err ?. message , ERROR . ErrInvalidStopPrice )
499
- // @ts -expect-error invalid side
500
- const wrongOtherOrderOption1 = ob . stopLimit ( { side : 'wrong-side' , size : 1 , price : 10 } )
501
+ const wrongOtherOrderOption1 = ob . stopLimit ( {
502
+ // @ts -expect-error invalid side
503
+ side : 'wrong-side' ,
504
+ size : 1 ,
505
+ price : 10
506
+ } )
501
507
equal ( wrongOtherOrderOption1 . err != null , true )
502
508
503
509
// @ts -expect-error size must be greather than 0
504
- const wrongOtherOrderOption2 = ob . stopLimit ( { side : Side . BUY , size : 0 , price : 10 } )
510
+ const wrongOtherOrderOption2 = ob . stopLimit ( {
511
+ side : Side . BUY ,
512
+ size : 0 ,
513
+ price : 10
514
+ } )
505
515
equal ( wrongOtherOrderOption2 . err != null , true )
506
516
507
517
// @ts -expect-error price must be greather than 0
508
- const wrongOtherOrderOption3 = ob . stopLimit ( { side : Side . BUY , size : 1 , price : 0 } )
518
+ const wrongOtherOrderOption3 = ob . stopLimit ( {
519
+ side : Side . BUY ,
520
+ size : 1 ,
521
+ price : 0
522
+ } )
509
523
equal ( wrongOtherOrderOption3 . err != null , true )
510
524
511
525
// Add a stop limit BUY order
0 commit comments