@@ -191,7 +191,10 @@ def cancel_preorder_handler(self, exchange: Exchange, tick: sj.TickSTKv1):
191
191
api = self .api
192
192
# 8:55 - 8:59:55
193
193
if tick .simtrade :
194
- if position .cond .quantity < 0 and float (tick .close ) == position .contract .limit_up :
194
+ if (
195
+ position .cond .quantity < 0
196
+ and float (tick .close ) == position .contract .limit_up
197
+ ):
195
198
with position .lock :
196
199
position .status .cancel_preorder = True
197
200
for trade in self .positions [tick .code ].entry_trades :
@@ -252,8 +255,8 @@ def intraday_handler(self, exchange: Exchange, tick: sj.TickSTKv1):
252
255
253
256
def stop_profit (self , position : Position , tick : sj .TickSTKv1 ):
254
257
if not tick .simtrade :
255
- cover_quantity = (
256
- position .status .open_quantity + position .status .cover_order_quantity
258
+ cover_quantity = position . status . open_quantity + (
259
+ position .status .cover_order_quantity - position .status .cover_quantity
257
260
)
258
261
if cover_quantity == 0 :
259
262
return
@@ -275,8 +278,8 @@ def stop_profit(self, position: Position, tick: sj.TickSTKv1):
275
278
276
279
def stop_loss (self , position : Position , tick : sj .TickSTKv1 ):
277
280
if not tick .simtrade :
278
- cover_quantity = (
279
- position .status .open_quantity + position .status .cover_order_quantity
281
+ cover_quantity = position . status . open_quantity + (
282
+ position .status .cover_order_quantity - position .status .cover_quantity
280
283
)
281
284
if cover_quantity == 0 :
282
285
return
@@ -303,8 +306,8 @@ def place_cover_order(
303
306
api = self .simulation_api
304
307
else :
305
308
api = self .api
306
- cover_quantity = (
307
- position .status .open_quantity + position .status .cover_order_quantity
309
+ cover_quantity = position . status . open_quantity + (
310
+ position .status .cover_order_quantity - position .status .cover_quantity
308
311
)
309
312
if not price_sets :
310
313
price_sets = self .stratagy .cover_price_set (
0 commit comments