Administrator
2024-07-18 5159d3026648a0db3a0bceeb0e430e79fcafae54
策略修改
3个文件已修改
26 ■■■■ 已修改文件
test/test_l2.py 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/buy_strategy.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
utils/tool.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
test/test_l2.py
@@ -1,5 +1,6 @@
from code_attribute import target_codes_manager
from log_module import log_export
from utils import tool, l2_huaxin_util
def get_cb_code(code):
@@ -16,7 +17,22 @@
if __name__ == "__main__":
    code = '118010'
    __latest_transaction_price_dict ={code:[(10.77, 9305865), (10.77, 9305865), (10.76, 9305865), (10.76, 9305865), (10.76, 9305865), (10.76, 9305865), (10.76, 9305865), (10.76, 9305865), (10.76, 9305865), (10.76, 9305865), (10.76, 9305865), (10.76, 9305865), (10.76, 9305865), (10.76, 9305865), (10.76, 9305865), (10.76, 9305865), (10.76, 9305865), (10.76, 9305865), (10.76, 9305865), (10.76, 9305865), (10.76, 9305865), (10.76, 9305865), (10.76, 9305865), (10.78, 9305908), (10.78, 9305910), (10.78, 9305931), (10.79, 9310049), (10.8, 9310049), (10.8, 9310049), (10.8, 9310049), (10.83, 9310049), (10.83, 9310049), (10.8, 9310212), (10.8, 9310220), (10.83, 9310257), (10.83, 9310259), (10.83, 9310259), (10.83, 9310272), (10.83, 9310291), (10.83, 9310291), (10.82, 9310359), (10.83, 9310372), (10.83, 9310372), (10.83, 9310397), (10.83, 9310460), (10.83, 9310460), (10.82, 9310460), (10.82, 9310460), (10.82, 9310460), (10.82, 9310460), (10.82, 9310460), (10.82, 9310460), (10.82, 9310460), (10.81, 9310460), (10.81, 9310463), (10.8, 9310463), (10.8, 9310463), (10.8, 9310463), (10.8, 9310463), (10.86, 9310465), (10.89, 9310465), (10.81, 9310489), (10.81, 9310489), (10.81, 9310489), (10.8, 9310489), (10.79, 9310489), (10.79, 9310489), (10.79, 9310489), (10.79, 9310492), (10.79, 9310492), (10.79, 9310492), (10.79, 9310492), (10.79, 9310492), (10.79, 9310492), (10.79, 9310492), (10.79, 9310492), (10.79, 9310492), (10.79, 9310492), (10.79, 9310492), (10.79, 9310492), (10.79, 9310492), (10.79, 9310492), (10.79, 9310492), (10.79, 9310492), (10.79, 9310492), (10.79, 9310492), (10.79, 9310492), (10.81, 9310501), (10.81, 9310599), (10.81, 9310599), (10.8, 9310608), (10.89, 9310751), (10.89, 9310757), (10.89, 9310757), (10.89, 9310844), (10.89, 9310844), (10.89, 9310844), (10.89, 9310866), (10.89, 9310868), (10.87, 9310870), (10.87, 9310870), (10.87, 9310892), (10.88, 9310953), (10.88, 9310955), (10.88, 9310958), (10.88, 9310963), (10.89, 9311049), (10.89, 9311076), (10.89, 9311087), (10.88, 9311087), (10.88, 9311089), (10.88, 9311089), (10.89, 9311112), (10.9, 9311143), (10.9, 9311143), (10.9, 9311143), (10.9, 9311143), (10.9, 9311164), (10.92, 9311250), (10.92, 9311250), (10.92, 9311250), (10.92, 9311250), (10.92, 9311250), (10.93, 9311314), (10.92, 9311314), (10.92, 9311314), (10.92, 9311314), (10.92, 9311314), (10.92, 9311314), (10.92, 9311314), (10.92, 9311314), (10.92, 9311314), (10.92, 9311314), (10.92, 9311314), (10.92, 9311314), (10.93, 9311338), (10.92, 9311338), (10.93, 9311381), (10.93, 9311420), (10.92, 9311420), (10.93, 9311442), (10.93, 9311442), (10.93, 9311491), (10.92, 9311491), (10.95, 9311536), (10.93, 9311552), (10.95, 9311552), (10.95, 9311552), (10.93, 9311552), (10.93, 9311552), (10.93, 9311552), (10.95, 9311602), (10.93, 9311619), (10.93, 9311652), (10.92, 9311652), (10.92, 9311670), (10.94, 9311708), (10.94, 9311708), (10.97, 9311708), (10.97, 9311708), (10.97, 9311714), (10.97, 9311738), (10.97, 9311742), (10.97, 9311745), (10.97, 9311846), (10.98, 9311848), (10.98, 9311848), (10.98, 9311848), (10.98, 9311868), (10.97, 9311870), (10.97, 9311870), (10.97, 9311870), (10.97, 9311870), (10.97, 9311870), (10.97, 9311870), (10.97, 9311870), (10.97, 9311870), (10.98, 9311873), (10.97, 9311873), (10.95, 9311933), (10.92, 9311933), (10.96, 9311937), (10.97, 9311937), (10.97, 9311937), (10.97, 9311937), (10.98, 9311937), (10.98, 9311937), (10.92, 9311942), (10.92, 9311942), (10.92, 9311942), (10.92, 9311942), (10.92, 9311942), (10.92, 9311945), (10.98, 9312004), (10.98, 9312004), (10.98, 9312004), (10.99, 9312004), (10.99, 9312004), (10.99, 9312004), (10.99, 9312004), (11.0, 9312004), (11.0, 9312004), (10.93, 9312015), (10.98, 9312145), (10.95, 9312149), (10.95, 9312149), (10.95, 9312149), (10.95, 9312149), (10.95, 9312170), (10.95, 9312170), (10.93, 9312251), (10.93, 9312285), (10.93, 9312285), (10.94, 9312291), (10.94, 9312291), (10.94, 9312305), (10.95, 9312305), (10.95, 9312305), (10.95, 9312305), (10.98, 9312305), (10.98, 9312305), (10.98, 9312305), (10.98, 9312305), (10.98, 9312305), (10.98, 9312305), (10.98, 9312305), (10.98, 9312308), (10.98, 9312314), (10.98, 9312314), (10.98, 9312314), (10.98, 9312314), (10.98, 9312323), (10.98, 9312323), (10.99, 9312323), (10.99, 9312323), (10.98, 9312337), (10.98, 9312456), (11.0, 9312490), (11.0, 9312501), (11.0, 9312513), (10.98, 9312513), (10.99, 9312538), (10.99, 9312538), (10.99, 9312547), (10.99, 9312581), (10.98, 9312581), (11.0, 9312672), (11.0, 9312740), (10.99, 9312748), (10.99, 9312748), (10.99, 9312748), (11.0, 9312750), (11.0, 9312750), (10.99, 9312750), (10.99, 9312753), (10.99, 9312753), (10.99, 9312753), (11.0, 9312822), (10.99, 9312840), (10.99, 9312840), (10.99, 9312840), (10.99, 9312840), (11.0, 9312840), (11.0, 9312840), (11.0, 9312916), (11.0, 9312916), (11.0, 9312916), (11.0, 9312916), (11.0, 9312916), (11.0, 9312916), (11.0, 9312916), (11.01, 9312971), (11.0, 9312971), (10.99, 9312971), (10.99, 9312971), (11.02, 9313030), (11.04, 9313050), (11.04, 9313050), (11.04, 9313050), (11.04, 9313050), (11.04, 9313050), (11.04, 9313050), (11.04, 9313050), (11.04, 9313050), (11.04, 9313050), (11.04, 9313050), (11.04, 9313050), (11.04, 9313050), (11.04, 9313053), (11.04, 9313053), (11.04, 9313053), (11.04, 9313053), (11.04, 9313056), (11.04, 9313056), (11.04, 9313056), (11.02, 9313056), (11.01, 9313056), (11.0, 9313056), (11.0, 9313056), (11.04, 9313100), (11.04, 9313100), (11.05, 9313100), (11.01, 9313118), (11.01, 9313132), (11.0, 9313132), (11.04, 9313132), (11.05, 9313132), (11.05, 9313132), (11.05, 9313132), (11.05, 9313132), (11.05, 9313132), (11.05, 9313132), (11.05, 9313132), (11.05, 9313132), (11.05, 9313132), (11.05, 9313132), (11.05, 9313132), (11.05, 9313132), (11.05, 9313132), (11.05, 9313132), (11.05, 9313132), (11.05, 9313132), (11.01, 9313169), (11.01, 9313169), (11.01, 9313189), (11.01, 9313197), (11.01, 9313197), (11.04, 9313248), (11.04, 9313351), (11.04, 9313351), (11.04, 9313351), (11.05, 9313354), (11.04, 9313354), (11.04, 9313364), (11.04, 9313364), (11.04, 9313380), (11.04, 9313481), (11.04, 9313488), (11.04, 9313488), (11.05, 9313533), (11.06, 9313649), (11.05, 9313678), (11.04, 9313690), (11.04, 9313690), (11.04, 9313695), (11.04, 9313695), (11.03, 9313733), (11.03, 9313733), (11.03, 9313733), (11.03, 9313733), (11.03, 9313733), (11.03, 9313733), (11.03, 9313733), (11.03, 9313740), (11.03, 9313740), (11.03, 9313740), (11.03, 9313740), (11.03, 9313740), (11.03, 9313740), (11.03, 9313740), (11.03, 9313740), (11.03, 9313740), (11.03, 9313740), (11.03, 9313740), (11.03, 9313740), (11.03, 9313740), (11.03, 9313740), (11.03, 9313740), (11.03, 9313740), (11.03, 9313740), (11.03, 9313740), (11.0, 9313776), (11.0, 9313776), (11.0, 9313776), (11.0, 9313776), (11.0, 9313776), (11.0, 9313779)]}
    codes = {'300732', '300283'}
    for code in codes:
        print(code, get_cb_code(code))
    if code not in __latest_transaction_price_dict:
        __latest_transaction_price_dict[code] = []
    time_space = 2000
    while True:
        end_time, start_time = __latest_transaction_price_dict[code][-1][1], \
                               __latest_transaction_price_dict[code][0][1]
        if tool.trade_time_sub_with_ms(l2_huaxin_util.convert_time(end_time, with_ms=True),
                                       l2_huaxin_util.convert_time(start_time, with_ms=True)) <= time_space:
            break
        else:
            if __latest_transaction_price_dict[code]:
                # 删除第一个元素
                __latest_transaction_price_dict[code].pop(0)
    print(__latest_transaction_price_dict[code][-1][0] - __latest_transaction_price_dict[code][0][0], f"{__latest_transaction_price_dict[code]}")
trade/buy_strategy.py
@@ -168,7 +168,7 @@
            else:
                if self.__latest_transaction_price_dict[code]:
                    # 删除第一个元素
                    del self.__latest_transaction_price_dict[code][0]
                    self.__latest_transaction_price_dict[code].pop(0)
        return self.__latest_transaction_price_dict[code][-1][0] - self.__latest_transaction_price_dict[code][0][0], f"{self.__latest_transaction_price_dict[code]}"
utils/tool.py
@@ -160,7 +160,7 @@
def get_time_as_millionsecond(time_str):
    s_str, ms_str = time_str.split(".")
    ts = s_str.split(":")
    return int(ts[0]) * 3600 + int(ts[1]) * 60 + int(ts[2]) * 1000 + int(ms_str)
    return (int(ts[0]) * 3600 + int(ts[1]) * 60 + int(ts[2])) * 1000 + int(ms_str)
# 将秒数格式化为时间