| | |
| | | |
| | | from third_data.history_k_data_util import HistoryKDatasUtils |
| | | from trade import l2_trade_util, trade_manager |
| | | from l2.cancel_buy_strategy import L2LimitUpSellStatisticUtil, LCancelBigNumComputer |
| | | from l2.cancel_buy_strategy import L2LimitUpSellStatisticUtil, LCancelBigNumComputer, DCancelBigNumComputer |
| | | from log_module.log import logger_juejin_tick, logger_system |
| | | from trade.trade_data_manager import CodeActualPriceProcessor |
| | | from trade.trade_queue_manager import JueJinBuy1VolumnManager |
| | |
| | | trade_manager.ForbiddenBuyCodeByScoreManager.clear() |
| | | # 清空暂停交易代码 |
| | | gpcode_manager.PauseBuyCodesManager.clear() |
| | | |
| | | # 清除L撤数据 |
| | | LCancelBigNumComputer.clear() |
| | | # 清除D撤数据 |
| | | DCancelBigNumComputer.clear() |
| | | |
| | | |
| | | # 每日初始化 |
| | |
| | | latest_progress_index = -1 |
| | | # 监听的数据 |
| | | watch_indexs_dict = {} |
| | | total_nums = 0 |
| | | if start_index >= 1956: |
| | | print("进入测试") |
| | | # 初始化为1防止分母为0 |
| | | total_nums = 1 |
| | | if origin_progress_index is not None: |
| | | # 获取成交位置到执行位置的监控数据 |
| | | watch_indexs = cls.__get_watch_index_set(code)[0] |
| | |
| | | is_first_code): |
| | | time_space = tool.trade_time_sub(total_data[start_index]["val"]["time"], |
| | | total_data[buy_exec_index]["val"]["time"]) |
| | | # 守护30s以外的数据 |
| | | if time_space <= constant.S_CANCEL_EXPIRE_TIME: |
| | | # 守护S撤以外的数据 |
| | | if time_space <= constant.S_CANCEL_EXPIRE_TIME or int(tool.get_now_time_str().replace(":", "")) > int("145000"): |
| | | return False, None |
| | | watch_indexes = cls.__get_watch_indexes(code) |
| | | if not watch_indexes: |
| | |
| | | from l2 import safe_count_manager, l2_data_manager, l2_data_log, l2_log, l2_data_source_util, code_price_manager, \ |
| | | transaction_progress |
| | | from l2.cancel_buy_strategy import SecondCancelBigNumComputer, HourCancelBigNumComputer, L2LimitUpMoneyStatisticUtil, \ |
| | | L2LimitUpSellStatisticUtil, DCancelBigNumComputer |
| | | L2LimitUpSellStatisticUtil, DCancelBigNumComputer, LCancelBigNumComputer |
| | | from l2.l2_data_manager import L2DataException, TradePointManager |
| | | from l2.l2_data_util import local_today_datas, L2DataUtil, local_today_num_operate_map, local_today_buyno_map, \ |
| | | local_latest_datas |
| | |
| | | l2_data_log.l2_time(code, round(t.time() * 1000) - _start_time, "已下单-H撤大单计算") |
| | | return None, "" |
| | | |
| | | # L撤 |
| | | @dask.delayed |
| | | def l_cancel(): |
| | | _start_time = round(t.time() * 1000) |
| | | try: |
| | | b_need_cancel, b_cancel_data = LCancelBigNumComputer.need_cancel(code, |
| | | buy_exec_index, start_index, |
| | | end_index, total_data, |
| | | local_today_num_operate_map.get( |
| | | code), is_first_code) |
| | | if b_need_cancel and b_cancel_data: |
| | | return b_cancel_data, "L撤销比例触发阈值" |
| | | except Exception as e: |
| | | logging.exception(e) |
| | | finally: |
| | | l2_data_log.l2_time(code, round(t.time() * 1000) - _start_time, "已下单-L撤大单计算") |
| | | return None, "" |
| | | |
| | | # 板上卖撤 |
| | | @dask.delayed |
| | | def sell_cancel(): |
| | |
| | | f4 = h_cancel() |
| | | f5 = buy_1_cancel() |
| | | f6 = sell_cancel() |
| | | dask_result = is_need_cancel(f1, f2, f3, f4, f5, f6) |
| | | f7 = l_cancel() |
| | | dask_result = is_need_cancel(f1, f2, f3, f4, f5, f6, f7) |
| | | if is_first_code: |
| | | dask_result = is_need_cancel(f3, f4) |
| | | dask_result = is_need_cancel(f3, f4, f7) |
| | | |
| | | cancel_data, cancel_msg = dask_result.compute() |
| | | |
| | |
| | | |
| | | # @unittest.skip("跳过此单元测试") |
| | | def test_trade(self): |
| | | code = "002387" |
| | | code = "002213" |
| | | clear_trade_data(code) |
| | | l2.l2_data_util.load_l2_data(code) |
| | | total_datas = deepcopy(l2.l2_data_util.local_today_datas[code]) |
| | |
| | | from l2 import l2_data_manager_new, l2_log, code_price_manager, l2_data_util, l2_data_manager, transaction_progress |
| | | from l2.cancel_buy_strategy import HourCancelBigNumComputer, LCancelBigNumComputer, DCancelBigNumComputer |
| | | from l2.huaxin import huaxin_target_codes_manager |
| | | from l2.l2_data_manager_new import L2TradeDataProcessor |
| | | from log_module.log import hx_logger_l2_upload, hx_logger_contact_debug, hx_logger_trade_callback, \ |
| | | hx_logger_l2_orderdetail, hx_logger_l2_transaction, hx_logger_l2_market_data, logger_l2_trade_buy_queue |
| | | from third_data import block_info |
| | |
| | | buy_progress_index) |
| | | buy_time = total_datas[buy_progress_index]["val"][ |
| | | "time"] |
| | | HourCancelBigNumComputer.set_trade_progress(code, buy_time, buy_exec_index, |
| | | buy_progress_index, total_datas, |
| | | num_operate_map) |
| | | limit_up_price = gpcode_manager.get_limit_up_price(code) |
| | | if buy_exec_index: |
| | | need_cancel, msg = DCancelBigNumComputer.set_trade_progress(code, |
| | | buy_progress_index, |
| | | buy_exec_index, |
| | | total_datas, |
| | | num_operate_map, |
| | | num * 100 * float( |
| | | limit_up_price), |
| | | limit_up_price) |
| | | if need_cancel: |
| | | L2TradeDataProcessor.cancel_buy(code, f"D撤:{msg}", source="d_cancel") |
| | | |
| | | f1 = dask.delayed(HourCancelBigNumComputer.set_trade_progress)(code, buy_time, |
| | | buy_exec_index, |
| | | buy_progress_index, |
| | |
| | | buy_progress_index, |
| | | total_datas, |
| | | num_operate_map) |
| | | f4 = dask.delayed(DCancelBigNumComputer.set_trade_progress)(code, |
| | | buy_progress_index, |
| | | buy_exec_index, |
| | | total_datas, |
| | | num_operate_map, |
| | | 1000 * 10000, |
| | | gpcode_manager.get_limit_up_price( |
| | | code)) |
| | | dask.compute(f1, f2, f3, f4) |
| | | dask.compute(f1, f2, f3) |
| | | except Exception as e: |
| | | hx_logger_l2_transaction.exception(e) |
| | | |