| | |
| | | |
| | | # 正在成交的订单 |
| | | __dealing_order_info_dict = {} |
| | | |
| | | # 正在成交的主动买的订单 |
| | | __dealing_active_buy_order_info_dict = {} |
| | | # 最近成交的订单{"code":(订单号,是否成交完成)} |
| | | __latest_deal_order_info_dict = {} |
| | | |
| | |
| | | return cls.__dealing_order_info_dict.get(code) |
| | | |
| | | @classmethod |
| | | def get_dealing_active_order_info(cls, code): |
| | | """ |
| | | 获取正在主动成交的数据 |
| | | @param code: |
| | | @return:[订单号,总股数,成交金额,成交开始时间,成交结束时间] |
| | | """ |
| | | return cls.__dealing_active_buy_order_info_dict.get(code) |
| | | |
| | | @classmethod |
| | | def statistic_big_buy_data(cls, code, datas, limit_up_price): |
| | | """ |
| | | 统计大单买 |
| | |
| | | if code not in cls.__dealing_order_info_dict: |
| | | # 数据格式[订单号,总股数,成交金额,成交开始时间,成交结束时间] |
| | | cls.__dealing_order_info_dict[code] = [data[6], data[2], data[2] * data[1], data[3], data[3]] |
| | | else: |
| | | if cls.__dealing_order_info_dict[code][0] == data[6]: |
| | | # 成交同一个订单号 |
| | | cls.__dealing_order_info_dict[code][1] += data[2] |
| | |
| | | |
| | | # 初始化本条数据 |
| | | cls.__dealing_order_info_dict[code] = [data[6], data[2], data[2] * data[1], data[3], data[3]] |
| | | # 统计主动买(买单号大于卖单号) |
| | | try: |
| | | if data[6] > data[7]: |
| | | if code not in cls.__dealing_active_buy_order_info_dict: |
| | | # 数据格式[订单号,总股数,成交金额,成交开始时间,成交结束时间] |
| | | cls.__dealing_active_buy_order_info_dict[code] = [data[6], data[2], data[2] * data[1], data[3], |
| | | data[3]] |
| | | else: |
| | | if cls.__dealing_active_buy_order_info_dict[code][0] == data[6]: |
| | | # 成交同一个订单号 |
| | | cls.__dealing_active_buy_order_info_dict[code][1] += data[2] |
| | | cls.__dealing_active_buy_order_info_dict[code][2] += data[2] * data[1] |
| | | cls.__dealing_active_buy_order_info_dict[code][4] = data[3] |
| | | else: |
| | | # 初始化本条数据 |
| | | cls.__dealing_active_buy_order_info_dict[code] = [data[6], data[2], data[2] * data[1], |
| | | data[3], data[3]] |
| | | except: |
| | | pass |
| | | |
| | | return big_buy_datas, normal_buy_datas |
| | | |
| | | |
| | |
| | | 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): |
| | | # 真实下单位置不管是否撤单都需要加入队列 |
| | |
| | | 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 |
| | |
| | | trade_progress, is_default = transaction_progress.TradeBuyQueue().get_traded_index(code) |
| | | # 获取正在成交, 计算成交进度 |
| | | dealing_info = HuaXinBuyOrderManager.get_dealing_order_info(code) |
| | | dealing_active_info = HuaXinBuyOrderManager.get_dealing_active_order_info(code) |
| | | percent = 100 |
| | | if dealing_info: |
| | | total_datas = l2_data_util.local_today_datas.get(code) |
| | | if str(total_datas[trade_progress]['val']["orderNo"]) == str(dealing_info[0]): |
| | | percent = int(dealing_info[1] / total_datas[trade_progress]['val']['num']) |
| | | num = total_datas[trade_progress]['val']['num'] |
| | | if dealing_active_info and dealing_info[0] == dealing_active_info[0]: |
| | | if tool.is_sh_code(code): |
| | | num += dealing_active_info[1]//100 |
| | | percent = int(dealing_info[1] / num) |
| | | response_data = json.dumps( |
| | | {"code": 0, "data": {"trade_progress": trade_progress, "is_default": is_default, "percent": percent}}) |
| | | elif url.path == "/get_l_cancel_datas": |