| | |
| | | """ |
| | | 添加大买单数据 |
| | | @param code: 代码 |
| | | @param datas:[(买单号,总股数,总成交额)] |
| | | @param datas:[(买单号,总股数,总成交额,成交开始时间,成交结束时间)] |
| | | @return: |
| | | """ |
| | | if not datas: |
| | |
| | | @return: |
| | | """ |
| | | if code not in self.__total_buy_datas_dict: |
| | | return 0 |
| | | return [] |
| | | return [x[2] for x in self.__total_buy_datas_dict[code]] |
| | | |
| | | def get_total_buy_data_list(self, code): |
| | | """ |
| | | 获取所有的买单数据列表 |
| | | @param code: |
| | | @return:[(买单号,总股数,总成交额,成交开始时间,成交结束时间)] |
| | | """ |
| | | return self.__total_buy_datas_dict.get(code) |
| | | |
| | | def get_total_sell_money(self, code): |
| | | """ |
| | |
| | | |
| | | # 统计所有的成交量 |
| | | __deal_volume_list_dict = {} |
| | | # 统计涨停主动买的成交量 |
| | | __deal_active_buy_volume_list_dict = {} |
| | | |
| | | @classmethod |
| | | def statistic_total_deal_volume(cls, code, datas): |
| | | def statistic_total_deal_volume(cls, code, datas, limit_up_price): |
| | | # 只统计被动买 |
| | | if code not in cls.__deal_volume_list_dict: |
| | | cls.__deal_volume_list_dict[code] = [] |
| | | |
| | | time_dict = {} |
| | | for d in datas: |
| | | # 只统计被动买 |
| | |
| | | # 删除超过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 datas: |
| | | # 只统计主动买 |
| | | if d[7] > d[6]: |
| | | continue |
| | | # 只统计涨停买 |
| | | if d[1] != limit_up_price: |
| | | continue |
| | | if d[3] in time_dict: |
| | | time_str = time_dict[d[3]] |
| | | else: |
| | | time_dict[d[3]] = l2_huaxin_util.convert_time(d[3]) |
| | | time_str = time_dict[d[3]] |
| | | 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[2] |
| | | else: |
| | | # 不是同一秒 |
| | | cls.__deal_active_buy_volume_list_dict[code].append([time_str, d[2]]) |
| | | else: |
| | | cls.__deal_active_buy_volume_list_dict[code].append([time_str, d[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 |
| | | |
| | | time_dict.clear() |
| | | |
| | | @classmethod |
| | |
| | | # 从倒数第二个数据计算 |
| | | for i in range(len(deal_list) - 1, -1, -1): |
| | | if tool.trade_time_sub(fdatas[0][0], deal_list[i][0]) < 2: |
| | | 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 |
| | | |
| | |
| | | total_sell_info[0] += int(latest_sell_order_info[1] * latest_sell_order_info[2]) |
| | | big_sell_orders.reverse() |
| | | total_sell_info[1] = big_sell_orders |
| | | # ----------------统计涨停主动买----------------- |
| | | try: |
| | | limit_up_active_buy_datas = [] |
| | | for d in datas: |
| | | if is_active_sell(d[7], d[6]): |
| | | # 被动买 |
| | | continue |
| | | # 是否是涨停 |
| | | if d[1] == limit_up_price: |
| | | # 有涨停主动买 |
| | | limit_up_active_buy_datas.append(d) |
| | | L2TradeSingleDataManager.set_limit_up_active_buy(code, limit_up_active_buy_datas) |
| | | except: |
| | | pass |
| | | |
| | | return total_sell_info |
| | | |
| | | # 获取最近成交数据 |