| | |
| | | |
| | | |
| | | # 处理l2数据 |
| | | def __format_l2_data(origin_datas, code, limit_up_price): |
| | | # filter_not_limit_up : 过滤掉非涨停数据 |
| | | def __format_l2_data(origin_datas, code, limit_up_price, filter_not_limit_up=True): |
| | | datas = [] |
| | | dataIndexs = {} |
| | | same_time_num = {} |
| | |
| | | item["limitPrice"] = "{}".format(limitPrice) |
| | | operateType = item["operateType"] |
| | | # 不需要非涨停买与买撤 |
| | | if int(item["limitPrice"]) != 1 and (int(operateType) == 0 or int(operateType) == 1) and num != 1: |
| | | if filter_not_limit_up and int(item["limitPrice"]) != 1 and ( |
| | | int(operateType) == 0 or int(operateType) == 1) and num != 1: |
| | | continue |
| | | key = "{}-{}-{}".format(code, item["mainSeq"], item["subSeq"]) |
| | | if key in dataIndexs: |
| | |
| | | def get_format_l2_datas(code, origin_datas, limit_up_price, start_index): |
| | | # 先转变数据格式 |
| | | datas = [__convert_order(x, float(limit_up_price)) for x in origin_datas] |
| | | fdatas = __format_l2_data(datas, code, float(limit_up_price)) |
| | | # 在9:25之前不过滤非涨停金额 |
| | | filter_not_limit_up = True |
| | | if int(datas[0]["time"][:5].replace(":", "")) <= 925: |
| | | filter_not_limit_up = False |
| | | fdatas = __format_l2_data(datas, code, float(limit_up_price), filter_not_limit_up=filter_not_limit_up) |
| | | for i in range(0, len(fdatas)): |
| | | fdatas[i]["index"] = start_index + i |
| | | return fdatas |