| | |
| | | SecondCancelBigNumComputer().set_real_place_order_index(code, index) |
| | | LCancelBigNumComputer().set_real_place_order_index(code, index, buy_single_index=buy_single_index) |
| | | HourCancelBigNumComputer().set_real_place_order_index(code, index, buy_single_index) |
| | | GCancelBigNumComputer().set_real_place_order_index(code, index) |
| | | GCancelBigNumComputer().set_real_place_order_index(code, index, buy_single_index) |
| | | |
| | | |
| | | class SecondCancelBigNumComputer: |
| | |
| | | # ---------------------------------G撤------------------------------- |
| | | class GCancelBigNumComputer: |
| | | __real_place_order_index_dict = {} |
| | | __trade_progress_index_dict = {} |
| | | __watch_indexes_dict = {} |
| | | |
| | | __instance = None |
| | | |
| | | def __new__(cls, *args, **kwargs): |
| | |
| | | cls.__instance = super(GCancelBigNumComputer, cls).__new__(cls, *args, **kwargs) |
| | | return cls.__instance |
| | | |
| | | def set_real_place_order_index(self, code, index): |
| | | def set_real_place_order_index(self, code, index, buy_single_index): |
| | | self.__real_place_order_index_dict[code] = index |
| | | start_index = buy_single_index |
| | | if code in self.__trade_progress_index_dict: |
| | | start_index = self.__trade_progress_index_dict.get(code) |
| | | self.__commpute_watch_indexes(code, start_index, index) |
| | | |
| | | def clear(self, code=None): |
| | | if code: |
| | | if code in self.__real_place_order_index_dict: |
| | | self.__real_place_order_index_dict.pop(code) |
| | | if code in self.__watch_indexes_dict: |
| | | self.__watch_indexes_dict.pop(code) |
| | | if code in self.__trade_progress_index_dict: |
| | | self.__trade_progress_index_dict.pop(code) |
| | | else: |
| | | self.__real_place_order_index_dict.clear() |
| | | self.__watch_indexes_dict.clear() |
| | | self.__trade_progress_index_dict.clear() |
| | | |
| | | def __commpute_watch_indexes(self, code, traded_index, real_order_index): |
| | | total_datas = local_today_datas.get(code) |
| | | watch_indexes = set() |
| | | for i in range(traded_index, real_order_index): |
| | | # 判断是否有未撤的大单 |
| | | data = total_datas[i] |
| | | val = data["val"] |
| | | if not L2DataUtil.is_limit_up_price_buy(val): |
| | | continue |
| | | if val["num"] * float(val["price"]) < 30000: |
| | | continue |
| | | # 是否已撤单 |
| | | left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code, i, |
| | | total_datas, |
| | | local_today_canceled_buyno_map.get( |
| | | code)) |
| | | if left_count > 0: |
| | | watch_indexes.add(i) |
| | | if not watch_indexes: |
| | | temp_list = [] |
| | | for i in range(traded_index, real_order_index): |
| | | data = total_datas[i] |
| | | val = data["val"] |
| | | if not L2DataUtil.is_limit_up_price_buy(val): |
| | | continue |
| | | if val["num"] * float(val["price"]) < 5000: |
| | | continue |
| | | temp_list.append((val["num"], data)) |
| | | if len(temp_list) > 15: |
| | | break |
| | | temp_list.sort(key=lambda x: x[0], reverse=True) |
| | | if temp_list: |
| | | watch_indexes.add(temp_list[0][1]["index"]) |
| | | self.__watch_indexes_dict[code] = watch_indexes |
| | | |
| | | def set_trade_progress(self, code, buy_single_index, index): |
| | | if self.__trade_progress_index_dict.get(code) != index: |
| | | self.__trade_progress_index_dict[code] = index |
| | | self.__commpute_watch_indexes(code, index, self.__real_place_order_index_dict.get(code)) |
| | | |
| | | def need_cancel(self, code, buy_exec_index, start_index, end_index): |
| | | if code not in self.__real_place_order_index_dict: |
| | |
| | | if tool.trade_time_sub(total_datas[end_index]["val"]["time"], total_datas[buy_exec_index]["val"]["time"]) > 15: |
| | | return False, None, "下单15s内才生效" |
| | | |
| | | watch_indexes = self.__watch_indexes_dict.get(code) |
| | | if watch_indexes is None: |
| | | watch_indexes = set() |
| | | |
| | | for i in range(start_index, end_index + 1): |
| | | data = total_datas[i] |
| | | val = data["val"] |
| | | if not L2DataUtil.is_limit_up_price_buy_cancel(val): |
| | | continue |
| | | if val["num"] * float(val["price"]) < 30000: |
| | | if val["num"] * float(val["price"]) < 5000: |
| | | continue |
| | | buy_index = l2_data_source_util.L2DataSourceUtils.get_buy_index_with_cancel_data_v2(data, |
| | | local_today_buyno_map.get( |
| | | code)) |
| | | if buy_index is not None and buy_index < real_place_order_index: |
| | | if buy_index is not None and buy_index < real_place_order_index and buy_index in watch_indexes: |
| | | return True, data, "" |
| | | return False, None, "" |
| | | |