Administrator
2023-08-18 319526fe38fffe8b8fb6603cc8ccd9bbaa944393
相同订单的成交过滤
3个文件已修改
12 ■■■■■ 已修改文件
constant.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
huaxin_api/l2_client.py 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_data_manager_new.py 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
constant.py
@@ -1,7 +1,7 @@
# 是否为测试
import platform
TEST = True
TEST = False
# 是否允许交易
TRADE_ENABLE = True
huaxin_api/l2_client.py
@@ -49,6 +49,8 @@
    special_code_volume_for_order_dict = {}
    # 已经订阅的代码
    subscripted_codes = set()
    # 代码的上次成交的订单唯一索引
    __last_transaction_keys_dict = {}
    def __init__(self, api):
        lev2mdapi.CTORATstpLev2MdSpi.__init__(self)
@@ -304,6 +306,10 @@
                        "SubSeq": pTransaction['SubSeq'], "BuyNo": pTransaction['BuyNo'],
                        "SellNo": pTransaction['SellNo'],
                        "ExecType": pTransaction['ExecType'].decode()}
                key = f"{item['SecurityID']}_{item['TradePrice']}_{item['BuyNo']}"
                if self.__last_transaction_keys_dict.get(code) == key:
                    return
                self.__last_transaction_keys_dict[code] = key
                # print("逐笔成交", item)
                l2_data_manager.add_transaction_detail(item)
@@ -555,7 +561,6 @@
    print("l2_client启动成功")
    while True:
        time.sleep(2)
if __name__ == "__main__":
l2/l2_data_manager_new.py
@@ -1046,9 +1046,7 @@
            cls.__save_order_begin_data(code, buy_single_index, compute_index, compute_index,
                                        buy_nums, buy_count, max_num_set_new,
                                        cls.volume_rate_info[code][0])
            l2_log.debug(code, "__save_order_begin_data")
            cls.__LimitUpTimeManager.save_limit_up_time(code, total_datas[compute_index]["val"]["time"])
            l2_log.debug(code, "save_limit_up_time")
            cls.__TradePointManager.delete_buy_cancel_point(code)
            l2_log.debug(code, "delete_buy_cancel_point")
            # 直接下单
@@ -1075,7 +1073,6 @@
    def __get_order_begin_pos(cls, code):
        buy_single_index, buy_exec_index, compute_index, num, count, max_num_set, volume_rate = cls.__TradePointManager.get_buy_compute_start_data_cache(
            code)
        logger_debug.info(f"获取买入执行位置信息{code}:{buy_single_index}-{buy_exec_index}-{compute_index}-{num}-{count}")
        return buy_single_index, buy_exec_index, compute_index, num, count, max_num_set, volume_rate
    # 保存下单起始信号