| | |
| | | from l2.huaxin import l2_huaxin_util, huaxin_delegate_postion_manager |
| | | from l2.l2_limitup_sell_data_manager import L2LimitUpSellDataManager |
| | | from l2.l2_sell_manager import L2MarketSellManager, L2LimitUpSellManager |
| | | from l2.l2_transaction_data_manager import HuaXinSellOrderStatisticManager, BigOrderDealManager |
| | | from l2.l2_transaction_data_manager import HuaXinSellOrderStatisticManager, BigOrderDealManager, HuaXinBuyOrderManager |
| | | 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 |
| | |
| | | max_num_set=set(), |
| | | buy_volume_rate=buy_volume_rate, |
| | | mode=OrderBeginPosInfo.MODE_RADICAL, |
| | | mode_desc=f"总抛压小扫入", |
| | | mode_desc=f"总抛压小扫入:{radical_result[2]}", |
| | | sell_info=sell_info, |
| | | threshold_money=threshold_money) |
| | | order_begin_pos_info.at_limit_up = cls.__is_at_limit_up_buy(code) |
| | |
| | | if cls.__is_at_limit_up_buy(code, start_index): |
| | | return False, None, "板上放量" |
| | | total_datas = local_today_datas[code] |
| | | min_num = int(29900 / gpcode_manager.get_limit_up_price_as_num(code)) |
| | | limit_up_price = gpcode_manager.get_limit_up_price_as_num(code) |
| | | bigger_money = l2_data_util.get_big_money_val(limit_up_price, tool.is_ge_code(code)) |
| | | min_num = int(bigger_money / limit_up_price / 100) |
| | | # 如果有大单成交就不需要看大单 |
| | | deal_money_list = BigOrderDealManager().get_total_buy_money_list(code) |
| | | if deal_money_list: |
| | | for m in deal_money_list: |
| | | if m >= 2990000: |
| | | min_num = int(5000 / gpcode_manager.get_limit_up_price_as_num(code)) |
| | | break |
| | | total_deal_money = BigOrderDealManager().get_total_buy_money(code) |
| | | THRESHOLD_MONEY = 2990000 |
| | | if total_deal_money >= THRESHOLD_MONEY: |
| | | min_num = int(5000 / limit_up_price) |
| | | |
| | | single_index = None |
| | | for i in range(start_index, end_index + 1): |
| | |
| | | continue |
| | | if val["num"] < min_num: |
| | | continue |
| | | # 上证有可能是部分成交的大单 |
| | | if i == start_index and tool.is_sh_code(code): |
| | | dealing_active_order_info = HuaXinBuyOrderManager().get_dealing_active_order_info(code) |
| | | if dealing_active_order_info and dealing_active_order_info[0] == int(val["orderNo"]): |
| | | # 判断是否为大单 |
| | | order_money = dealing_active_order_info[2] + round(val["price"], 2) * val["num"] * 100 |
| | | if order_money >= bigger_money: |
| | | total_deal_money += order_money |
| | | if total_deal_money >= THRESHOLD_MONEY: |
| | | single_index = i |
| | | break |
| | | |
| | | if int(val["orderNo"]) <= radical_data[1]: |
| | | # 主动买单后的数据不算 |
| | | continue |
| | | single_index = i |
| | | break |
| | | |
| | | total_deal_money += round(val["price"], 2) * val["num"] * 100 |
| | | if total_deal_money >= THRESHOLD_MONEY: |
| | | single_index = i |
| | | break |
| | | if single_index is not None: |
| | | return True, single_index, "有大单" |
| | | return False, None, "无大单" |
| | |
| | | return False, None, "超过生效时间" |
| | | result = __can_order() |
| | | l2_log.debug(code, f"L2扫入判断:{result}") |
| | | if result[0]: |
| | | return True, result[1], f"扫入板块:{radical_data[2]}" |
| | | return result |
| | | |
| | | @classmethod |
| | |
| | | except: |
| | | pass |
| | | |
| | | |
| | | total_datas = l2_data_util.local_today_datas.get(code) |
| | | use_time_list = [] |
| | | try: |
| | |
| | | logger_debug.exception(e) |
| | | _start_time = time.time() |
| | | L2LimitUpSellDataManager.set_deal_datas(code, datas) |
| | | cls.__statistic_thread_pool.submit(cls.statistic_big_order_infos, code, datas, order_begin_pos) |
| | | # 大单统计 |
| | | # cls.__statistic_thread_pool.submit(cls.statistic_big_order_infos, code, datas, order_begin_pos) |
| | | cls.statistic_big_order_infos(code, datas, order_begin_pos) |
| | | |
| | | use_time_list.append(("统计买单数据", time.time() - _start_time)) |
| | | _start_time = time.time() |
| | |
| | | L2TradeDataProcessor.start_buy(code, total_datas[-1], total_datas[-1]["index"], True) |
| | | else: |
| | | RadicalBuyDealCodesManager.buy_by_l2_delegate_expire_time_dict[code] = ( |
| | | time.time() + 3, transaction_datas[-1][6]) |
| | | time.time() + 2, transaction_datas[-1][6], buy_blocks) |
| | | else: |
| | | async_log_util.info(logger_l2_radical_buy, f"不能下单:{code}-{result_by_volume}") |
| | | else: |
| | |
| | | 激进买策略管理 |
| | | """ |
| | | # 上一个50W的起始时间:{code:"09:30:00.120"} |
| | | import l2_data_util |
| | | from code_attribute import code_volumn_manager, gpcode_manager |
| | | from l2 import l2_data_manager |
| | | from l2.huaxin import l2_huaxin_util |
| | | from l2.l2_limitup_sell_data_manager import L2LimitUpSellDataManager |
| | | from l2.l2_sell_manager import L2MarketSellManager |
| | | from l2.l2_transaction_data_manager import HuaXinSellOrderStatisticManager, BigOrderDealManager |
| | | from l2.l2_transaction_data_manager import HuaXinSellOrderStatisticManager, BigOrderDealManager, HuaXinBuyOrderManager |
| | | from log_module import async_log_util |
| | | from log_module.log import logger_l2_radical_buy, hx_logger_l2_transaction |
| | | from trade import radical_buy_data_manager |
| | |
| | | with_info=False) |
| | | if volume_rate is None: |
| | | volume_rate = 0.5 |
| | | # 根据大单判断是否可以扫 |
| | | big_order_deal_result = __is_big_order_deal_enough(code, volume_rate) |
| | | if not big_order_deal_result[0]: |
| | | return BUY_MODE_NONE, big_order_deal_result[1] |
| | | |
| | | THRESHOLD_RATE = radical_buy_data_manager.get_volume_rate_threshold(code, volume_rate) |
| | | if rate >= THRESHOLD_RATE: |
| | | # 成交的比例 |
| | | # if total_sell > 1000 * 1e4: |
| | | if total_sell >= 0: |
| | | # 根据大单判断是否可以扫 |
| | | big_order_deal_result = __is_big_order_deal_enough(code, volume_rate) |
| | | if big_order_deal_result[0]: |
| | | return BUY_MODE_DIRECT, f"剩余涨停总卖额-{selling_num * price},原涨停总卖-{total_sell},已成交额-{__deal_active_buy_total_money[code]},成交比例-{rate}/{THRESHOLD_RATE}" |
| | | else: |
| | | return BUY_MODE_BY_L2, f"剩余涨停总卖额小于500w-{selling_num * price},原涨停总卖-{total_sell},已成交额-{__deal_active_buy_total_money[code]},成交比例-{rate}/{THRESHOLD_RATE} " |
| | | # 无大单成交就只能通过L2下单 |
| | | return BUY_MODE_BY_L2, f"无大单成交-{big_order_deal_result[1]},原涨停总卖-{total_sell},已成交额-{__deal_active_buy_total_money[code]},成交比例-{rate}/{THRESHOLD_RATE} " |
| | | else: |
| | | return BUY_MODE_NONE, f"被动卖成交比例未达到:剩余涨停总卖额-{selling_num * price},原涨停总卖-{total_sell},已成交额-{__deal_active_buy_total_money[code]},成交比例-{rate}/{THRESHOLD_RATE}" |
| | | else: |
| | |
| | | volume_rate = 0.5 |
| | | # 根据大单判断是否可以扫 |
| | | big_order_deal_result = __is_big_order_deal_enough(code, volume_rate) |
| | | if not big_order_deal_result[0]: |
| | | return BUY_MODE_NONE, big_order_deal_result[1] |
| | | return __get_deal_rate_by(code, huaxin_timestamp) |
| | | result = __get_deal_rate_by(code, huaxin_timestamp) |
| | | if result[0] == BUY_MODE_DIRECT: |
| | | if big_order_deal_result[0]: |
| | | return result |
| | | else: |
| | | return BUY_MODE_BY_L2, big_order_deal_result[1] |
| | | else: |
| | | return result |
| | | |
| | | |
| | | def __is_big_order_deal_enough(code, volume_rate): |
| | |
| | | money_y = min(money_y, 50) |
| | | money_y = max(money_y, 5) |
| | | # 计算大单参考数量 |
| | | threshold_count = int(round(0.4 * money_y)) |
| | | threshold_count = 1 # int(round(0.4 * money_y)) |
| | | threshold_money = threshold_count * 299 * 10000 |
| | | |
| | | if volume_rate >= 0.5 or True: |
| | | # 按量大于50%算 |
| | | # 当换手量>50%时,则,不需要每次扫入时需要≥2笔大单,而是累计需要≥2笔大单即可 |
| | | deal_big_order_money = BigOrderDealManager().get_total_buy_money(code) |
| | | # 获取正在成交的订单 |
| | | dealing_order_info = HuaXinBuyOrderManager().get_dealing_order_info(code) |
| | | |
| | | threshold_big_money = l2_data_util.get_big_money_val(limit_up_price, tool.is_ge_code(code)) |
| | | if dealing_order_info and dealing_order_info[2] >= threshold_big_money: |
| | | # 正在成交的订单是大单 |
| | | deal_big_order_money += dealing_order_info[2] |
| | | |
| | | if deal_big_order_money >= threshold_money: |
| | | return True, f"量比-{volume_rate}, 总大单成交金额({deal_big_order_money})>={threshold_money}" |
| | | else: |
| | |
| | | __deal_codes_cache = set() |
| | | __instance = None |
| | | __mysqldb = Mysqldb() |
| | | # 根据L2数据来激进买入的有效时间:{"code":(有效截至时间, 买单号)} |
| | | # 根据L2数据来激进买入的有效时间:{"code":(有效截至时间, 买单号, 扫入的板块)} |
| | | buy_by_l2_delegate_expire_time_dict = {} |
| | | # 仅仅买的板块 |
| | | radical_buy_blocks_dict = {} |