| | |
| | | transaction_progress, cancel_buy_strategy, place_order_single_data_manager |
| | | from l2.cancel_buy_strategy import DCancelBigNumComputer, \ |
| | | LatestCancelIndexManager, \ |
| | | NewGCancelBigNumComputer, JCancelBigNumComputer, L2DataComputeUtil |
| | | NewGCancelBigNumComputer, JCancelBigNumComputer, L2DataComputeUtil, RDCancelBigNumComputer |
| | | from l2.l2_data_manager import L2DataException, OrderBeginPosInfo |
| | | from l2.l2_data_util import local_today_datas, L2DataUtil, local_today_num_operate_map, local_today_buyno_map, \ |
| | | local_latest_datas, local_today_canceled_buyno_map, local_today_sellno_map |
| | |
| | | f"J撤出错 参数:buy_single_index-{_buy_single_index} buy_exec_index-{_buy_exec_index} 错误原因:{str(e)}") |
| | | return None, "" |
| | | |
| | | # RD撤 |
| | | def rd_cancel(_buy_single_index, _buy_exec_index): |
| | | try: |
| | | b_need_cancel, b_cancel_data, extra_msg = RDCancelBigNumComputer().need_cancel(code, start_index, |
| | | end_index) |
| | | if b_need_cancel and b_cancel_data: |
| | | return b_cancel_data, f"RD撤({extra_msg})", trade_constant.CANCEL_TYPE_RD |
| | | except Exception as e: |
| | | async_log_util.error(logger_l2_error, |
| | | f"RD撤出错 参数:buy_single_index-{_buy_single_index} buy_exec_index-{_buy_exec_index} 错误原因:{str(e)}") |
| | | return None, "", trade_constant.CANCEL_TYPE_RD |
| | | |
| | | if start_index < 0: |
| | | start_index = 0 |
| | | |
| | |
| | | if order_begin_pos.buy_volume_rate is None: |
| | | order_begin_pos.buy_volume_rate = 0.2 |
| | | cancel_data, cancel_msg, cancel_type = None, "", None |
| | | if order_begin_pos.mode == OrderBeginPosInfo.MODE_RADICAL: |
| | | |
| | | if not cancel_data: |
| | | cancel_data, cancel_msg, cancel_type = rd_cancel(order_begin_pos.buy_single_index, |
| | | order_begin_pos.buy_exec_index) |
| | | |
| | | # 扫入下单只有L撤 |
| | | if not cancel_data: |
| | | cancel_data, cancel_msg, cancel_type = l_cancel(order_begin_pos.buy_single_index, |
| | | order_begin_pos.buy_exec_index) |
| | | else: |
| | | if not cancel_data: |
| | | cancel_data, cancel_msg = g_cancel(order_begin_pos.buy_single_index, order_begin_pos.buy_exec_index) |
| | | cancel_type = trade_constant.CANCEL_TYPE_G |
| | |
| | | l2_log.debug(code, "处理买入成功2") |
| | | params_desc = cls.__l2PlaceOrderParamsManagerDict[code].get_buy_rank_desc() |
| | | l2_log.debug(code, params_desc) |
| | | #################清除本次下单的大单数据############### |
| | | EveryLimitupBigDealOrderManager.clear(code) |
| | | ############记录下单时的数据############ |
| | | try: |
| | | jx_blocks, jx_blocks_by = KPLCodeJXBlockManager().get_jx_blocks_cache( |
| | |
| | | # 是否是交易队列触发 |
| | | # 扫入下单只有L撤能撤单 |
| | | if order_begin_pos and order_begin_pos.mode == OrderBeginPosInfo.MODE_RADICAL and cancel_type not in { |
| | | trade_constant.CANCEL_TYPE_L_DOWN, trade_constant.CANCEL_TYPE_L}: |
| | | trade_constant.CANCEL_TYPE_L_DOWN, trade_constant.CANCEL_TYPE_L, trade_constant.CANCEL_TYPE_RD}: |
| | | l2_log.cancel_debug(code, "撤单中断,原因:{}", "扫入下单不是L撤") |
| | | return False |
| | | # 加绿只有L撤/人撤生效 |
| | |
| | | block_info=radical_result[3]) |
| | | if ordered: |
| | | radical_buy_data_manager.BlockPlaceOrderRecordManager().add_record(code, radical_result[2]) |
| | | # 监听大单 |
| | | RDCancelBigNumComputer().set_watch_indexes(code, radical_result[4]) |
| | | return |
| | | |
| | | if RadicalBuyDealCodesManager.radical_buy_blocks_dict.get(code): |
| | | if RadicalBuyDealCodesManager().get_code_blocks(code): |
| | | # 已经扫入下过单 |
| | | return |
| | | |
| | | if not constant.CAN_COMMON_BUY: |
| | |
| | | @param code: |
| | | @param start_index: |
| | | @param end_index: |
| | | @return: (是否获取到信号, 信号位置, 扫入板块/消息, 扫入板块大单流入信息) |
| | | @return: (是否获取到信号, 信号位置, 扫入板块/消息, 扫入板块大单流入信息, 需要监听的大单) |
| | | """ |
| | | |
| | | # 激进买信号的时间 |
| | |
| | | def __can_order(): |
| | | # 判断是否是板上放量 |
| | | if cls.__is_at_limit_up_buy(code, start_index): |
| | | return False, None, "板上放量" |
| | | return False, None, "板上放量", None |
| | | total_datas = local_today_datas[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)) |
| | |
| | | |
| | | if constant.CAN_RADICAL_BUY_NEED_BIG_ORDER_EVERYTIME: |
| | | # 每次下单都需要大单 |
| | | total_deal_money = EveryLimitupBigDealOrderManager.get_big_buy_deal_order_money(code) |
| | | current_big_order_deal_money_info = EveryLimitupBigDealOrderManager.get_big_buy_deal_order_money_info( |
| | | code) |
| | | if current_big_order_deal_money_info: |
| | | total_deal_money = current_big_order_deal_money_info[0] |
| | | if current_big_order_deal_money_info and tool.trade_time_sub(tool.get_now_time_str(), |
| | | current_big_order_deal_money_info[1]) > 60: |
| | | # 60s以上的大单不看 |
| | | total_deal_money = 0 |
| | | else: |
| | | # 只需要总成交的大单 |
| | | 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) |
| | | |
| | | # 需要监听的大单 |
| | | watch_indexes = set() |
| | | # 总委托大单金额 |
| | | total_delegating_big_money = 0 |
| | | single_index = None |
| | |
| | | order_money = dealing_active_order_info[2] + round(val["price"], 2) * val["num"] * 100 |
| | | if order_money >= bigger_money: |
| | | total_delegating_big_money += order_money |
| | | watch_indexes.add(i) |
| | | if total_delegating_big_money + total_deal_money >= THRESHOLD_MONEY: |
| | | single_index = i |
| | | break |
| | |
| | | if int(val["orderNo"]) <= radical_data[1]: |
| | | # 主动买单后的数据不算 |
| | | continue |
| | | |
| | | watch_indexes.add(i) |
| | | 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: |
| | | return True, single_index, "有大单" |
| | | return False, None, "无大单" |
| | | return True, single_index, "有大单", watch_indexes |
| | | return False, None, "无大单", watch_indexes |
| | | |
| | | radical_data = RadicalBuyDealCodesManager.buy_by_l2_delegate_expire_time_dict.get(code) |
| | | record_codes = radical_buy_data_manager.BlockPlaceOrderRecordManager().get_codes() |
| | |
| | | # 如果板上放量不可买入就需要删除信号 |
| | | 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], radical_data[3] |
| | | return True, result[1], radical_data[2], radical_data[3], result[3] |
| | | return result |
| | | |
| | | @classmethod |