Administrator
2025-06-05 48e24816c88f722e40b43187fa63a8334196f5ae
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""
卖数据处理器
"""
from utils import tool
 
 
class TickDataProcess:
    # 最高价
    __highest_price_infos = {}
 
    @classmethod
    def init_origin_price(cls, code, price, rate_percent):
        cls.__highest_price_infos[code] = [("09:25:00", price, rate_percent)]
 
    # 价格信息(时间,现价,涨幅)
    # return 是否减仓
    @classmethod
    def process_tick_data(cls, code, time_str, price, rate_percent, max_amplitude_rate_percent=0.6):
        # 非交易时间
        if tool.trade_time_sub(time_str, "09:30:00") < 0:
            return False
        now_price_info = (time_str, price, rate_percent)
        # 如果比最高价高就取最高价
        if cls.__highest_price_infos.get(code)[2] < now_price_info[2]:
            cls.__highest_price_infos[code] = now_price_info
        else:
            # 低于最高点阈值
            if cls.__highest_price_infos.get(code)[2] - now_price_info[2] > max_amplitude_rate_percent:
                # 触发卖
                cls.__highest_price_infos[code] = now_price_info
                return True
        return False
 
 
if __name__ == "__main__":
    pass