| | |
| | | from l2.place_order_single_data_manager import L2TradeSingleDataProcessor |
| | | from log_module import async_log_util, log_export |
| | | from third_data import kpl_data_manager, block_info |
| | | from utils import global_util, ths_industry_util, tool, buy_condition_util |
| | | from utils import global_util, ths_industry_util, tool, buy_condition_util, buy_strategy_util |
| | | import l2_data_util |
| | | from db import redis_manager_delegate as redis_manager |
| | | from third_data.code_plate_key_manager import CodePlateKeyBuyManager, KPLCodeJXBlockManager |
| | |
| | | order_begin_pos = cls.__get_order_begin_pos( |
| | | code) |
| | | if not trade_result_manager.can_place_order_for_cancel_time(code, total_data[order_begin_pos.buy_exec_index]): |
| | | return False, True, f"距离上次挂单小于1000ms" |
| | | return False, True, f"距离上次挂单小于时间限制" |
| | | if constant.L2_SOURCE_TYPE == constant.L2_SOURCE_TYPE_HUAXIN: |
| | | trade_price = current_price_process_manager.get_trade_price(code) |
| | | if trade_price is None: |
| | |
| | | if not buy1_money: |
| | | buy1_money = 1 |
| | | deal_rate = round(total_deal_money / buy1_money, 2) |
| | | if deal_rate < 0.05: |
| | | if deal_rate < 0.15: |
| | | # 判断成交进度到当前数据的笔数,如果少于10笔且还有未成交的大单(>=299)就可以下单 |
| | | trade_index, is_default = cls.__TradeBuyQueue.get_traded_index(code) |
| | | if trade_index is None: |
| | | trade_index = 0 |
| | | total_count = 0 |
| | | total_big_count = 0 |
| | | for i in range(trade_index + 1, total_data[-1]["index"] + 1): |
| | | data = total_data[i] |
| | | val = data["val"] |
| | | if not L2DataUtil.is_limit_up_price_buy(val): |
| | | continue |
| | | money = val["num"] * float(val["price"]) |
| | | if money < 5000: |
| | | continue |
| | | |
| | | left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2( |
| | | code, |
| | | i, |
| | | total_data, |
| | | local_today_canceled_buyno_map.get( |
| | | code)) |
| | | if left_count > 0: |
| | | total_count += 1 |
| | | if money > 29900: |
| | | total_big_count += 1 |
| | | if total_count > 10: |
| | | break |
| | | if total_count > 10 or total_big_count < 1: |
| | | return False, True, f"板上放量成交金额不足,近2s总成交比例({deal_rate}):{total_deal_money}/{buy1_money}小于0.05,未成交数量-{total_count},大单数量-{total_big_count}" |
| | | can_place_order, msg = buy_strategy_util.is_near_by_trade_index(code, trade_index) |
| | | if not can_place_order: |
| | | try: |
| | | # 不能下单,判断小群撤是否可以下 |
| | | if buy_strategy_util.is_has_small_batch_cancel(code, trade_index, order_begin_pos.buy_single_index): |
| | | # 判断撤单比例是否足够 |
| | | if not buy_strategy_util.is_cancel_rate_reieved(code, 0.69,trade_index, order_begin_pos.buy_single_index): |
| | | return False, True, f"板上放量不足,有小群撤, 整体撤单比例不足({trade_index}-{order_begin_pos.buy_single_index})" |
| | | else: |
| | | return False, True, f"板上放量不足,且没有小群撤({trade_index}-{order_begin_pos.buy_single_index})" |
| | | except Exception as e: |
| | | l2_log.info(code, logger_l2_error, "板上放量不足异常:{}",str(e)) |
| | | return False, True, f"板上放量不足" |
| | | # 上证下单需要有成交大单(包含主动买与被动买)或者挂买的大单 |
| | | if tool.is_sh_code(code): |
| | | deal_big_order_count = BigOrderDealManager().get_total_buy_count(code) |
| | |
| | | if left_count < 1: |
| | | return False, False, f"没有已挂或者成交的大单" |
| | | place_order_count = trade_data_manager.PlaceOrderCountManager().get_place_order_count(code) |
| | | # 第一和第二次下单都必须要有至少一笔未成交/待成交的大单 |
| | | # 第一和第二次下单都必须要有至少一笔未成交的大单 |
| | | # 计算大单 |
| | | total_datas = local_today_datas.get(code) |
| | | if place_order_count < 2: |
| | |
| | | if buy_count > THRESHOLD_BUY_COUNT: |
| | | break |
| | | if buy_count > THRESHOLD_BUY_COUNT: |
| | | HuaXinSellOrderStatisticManager.clear_latest_deal_volume(code) |
| | | cls.__next_buy_time_dict[code] = t.time() + 1 |
| | | return False, True, f"执行位批次数据量({buy_count})大于{THRESHOLD_BUY_COUNT} {range_indexes[0]}-{range_indexes[1]}" |
| | | # 判断是否为量化 |
| | | time_as_ms = tool.trade_time_sub_with_ms( |
| | | L2DataUtil.get_time_with_ms(total_datas[range_indexes[1]]["val"]), |
| | | L2DataUtil.get_time_with_ms(total_datas[range_indexes[0]]["val"])) |
| | | if time_as_ms <= 10 if tool.is_sz_code(code) else 100: |
| | | # 深证10ms内,上证100ms内就判定为量化 |
| | | HuaXinSellOrderStatisticManager.clear_latest_deal_volume(code) |
| | | cls.__next_buy_time_dict[code] = t.time() + buy_condition_util.get_cancel_and_buy_space_time( |
| | | code) / 1000 |
| | | # 如果是首次下单,增加一次下单次数 |
| | | place_order_count = trade_data_manager.PlaceOrderCountManager().get_place_order_count(code) |
| | | if place_order_count ==0: |
| | | trade_data_manager.PlaceOrderCountManager().place_order(code) |
| | | return False, True, f"执行位批次数据量({buy_count})大于{THRESHOLD_BUY_COUNT} {range_indexes[0]}-{range_indexes[1]}" |
| | | # 暂时注释想买单功能 |
| | | if not cls.__WantBuyCodesManager.is_in_cache(code): |
| | | # if cls.__TradeTargetCodeModeManager.get_mode_cache() == TradeTargetCodeModeManager.MODE_ONLY_BUY_WANT_CODES: |