| | |
| | | if temp_rate >= 1: |
| | | if temp_rate > 3: |
| | | temp_rate = 3 |
| | | deal_rate = round((temp_rate * 3.5 - 2.5) / 100, 4) if is_up else round((temp_rate * 10.5 - 7.5) / 100, 4) |
| | | deal_rate = round((temp_rate * 3.5 - 2.5) / 100, 4) if is_up else round( |
| | | (temp_rate * 10.5 - 7.5) / 100, 4) |
| | | |
| | | base_rate += block_rate |
| | | base_rate += deal_rate |
| | |
| | | if indexes: |
| | | trade_record_log_util.add_cancel_watch_indexes_log(code, |
| | | trade_record_log_util.CancelWatchIndexesInfo( |
| | | trade_record_log_util.CancelWatchIndexesInfo.CANCEL_TYPE_L_DOWN,buy_single_index, |
| | | trade_record_log_util.CancelWatchIndexesInfo.CANCEL_TYPE_L_DOWN, |
| | | buy_single_index, |
| | | list(indexes))) |
| | | |
| | | def __get_watch_indexes(self, code): |
| | |
| | | if indexes: |
| | | trade_record_log_util.add_cancel_watch_indexes_log(code, |
| | | trade_record_log_util.CancelWatchIndexesInfo( |
| | | trade_record_log_util.CancelWatchIndexesInfo.CANCEL_TYPE_L_UP,buy_single_index, |
| | | trade_record_log_util.CancelWatchIndexesInfo.CANCEL_TYPE_L_UP, |
| | | buy_single_index, |
| | | list(indexes))) |
| | | self.__near_by_trade_progress_index_cache[code] = indexes |
| | | RedisUtils.setex_async(self.__db, f"l_cancel_near_by_index-{code}", tool.get_expire(), |
| | |
| | | |
| | | # 计算观察索引,倒序计算 |
| | | def compute_watch_index(self, code, buy_single_index, start_index, end_index): |
| | | try: |
| | | l2_log.l_cancel_debug(code, f"计算L后囊括范围:{start_index}-{end_index}") |
| | | total_datas = local_today_datas.get(code) |
| | | if total_datas: |
| | | # 计算的上截至位距离下截至位纯买额要小于2.5倍m值 |
| | |
| | | # 小金额过滤 |
| | | if float(val['price']) * val['num'] < min_money * 100: |
| | | continue |
| | | left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code, |
| | | 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( |
| | |
| | | # 小金额过滤 |
| | | if float(val['price']) * val['num'] < 100 * 100: |
| | | continue |
| | | left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code, |
| | | 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( |
| | |
| | | break |
| | | self.__set_watch_indexes(code,buy_single_index, watch_indexes) |
| | | l2_log.l_cancel_debug(code, f"设置监听范围, 数据范围:{re_start_index}-{end_index} 监听范围-{watch_indexes}") |
| | | except Exception as e: |
| | | l2_log.l_cancel_debug(code, f"计算L后囊括范围出错:{str(e)}") |
| | | async_log_util.exception(logger_l2_l_cancel, e) |
| | | |
| | | # 设置真实下单位置 |
| | | def set_real_place_order_index(self, code, index, buy_single_index=None): |
| | | l2_log.l_cancel_debug(code, f"设置真实下单位-{index},buy_single_index-{buy_single_index}") |
| | | self.__real_place_order_index_dict[code] = index |
| | | if buy_single_index: |
| | | self.compute_watch_index(code, buy_single_index, buy_single_index, index) |
| | | if self.__last_trade_progress_dict.get(code): |
| | | self.__compute_trade_progress_near_by_indexes(code,buy_single_index, self.__last_trade_progress_dict.get(code) + 1, index) |
| | | self.__compute_trade_progress_near_by_indexes(code, buy_single_index, |
| | | self.__last_trade_progress_dict.get(code) + 1, index) |
| | | else: |
| | | self.__compute_trade_progress_near_by_indexes(code, buy_single_index, buy_single_index, index) |
| | | |
| | |
| | | if code not in self.__real_place_order_index_dict: |
| | | return |
| | | if code not in self.__last_l_up_compute_info or time.time() - self.__last_l_up_compute_info[code][0] >= 3: |
| | | self.__compute_trade_progress_near_by_indexes(code,buy_single_index, self.__last_trade_progress_dict.get(code) + 1, |
| | | self.__compute_trade_progress_near_by_indexes(code, buy_single_index, |
| | | self.__last_trade_progress_dict.get(code) + 1, |
| | | self.__real_place_order_index_dict.get(code)) |
| | | |
| | | # 计算范围内的成交位临近未撤大单 |
| | |
| | | self.__last_trade_progress_dict[code] = index |
| | | |
| | | # 重新计算成交位置临近大单撤单 |
| | | self.__compute_trade_progress_near_by_indexes(code, buy_single_index, index + 1, self.__real_place_order_index_dict.get(code)) |
| | | self.__compute_trade_progress_near_by_indexes(code, buy_single_index, index + 1, |
| | | self.__real_place_order_index_dict.get(code)) |
| | | |
| | | # 成交进度与L下撤无关 |
| | | # try: |
| | |
| | | def __compute_need_cancel(self, code, buy_exec_index, start_index, end_index, total_data, is_first_code): |
| | | watch_indexes = self.__get_watch_indexes_cache(code) |
| | | if not watch_indexes: |
| | | |
| | | return False, None |
| | | watch_indexes = set([int(i) for i in watch_indexes]) |
| | | # 计算监听的总条数 |