| | |
| | | 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 trade.buy_radical.radical_buy_data_manager import EveryLimitupBigDealOrderManager |
| | | from utils import global_util, tool, buy_condition_util, buy_strategy_util, trade_util |
| | | import l2_data_util |
| | | from db import redis_manager_delegate as redis_manager |
| | |
| | | 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) |
| | | # 如果有大单成交就不需要看大单 |
| | | total_deal_money = BigOrderDealManager().get_total_buy_money(code) |
| | | |
| | | if constant.CAN_RADICAL_BUY_NEED_BIG_ORDER_EVERYTIME: |
| | | # 每次下单都需要大单 |
| | | total_deal_money = EveryLimitupBigDealOrderManager.get_big_buy_deal_order_money(code) |
| | | else: |
| | | # 只需要总成交的大单 |
| | | total_deal_money = BigOrderDealManager().get_total_buy_money(code) |
| | | refer_sell_data = L2MarketSellManager().get_refer_sell_data(code, radical_data[3]) |
| | | # 参考总卖额 |
| | | refer_sell_money = 0 |
| | | if refer_sell_data: |
| | | refer_sell_money = refer_sell_data[1] |
| | | THRESHOLD_MONEY = 2990000 |
| | | if total_deal_money >= THRESHOLD_MONEY: |
| | | if refer_sell_money >= 1e7: |
| | | THRESHOLD_MONEY = 2990000 * 2 |
| | | else: |
| | | THRESHOLD_MONEY = 2990000 |
| | | if total_deal_money >= THRESHOLD_MONEY: |
| | | min_num = int(5000 / limit_up_price) |
| | | |
| | | # 总委托大单金额 |
| | | total_delegating_big_money = 0 |
| | | single_index = None |
| | | for i in range(start_index, end_index + 1): |
| | | data = total_datas[i] |
| | |
| | | # 判断是否为大单 |
| | | 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 |
| | | total_delegating_big_money += order_money |
| | | if total_delegating_big_money + total_deal_money >= THRESHOLD_MONEY: |
| | | single_index = i |
| | | break |
| | | |
| | | if int(val["orderNo"]) <= radical_data[1]: |
| | | # 主动买单后的数据不算 |
| | | continue |
| | | |
| | | total_deal_money += round(val["price"], 2) * val["num"] * 100 |
| | | if total_deal_money >= THRESHOLD_MONEY: |
| | | total_delegating_big_money += round(val["price"], 2) * val["num"] * 100 |
| | | if total_delegating_big_money + total_deal_money >= THRESHOLD_MONEY: |
| | | single_index = i |
| | | break |
| | | if single_index is not None: |
| | |
| | | |
| | | if not radical_data: |
| | | return False, None, "不满足激进买的条件" |
| | | if t.time() > radical_data[0] and not is_radical_buy: |
| | | # 没扫入过才需要判断时间 |
| | | return False, None, "超过生效时间" |
| | | |
| | | if constant.CAN_RADICAL_BUY_AT_LIMIT_UP: |
| | | # 板上放量可扫入 |
| | | if t.time() > radical_data[0] and not is_radical_buy: |
| | | # 没扫入过才需要判断时间 |
| | | return False, None, "超过生效时间" |
| | | else: |
| | | # 板上放量不可扫入 |
| | | if t.time() > radical_data[0]: |
| | | return False, None, "超过生效时间" |
| | | |
| | | result = __can_order() |
| | | l2_log.debug(code, f"L2扫入判断:{result}") |
| | | if result[0]: |
| | | # 已经扫入下过单的就需要判断板上放量的距离 |
| | | if is_radical_buy: |
| | | # 已经扫入下过单且允许板上放量扫入的就需要判断板上放量的距离 |
| | | if is_radical_buy and constant.CAN_RADICAL_BUY_AT_LIMIT_UP: |
| | | is_limit_up_buy = cls.__is_at_limit_up_buy(code) |
| | | if is_limit_up_buy: |
| | | # 判断成交进度到当前数据的笔数,如果少于10笔且还有未成交的大单(>=299)就可以下单 |
| | |
| | | deal_codes) |
| | | if not buy_blocks: |
| | | return False, result[1], f"板块代码已有成交:{radical_data[2]}" |
| | | # 如果板上放量不可买入就需要删除信号 |
| | | if not constant.CAN_RADICAL_BUY_AT_LIMIT_UP and code in RadicalBuyDealCodesManager.buy_by_l2_delegate_expire_time_dict: |
| | | RadicalBuyDealCodesManager.buy_by_l2_delegate_expire_time_dict.pop(code) |
| | | return True, result[1], radical_data[2] |
| | | return result |
| | | |