| | |
| | | time_str = f"{time_str[0:2]}:{time_str[2:4]}:{time_str[4:6]}" |
| | | buy_1_price, buy_1_volume = data["buy"][0] |
| | | sell_1_price, sell_1_volume = data["sell"][0] |
| | | limit_up_price = gpcode_manager.get_limit_up_price(code) |
| | | limit_up_price = gpcode_manager.get_limit_up_price_as_num(code) |
| | | |
| | | code_price_manager.Buy1PriceManager().set_latest_buy1_money(code, buy_1_price, buy_1_volume) |
| | | |
| | |
| | | if not trade_util.is_can_order_by_state(state): |
| | | # 不处于可下单状态 |
| | | RadicalBuyDataManager().market_info_change(code) |
| | | |
| | | # 是否即将炸开 |
| | | if RadicalCodeMarketInfoManager().is_almost_open_limit_up(code): |
| | | # 即将炸开 |
| | | total_deal_big_order_info = radical_buy_data_manager.get_total_deal_big_order_info(code, limit_up_price) |
| | | if total_deal_big_order_info and total_deal_big_order_info[0]<=0: |
| | | # 大单足够 |
| | | l2_trade_single_callback.process_limit_up_active_buy(code, [], is_almost_open_limit_up=True, |
| | | l2_market_time_str=time_str) |
| | | |
| | | @classmethod |
| | | def trading_order_canceled(cls, code, order_no): |
| | |
| | | except Exception as e: |
| | | logger_debug.exception(e) |
| | | |
| | | def __process_limit_up_active_buy(self, code, transaction_datas): |
| | | def process_limit_up_active_buy(self, code, transaction_datas, is_almost_open_limit_up=False, |
| | | l2_market_time_str=''): |
| | | """ |
| | | 处理涨停主动买 |
| | | @param code: |
| | | @param transaction_datas: |
| | | @param is_almost_open_limit_up: 是否即将炸板 |
| | | @param l2_market_time_str: 时间 |
| | | @return: 是否清除本次上板数据 |
| | | """ |
| | | __start_time = time.time() |
| | |
| | | if not trade_util.is_can_order_by_state(state): |
| | | # 不处于可下单状态 |
| | | return True |
| | | |
| | | if transaction_datas: |
| | | async_log_util.info(logger_l2_radical_buy, f"涨停主动买:{code}-{transaction_datas[-1]}") |
| | | else: |
| | | async_log_util.info(logger_l2_radical_buy, |
| | | f"即将炸板:{code}-{is_almost_open_limit_up}-{l2_market_time_str}") |
| | | deal_codes = RadicalBuyDealCodesManager().get_deal_codes() |
| | | # 判断今日扫入的代码数量是否大于阈值 |
| | | radical_buy_setting = BuyMoneyAndCountSetting().get_radical_buy_setting() |
| | |
| | | return True |
| | | |
| | | # -----根据成交比例判断是否可买------ |
| | | result_by_volume = radical_buy_strategy.process_limit_up_active_buy_deal(code, transaction_datas) |
| | | result_by_volume = radical_buy_strategy.process_limit_up_active_buy_deal(code, transaction_datas, |
| | | is_almost_open_limit_up) |
| | | async_log_util.info(logger_l2_radical_buy, f"量买入结果判断:{code}, 结果:{result_by_volume} 板块:{buy_blocks}") |
| | | in_blocks = RealTimeKplMarketData.get_top_market_jingxuan_blocks() |
| | | buy_blocks_with_money = [(b, RealTimeKplMarketData.get_jx_block_in_money(b), |
| | |
| | | |
| | | if result_by_volume[0] == radical_buy_strategy.BUY_MODE_DIRECT and not tool.is_sh_code(code): |
| | | # 上证不能根据成交买入 |
| | | refer_sell_data = L2MarketSellManager().get_refer_sell_data(code, |
| | | l2_huaxin_util.convert_time( |
| | | transaction_datas[-1][3])) |
| | | latest_deal_time = l2_huaxin_util.convert_time(transaction_datas[-1][3]) |
| | | refer_sell_data = L2MarketSellManager().get_refer_sell_data(code, latest_deal_time) |
| | | total_datas = l2_data_util.local_today_datas.get(code) |
| | | buy_single_index, buy_exec_index = total_datas[-1]["index"], total_datas[-1]["index"] |
| | | buy_volume_rate = L2TradeDataProcessor.volume_rate_info[code][0] |
| | |
| | | RadicalBuyDataManager().big_order_deal_enough(code) |
| | | return True |
| | | else: |
| | | if transaction_datas: |
| | | latest_buy_no = transaction_datas[-1][6] |
| | | latest_deal_time = l2_huaxin_util.convert_time(transaction_datas[-1][3]) |
| | | else: |
| | | # 如果没有成交数据,就取最近的买单号 |
| | | total_datas = l2_data_util.local_today_datas.get(code) |
| | | latest_buy_no = 0 |
| | | for index in range(total_datas[-1]["index"], -1, -1): |
| | | if L2DataUtil.is_buy(total_datas[index]["val"]): |
| | | latest_buy_no = int(total_datas[index]["val"]["orderNo"]) |
| | | break |
| | | latest_deal_time = l2_market_time_str |
| | | RadicalBuyDealCodesManager.buy_by_l2_delegate_expire_time_dict[code] = ( |
| | | time.time() + 30, transaction_datas[-1][6], buy_blocks, |
| | | l2_huaxin_util.convert_time(transaction_datas[-1][3]), buy_blocks_with_money) |
| | | time.time() + 30, latest_buy_no, buy_blocks, |
| | | latest_deal_time, buy_blocks_with_money) |
| | | return False |
| | | else: |
| | | async_log_util.info(logger_l2_radical_buy, f"不能下单:{code}-{result_by_volume}") |
| | |
| | | async_log_util.info(logger_debug, f"扫入处理时长:{code}-{use_time}") |
| | | |
| | | def OnLimitUpActiveBuy(self, code, transaction_datas): |
| | | can_clear_before_data = self.__process_limit_up_active_buy(code, transaction_datas) |
| | | can_clear_before_data = self.process_limit_up_active_buy(code, transaction_datas) |
| | | if can_clear_before_data: |
| | | # 清除 |
| | | EveryLimitupBigDealOrderManager.clear(code) |
| | |
| | | threading.Thread(target=run_pending, daemon=True).start() |
| | | l2_data_util.load_l2_data_all(True) |
| | | # L2成交信号回调 |
| | | L2TradeSingleDataManager.set_callback(MyL2TradeSingleCallback()) |
| | | global l2_trade_single_callback |
| | | l2_trade_single_callback = MyL2TradeSingleCallback() |
| | | |
| | | L2TradeSingleDataManager.set_callback(l2_trade_single_callback) |
| | | # 加载自由流通量 |
| | | global_data_loader.load_zyltgb_volume_from_db() |
| | | |