@@ -139,7 +139,7 @@ export class OrderBook {
139
139
opId : ++ this . _lastOp ,
140
140
ts : Date . now ( ) ,
141
141
op : "m" ,
142
- o : { side : options . side , size : options . size } ,
142
+ o : options ,
143
143
} ;
144
144
}
145
145
return response ;
@@ -160,7 +160,16 @@ export class OrderBook {
160
160
throw new Error (
161
161
"In order to use conditional orders you need to instantiate the order book with the `experimentalConditionalOrders` option set to true" ,
162
162
) ;
163
- return this . _stopMarket ( options ) ;
163
+ const response = this . _stopMarket ( options ) ;
164
+ if ( this . enableJournaling && response . err === null ) {
165
+ response . log = {
166
+ opId : ++ this . _lastOp ,
167
+ ts : Date . now ( ) ,
168
+ op : "sm" ,
169
+ o : options ,
170
+ } ;
171
+ }
172
+ return response ;
164
173
} ;
165
174
166
175
/**
@@ -182,14 +191,7 @@ export class OrderBook {
182
191
opId : ++ this . _lastOp ,
183
192
ts : Date . now ( ) ,
184
193
op : "l" ,
185
- o : {
186
- side : options . side ,
187
- id : options . id ,
188
- size : options . size ,
189
- price : options . price ,
190
- postOnly : options . postOnly ?? false ,
191
- timeInForce : options . timeInForce ?? TimeInForce . GTC ,
192
- } ,
194
+ o : options ,
193
195
} ;
194
196
}
195
197
return response ;
@@ -213,7 +215,16 @@ export class OrderBook {
213
215
throw new Error (
214
216
"In order to use conditional orders you need to instantiate the order book with the `experimentalConditionalOrders` option set to true" ,
215
217
) ;
216
- return this . _stopLimit ( options ) ;
218
+ const response = this . _stopLimit ( options ) ;
219
+ if ( this . enableJournaling && response . err === null ) {
220
+ response . log = {
221
+ opId : ++ this . _lastOp ,
222
+ ts : Date . now ( ) ,
223
+ op : "sl" ,
224
+ o : options ,
225
+ } ;
226
+ }
227
+ return response ;
217
228
} ;
218
229
219
230
/**
@@ -245,7 +256,16 @@ export class OrderBook {
245
256
throw new Error (
246
257
"In order to use conditional orders you need to instantiate the order book with the `experimentalConditionalOrders` option set to true" ,
247
258
) ;
248
- return this . _oco ( options ) ;
259
+ const response = this . _oco ( options ) ;
260
+ if ( this . enableJournaling && response . err === null ) {
261
+ response . log = {
262
+ opId : ++ this . _lastOp ,
263
+ ts : Date . now ( ) ,
264
+ op : "oco" ,
265
+ o : options ,
266
+ } ;
267
+ }
268
+ return response ;
249
269
} ;
250
270
251
271
/**
@@ -780,21 +800,52 @@ export class OrderBook {
780
800
if ( side == null || size == null ) {
781
801
throw CustomError ( ERROR . INVALID_JOURNAL_LOG ) ;
782
802
}
783
- this . market ( { side , size } ) ;
803
+ this . market ( log . o ) ;
784
804
break ;
785
805
}
786
806
case "l" : {
787
- const { side, id, size, price, timeInForce } = log . o ;
807
+ const { side, id, size, price } = log . o ;
788
808
if ( side == null || id == null || size == null || price == null ) {
789
809
throw CustomError ( ERROR . INVALID_JOURNAL_LOG ) ;
790
810
}
791
- this . limit ( {
792
- side,
793
- id,
794
- size,
795
- price,
796
- timeInForce,
797
- } ) ;
811
+ this . limit ( log . o ) ;
812
+ break ;
813
+ }
814
+ case "sm" : {
815
+ const { side, size, stopPrice } = log . o ;
816
+ if ( side == null || size == null || stopPrice == null ) {
817
+ throw CustomError ( ERROR . INVALID_JOURNAL_LOG ) ;
818
+ }
819
+ this . stopMarket ( log . o ) ;
820
+ break ;
821
+ }
822
+ case "sl" : {
823
+ const { side, id, size, price, stopPrice } = log . o ;
824
+ if (
825
+ side == null ||
826
+ id == null ||
827
+ size == null ||
828
+ price == null ||
829
+ stopPrice == null
830
+ ) {
831
+ throw CustomError ( ERROR . INVALID_JOURNAL_LOG ) ;
832
+ }
833
+ this . stopLimit ( log . o ) ;
834
+ break ;
835
+ }
836
+ case "oco" : {
837
+ const { side, id, size, price, stopPrice, stopLimitPrice } = log . o ;
838
+ if (
839
+ side == null ||
840
+ id == null ||
841
+ size == null ||
842
+ price == null ||
843
+ stopPrice == null ||
844
+ stopLimitPrice == null
845
+ ) {
846
+ throw CustomError ( ERROR . INVALID_JOURNAL_LOG ) ;
847
+ }
848
+ this . oco ( log . o ) ;
798
849
break ;
799
850
}
800
851
case "d" :
0 commit comments