2424from talib import ATR
2525import ujson as json
2626import aioredis
27-
28- import trader .utils .ApiStruct
2927from trader .strategy import BaseModule
3028from trader .utils .func_container import RegisterCallback
3129from trader .utils .read_config import config , ctp_errors
@@ -740,10 +738,8 @@ def calc_signal(self, inst: Instrument, day: datetime.datetime) -> (Signal, Deci
740738 df ["high_line" ] = df .close .rolling (window = break_n ).max ()
741739 df ["low_line" ] = df .close .rolling (window = break_n ).min ()
742740 idx = - 1
743- buy_sig = df .short_trend [idx ] > df .long_trend [idx ] and price_round (df .close [idx ], inst .price_tick ) >= price_round (df .high_line [idx - 1 ],
744- inst .price_tick )
745- sell_sig = df .short_trend [idx ] < df .long_trend [idx ] and price_round (df .close [idx ], inst .price_tick ) <= price_round (df .low_line [idx - 1 ],
746- inst .price_tick )
741+ buy_sig = df .short_trend [idx ] > df .long_trend [idx ] and price_round (df .close [idx ], inst .price_tick ) >= price_round (df .high_line [idx - 1 ], inst .price_tick )
742+ sell_sig = df .short_trend [idx ] < df .long_trend [idx ] and price_round (df .close [idx ], inst .price_tick ) <= price_round (df .low_line [idx - 1 ], inst .price_tick )
747743 pos = Trade .objects .filter (close_time__isnull = True , broker = self .__broker , strategy = self .__strategy , instrument = inst , shares__gt = 0 ).first ()
748744 roll_over = False
749745 if pos :
@@ -756,7 +752,6 @@ def calc_signal(self, inst: Instrument, day: datetime.datetime) -> (Signal, Deci
756752 sell_sig = True
757753 self .__strategy .force_opens .remove (inst )
758754 signal = signal_code = price = volume = volume_ori = use_margin = None
759-
760755 priority = PriorityType .LOW
761756 if pos :
762757 # 多头持仓
0 commit comments