| | |
| | | return left_big_num |
| | | |
| | | @classmethod |
| | | def need_cancel(cls, code, buy_single_index, buy_exec_index, start_index, end_index, total_data, |
| | | def need_cancel(cls, code, buy_single_index, buy_exec_index, start_index, end_index, total_data, is_first_code, |
| | | need_cancel=True): |
| | | if start_index >= 217: |
| | | print("进入调试") |
| | |
| | | cancel_rate_threshold = constant.S_CANCEL_SECOND_RATE |
| | | else: |
| | | cancel_rate_threshold = constant.S_CANCEL_THIRD_RATE |
| | | if is_first_code: |
| | | cancel_rate_threshold += 0.1 |
| | | cancel_rate_threshold = round(cancel_rate_threshold, 2) |
| | | if cancel_num / max(buy_num, 1) > cancel_rate_threshold: |
| | | return True, total_data[i] |
| | | finally: |
| | |
| | | cls.__getRedis().delete(key) |
| | | |
| | | @classmethod |
| | | def need_cancel(cls, code, buy_exec_index, start_index, end_index, total_data, local_today_num_operate_map): |
| | | def need_cancel(cls, code, buy_exec_index, start_index, end_index, total_data, local_today_num_operate_map, |
| | | is_first_code): |
| | | time_space = tool.trade_time_sub(total_data[start_index]["val"]["time"], |
| | | total_data[buy_exec_index]["val"]["time"]) |
| | | if time_space >= constant.S_CANCEL_EXPIRE_TIME - 1: |
| | |
| | | cancel_rate_threshold = constant.H_CANCEL_SECOND_RATE |
| | | else: |
| | | cancel_rate_threshold = constant.H_CANCEL_THIRD_RATE |
| | | if is_first_code: |
| | | cancel_rate_threshold += 0.1 |
| | | cancel_rate_threshold = round(cancel_rate_threshold,2) |
| | | process_index = start_index |
| | | try: |
| | | for i in range(start_index, end_index + 1): |
| | |
| | | |
| | | # 涨停买是否撤单 |
| | | @classmethod |
| | | def __get_limit_up_buy_no_canceled_count(cls, code, index, total_data, local_today_num_operate_map): |
| | | def __get_limit_up_buy_no_canceled_count(cls, code, index, total_data, local_today_num_operate_map, |
| | | MAX_EXPIRE_CANCEL_TIME=None): |
| | | data = None |
| | | try: |
| | | data = total_data[index] |
| | |
| | | buy_index = l2_data_source_util.L2DataSourceUtils.get_buy_index_with_cancel_data(code, cancel_data, |
| | | local_today_num_operate_map) |
| | | if buy_index == index: |
| | | if MAX_EXPIRE_CANCEL_TIME and tool.trade_time_sub(cancel_data["val"]["time"], |
| | | MAX_EXPIRE_CANCEL_TIME) > 0: |
| | | continue |
| | | canceled = True |
| | | count = data["re"] - cancel_data["re"] |
| | | if count > 0: |
| | | return count |
| | | cancel_index = cancel_data["index"] |
| | | break |
| | | if not canceled: |
| | | count = data["re"] |
| | |
| | | if i <= process_index_old: |
| | | continue |
| | | process_index = i |
| | | left_count = cls.__get_limit_up_buy_no_canceled_count(code, i, total_data, local_today_num_operate_map) |
| | | left_count = cls.__get_limit_up_buy_no_canceled_count(code, i, total_data, |
| | | local_today_num_operate_map, |
| | | tool.trade_time_add_second( |
| | | total_data[buy_exec_index]["val"]["time"], |
| | | constant.S_CANCEL_EXPIRE_TIME)) |
| | | if left_count > 0: |
| | | data = total_data[i] |
| | | val = data["val"] |