@@ -421,7 +421,8 @@ export class OrderBook {
421
421
this . asks . priceTree ( ) . forEach ( ( price : number , orders : OrderQueue ) => {
422
422
asks . push ( { price, orders : orders . toArray ( ) . map ( ( o ) => o . toObject ( ) ) } ) ;
423
423
} ) ;
424
- return { bids, asks, ts : Date . now ( ) , lastOp : this . _lastOp } ;
424
+ const stopBook = this . stopBook . snapshot ( ) ;
425
+ return { bids, asks, stopBook, ts : Date . now ( ) , lastOp : this . _lastOp } ;
425
426
} ;
426
427
427
428
private readonly _market = (
@@ -572,6 +573,28 @@ export class OrderBook {
572
573
this . asks . append ( newOrder ) ;
573
574
}
574
575
}
576
+
577
+ if ( snapshot . stopBook ?. bids ?. length > 0 ) {
578
+ for ( const level of snapshot . stopBook . bids ) {
579
+ for ( const order of level . orders ) {
580
+ // @ts -expect-error // TODO fix types
581
+ const newOrder = OrderFactory . createOrder ( order ) ;
582
+ // @ts -expect-error // TODO fix types
583
+ this . stopBook . add ( newOrder ) ;
584
+ }
585
+ }
586
+ }
587
+
588
+ if ( snapshot . stopBook ?. asks ?. length > 0 ) {
589
+ for ( const level of snapshot . stopBook . asks ) {
590
+ for ( const order of level . orders ) {
591
+ // @ts -expect-error // TODO fix types
592
+ const newOrder = OrderFactory . createOrder ( order ) ;
593
+ // @ts -expect-error // TODO fix types
594
+ this . stopBook . add ( newOrder ) ;
595
+ }
596
+ }
597
+ }
575
598
} ;
576
599
577
600
/**
0 commit comments