| | |
| | | # 是否为测试 |
| | | import platform |
| | | |
| | | TEST = True |
| | | TEST = False |
| | | # 是否允许交易 |
| | | TRADE_ENABLE = True |
| | | |
| | |
| | | special_code_volume_for_order_dict = {} |
| | | # 已经订阅的代码 |
| | | subscripted_codes = set() |
| | | # 代码的上次成交的订单唯一索引 |
| | | __last_transaction_keys_dict = {} |
| | | |
| | | def __init__(self, api): |
| | | lev2mdapi.CTORATstpLev2MdSpi.__init__(self) |
| | |
| | | "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) |
| | | |
| | |
| | | print("l2_client启动成功") |
| | | while True: |
| | | time.sleep(2) |
| | | |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | |
| | | 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") |
| | | # 直接下单 |
| | |
| | | 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 |
| | | |
| | | # 保存下单起始信号 |