Administrator
2023-08-31 ac2a9039d247359353a5c0553488d587b98137c4
G撤修改
2个文件已修改
28 ■■■■ 已修改文件
l2/cancel_buy_strategy.py 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/huaxin/trade_server.py 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/cancel_buy_strategy.py
@@ -1208,6 +1208,7 @@
    # 开始撤单
    def start_cancel(self, code, buy_no, total_datas, buy_order_no_map, local_operate_map, m_val_num):
        thresh_num = int(m_val_num * 1.5)
        place_order_index = self.__SecondCancelBigNumComputer.get_real_place_order_index_cache(code)
        if place_order_index is None:
            raise Exception("未获取到下单真实位置")
@@ -1227,11 +1228,11 @@
                                                                                                      local_operate_map)
                if left_count > 0:
                    buy_nums += left_count * data["val"]["num"]
                    if buy_nums > m_val_num:
                    if buy_nums > thresh_num:
                        break
        if buy_nums > m_val_num:
        if buy_nums > thresh_num:
            need_cancel = False
        return need_cancel, f"成交进度位({transaction_index})-真实下单位({place_order_index})  纯买手数:{buy_nums}/m值手数:{m_val_num}"
        return need_cancel, f"成交进度位({transaction_index})-真实下单位({place_order_index})  纯买手数:{buy_nums}/1.5倍m值手数:{thresh_num}"
# --------------------------------封单额变化撤------------------------
trade/huaxin/trade_server.py
@@ -289,20 +289,23 @@
    @classmethod
    def l2_transaction(cls, code, datas):
        hx_logger_l2_transaction.info(f"{code}#{datas}")
        async_log_util.info(hx_logger_l2_transaction, f"{code}#{datas}")
        if datas:
            # 设置成交价
            current_price_process_manager.set_trade_price(code, datas[-1][1])
        try:
            buyno_map = l2_data_util.local_today_buyno_map.get(code)
            hx_logger_l2_transaction.info(
                f"{code}的买入订单号数量:{len(buyno_map.keys()) if buyno_map else 0}")
            if not buyno_map:
                if trade_manager.CodesTradeStateManager().get_trade_state(code) != trade_manager.TRADE_STATE_NOT_TRADE:
                    l2_data_util.load_l2_data(code)
                    buyno_map = l2_data_util.local_today_buyno_map.get(code)
            async_log_util.info(hx_logger_l2_transaction, f"{code}的买入订单号数量:{len(buyno_map.keys()) if buyno_map else 0}")
            buy_progress_index = None
            for i in range(len(datas) - 1, -1, -1):
                d = datas[i]
                buy_no = f"{d[6]}"
                if buyno_map and buy_no in buyno_map:
                    hx_logger_l2_transaction.info(f"{code}成交进度:{buyno_map[buy_no]}")
                    async_log_util.info(hx_logger_l2_transaction, f"{code}成交进度:{buyno_map[buy_no]['index']}")
                    buy_progress_index = buyno_map[buy_no]["index"]
                    break
@@ -315,8 +318,7 @@
                    total_datas = l2_data_util.local_today_datas.get(code)
                    num_operate_map = l2_data_util.local_today_num_operate_map.get(
                        code)
                    logger_l2_trade_buy_queue.info("获取成交位置成功: code-{} index-{}", code,
                                                   buy_progress_index)
                    async_log_util.info(logger_l2_trade_buy_queue, "获取成交位置成功: code-{} index-{}", code, buy_progress_index)
                    buy_time = total_datas[buy_progress_index]["val"]["time"]
                    limit_up_price = gpcode_manager.get_limit_up_price(code)
                    if buy_exec_index:
@@ -836,9 +838,8 @@
if __name__ == "__main__":
    code = "603106"
    l2_data_util.load_l2_data(code, load_latest=False)
    buy_no_map = l2_data_util.local_today_buyno_map.get(code)
    print(buy_no_map.get("6114878"))
    code = "000536"
    TradeServerProcessor.l2_transaction(code,
                                        [('000536', 2.08, 20000, 143436460, 2014, 31126359, 16718956, 31126358, '1')])
    while True:
        time.sleep(10)