| | |
| | | |
| | | # 统计所有的成交量 |
| | | __deal_volume_list_dict = {} |
| | | # 统计涨停主动买的成交量 |
| | | __deal_active_buy_volume_list_dict = {} |
| | | |
| | | @classmethod |
| | | def statistic_total_deal_volume(cls, code, fdatas, limit_up_price): |
| | | def statistic_active_sell_deal_volume(cls, code, fdatas, limit_up_price): |
| | | """ |
| | | 统计总共的成交量 |
| | | 统计主动卖成交 |
| | | @param code: |
| | | @param fdatas: [(数据本身, 是否主动买, 是否涨停, 总成交额, 不含ms时间,含ms时间)] |
| | | @param limit_up_price: |
| | |
| | | # 只统计被动买 |
| | | if code not in cls.__deal_volume_list_dict: |
| | | cls.__deal_volume_list_dict[code] = [] |
| | | |
| | | # 为了加速处理,如果第一条数据和最后一条数据都是主动买就返回 |
| | | if fdatas[0][1] and fdatas[-1][1]: |
| | | return |
| | | for d in fdatas: |
| | | # 只统计被动买 |
| | | if d[1]: |
| | |
| | | # 删除超过5条数据 |
| | | if len(cls.__deal_volume_list_dict[code]) > 5: |
| | | cls.__deal_volume_list_dict[code] = cls.__deal_volume_list_dict[code][-5:] |
| | | |
| | | try: |
| | | # 统计主动买的成交量 |
| | | if code not in cls.__deal_active_buy_volume_list_dict: |
| | | cls.__deal_active_buy_volume_list_dict[code] = [] |
| | | for d in fdatas: |
| | | # 只统计主动买 |
| | | if not d[1]: |
| | | continue |
| | | # 只统计涨停买 |
| | | if not d[2]: |
| | | continue |
| | | time_str = d[4] |
| | | if cls.__deal_active_buy_volume_list_dict[code]: |
| | | if cls.__deal_active_buy_volume_list_dict[code][-1][0] == time_str: |
| | | # 如果是同一秒 |
| | | cls.__deal_active_buy_volume_list_dict[code][-1][1] += d[0][2] |
| | | else: |
| | | # 不是同一秒 |
| | | cls.__deal_active_buy_volume_list_dict[code].append([time_str, d[0][2]]) |
| | | else: |
| | | cls.__deal_active_buy_volume_list_dict[code].append([time_str, d[0][2]]) |
| | | # 删除超过10条数据 |
| | | if len(cls.__deal_active_buy_volume_list_dict[code]) > 10: |
| | | cls.__deal_active_buy_volume_list_dict[code] = cls.__deal_active_buy_volume_list_dict[code][-10:] |
| | | except: |
| | | pass |
| | | |
| | | @classmethod |
| | | def get_latest_3s_continue_deal_volumes(cls, code): |
| | |
| | | fdatas.append(deal_list[i]) |
| | | return fdatas |
| | | |
| | | @classmethod |
| | | def get_latest_6s_active_buy_deal_volumes(cls, code): |
| | | """ |
| | | 获取最近6s的主动买成交 |
| | | @param code: |
| | | @return: [(时间,量)] |
| | | """ |
| | | deal_list = cls.__deal_active_buy_volume_list_dict.get(code) |
| | | if not deal_list: |
| | | return [] |
| | | latest_time = deal_list[-1][0] |
| | | fdatas = [] |
| | | # 从倒数第二个数据计算 |
| | | for i in range(len(deal_list) - 1, -1, -1): |
| | | if tool.trade_time_sub(latest_time, deal_list[i][0]) < 6: |
| | | fdatas.append(deal_list[i]) |
| | | return fdatas |
| | | |
| | | @classmethod |
| | | def clear_latest_deal_volume(cls, code): |
| | |
| | | |
| | | # 返回最近1s的大单卖:(总卖金额,[(卖单号,总手数,价格,('开始时间',买单号),('结束时间',买单号)),...]) |
| | | @classmethod |
| | | def add_transaction_datas(cls, code, fdatas, limit_up_price=None): |
| | | def statistic_continue_limit_up_sell_transaction_datas(cls, code, fdatas, limit_up_price=None): |
| | | """ |
| | | 统计连续涨停卖成交的数据 |
| | | @param code: |
| | | @param fdatas: [(数据本身, 是否主动买, 是否涨停, 总成交额, 不含ms时间,含ms时间)] |
| | | @param limit_up_price: |
| | |
| | | |
| | | __start_time = time.time() |
| | | # 是否还有涨停卖剩下 |
| | | no_left_limit_up_sell = L2TradeSingleDataProcessor.process_passive_limit_up_sell_data(code, fdatas, |
| | | limit_up_price) |
| | | no_left_limit_up_sell = L2TradeSingleDataProcessor.process_passive_limit_up_sell_data(code, fdatas) |
| | | use_time = time.time() - __start_time |
| | | __start_time = time.time() |
| | | use_time_list.append(("处理涨停卖", use_time)) |