| | |
| | | from l2.l2_data_util import L2DataUtil, local_today_canceled_buyno_map |
| | | from l2.l2_transaction_data_manager import HuaXinBuyOrderManager |
| | | from l2.transaction_progress import TradeBuyQueue |
| | | from utils import tool |
| | | |
| | | |
| | | def __get_trade_queue(code, start_index, end_index, real_place_order_index, max_count, step=1): |
| | | fresults = [] |
| | | # 正在成交的数据 |
| | | dealing_info = HuaXinBuyOrderManager.get_dealing_order_info(code) |
| | | dealing_active_info = HuaXinBuyOrderManager.get_dealing_active_order_info(code) |
| | | |
| | | total_datas = l2_data_util.local_today_datas.get(code) |
| | | for i in range(start_index, end_index, step): |
| | | # 真实下单位置不管是否撤单都需要加入队列 |
| | | data = total_datas[i] |
| | | val = data['val'] |
| | | if not L2DataUtil.is_limit_up_price_buy(val): |
| | |
| | | total_datas, |
| | | local_today_canceled_buyno_map.get( |
| | | code)) |
| | | if left_count > 0: |
| | | if left_count > 0 or real_place_order_index == i: |
| | | if dealing_info and int(dealing_info[0]) > total_datas[i]["val"]["orderNo"]: |
| | | # 不能在正在成交位置之前 |
| | | continue |
| | | type_ = 0 |
| | | num = val['num'] |
| | | if dealing_info and str(total_datas[i]["val"]["orderNo"]) == str( |
| | | dealing_info[0]): |
| | | # 减去当前正在成交的数据中已经成交了的数据 |
| | | num -= dealing_info[1] // 100 |
| | | # 判断当前单的主动买的数量 |
| | | if dealing_active_info and str(total_datas[i]["val"]["orderNo"]) == str( |
| | | dealing_active_info[0]): |
| | | if tool.is_sh_code(code): |
| | | # 上证的票需要加上主动买的数据 |
| | | num += dealing_active_info[1] // 100 |
| | | |
| | | if i == real_place_order_index: |
| | | type_ = 1 |
| | | has_real_order_index = True |
| | | elif num * float(val['price']) >= 29900: |
| | | type_ = 2 |
| | | |
| | |
| | | if trade_index is None: |
| | | trade_index = 0 |
| | | threshold_before_count = max_count // 2 |
| | | |
| | | fresults = __get_trade_queue(code, real_place_order_index, trade_index - 1, real_place_order_index, |
| | | threshold_before_count, -1) |
| | | fresults.reverse() |