| | |
| | | |
| | | def __set_watch_indexes(self, code, indexes): |
| | | CodeDataCacheUtil.set_cache(self.__watch_indexes_cache, code, indexes) |
| | | RedisUtils.setex_async(self.__db, f"f_cancel_watch_index-{code}", tool.get_expire(), f"{json.dumps(list(indexes))}") |
| | | RedisUtils.setex_async(self.__db, f"f_cancel_watch_index-{code}", tool.get_expire(), |
| | | f"{json.dumps(list(indexes))}") |
| | | |
| | | def __get_watch_indexes(self, code): |
| | | watch_indexes = self.__watch_indexes_cache.get(code) |
| | |
| | | if len(watch_indexes) >= MAX_COUNT: |
| | | break |
| | | # 保存数据 |
| | | l2_log.f_cancel_debug(code,f"监听范围:{watch_indexes} 计算起始点:{c_start_index}") |
| | | self.__set_watch_indexes(code, watch_indexes) |
| | | |
| | | def set_trade_progress(self, code, index): |
| | |
| | | self.__set_real_order_index(code, index) |
| | | l2_log.f_cancel_debug(code, f"下单位置设置:{index}") |
| | | trade_index = self.__last_trade_progress_dict.get(code) |
| | | l2_log.f_cancel_debug(code, f"计算范围:{trade_index}-{index}") |
| | | if trade_index: |
| | | total_datas = local_today_datas.get(code) |
| | | # 真实下单位置 |
| | | total_count = 0 |
| | | for i in range(trade_index+1,index): |
| | | for i in range(trade_index + 1, index): |
| | | data = total_datas[i] |
| | | val = data["val"] |
| | | if not L2DataUtil.is_limit_up_price_buy(val): |
| | |
| | | total_datas, |
| | | local_today_canceled_buyno_map.get( |
| | | code)) |
| | | if left_count>0: |
| | | if left_count > 0: |
| | | total_count += left_count |
| | | if total_count >= 2: |
| | | return False |
| | | return True |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | def place_order_success(self, code): |
| | | self.clear(code) |
| | |
| | | cls.unreal_buy_dict.pop(code) |
| | | |
| | | @classmethod |
| | | def set_real_place_order_index(cls, code, index, buy_single_index): |
| | | trade_record_log_util.add_real_place_order_position_log(code, index, buy_single_index) |
| | | need_cancel = FastCancelBigNumComputer().set_real_order_index(code, index) |
| | | if need_cancel: |
| | | cls.cancel_buy(code, msg="F撤不够2笔触发撤单") |
| | | else: |
| | | cancel_buy_strategy.set_real_place_position(code, index, buy_single_index) |
| | | def set_real_place_order_index(cls, code, index, order_begin_pos:OrderBeginPosInfo): |
| | | trade_record_log_util.add_real_place_order_position_log(code, index, order_begin_pos.buy_single_index) |
| | | if order_begin_pos.mode == OrderBeginPosInfo.MODE_FAST: |
| | | need_cancel = FastCancelBigNumComputer().set_real_order_index(code, index) |
| | | if need_cancel: |
| | | cls.cancel_buy(code, msg="F撤不够2笔触发撤单") |
| | | return |
| | | cancel_buy_strategy.set_real_place_position(code, index, order_begin_pos.buy_single_index) |
| | | |
| | | # 处理华鑫L2数据 |
| | | @classmethod |
| | |
| | | if place_order_index: |
| | | order_begin_pos = cls.__get_order_begin_pos( |
| | | code) |
| | | cls.set_real_place_order_index(code, place_order_index, order_begin_pos.buy_single_index) |
| | | cls.set_real_place_order_index(code, place_order_index, order_begin_pos) |
| | | async_log_util.info(logger_l2_process, "code:{} 获取到下单真实位置:{}", code, place_order_index) |
| | | except: |
| | | async_log_util.error(logger_l2_error, f"{code} 处理真实下单位置出错") |
| | |
| | | return False, -1, "股价大于10块" |
| | | total_datas = local_today_datas[code] |
| | | start_time_str = total_datas[start_index]["val"]["time"] |
| | | if tool.trade_time_sub(start_time_str, "10:00:00") > 0: |
| | | if tool.trade_time_sub(start_time_str, "11:00:00") > 0: |
| | | return False, -1, "超过规定时间" |
| | | refer_sell_data = cls.__L2MarketSellManager.get_refer_sell_data(code, start_time_str) |
| | | if refer_sell_data is None: |
| | |
| | | from code_attribute import gpcode_manager |
| | | from l2 import l2_data_util, l2_data_manager, transaction_progress |
| | | from l2.cancel_buy_strategy import LCancelRateManager, DCancelBigNumComputer, LCancelBigNumComputer, \ |
| | | SecondCancelBigNumComputer, HourCancelBigNumComputer |
| | | SecondCancelBigNumComputer, HourCancelBigNumComputer, FastCancelBigNumComputer |
| | | from l2.l2_data_manager_new import L2TradeDataProcessor |
| | | from l2.l2_data_util import L2DataUtil |
| | | from log_module import async_log_util |
| | |
| | | # L2TradeDataProcessor.cancel_buy(code, f"D撤:{msg}", source="d_cancel") |
| | | |
| | | LCancelBigNumComputer().set_trade_progress(code, buy_progress_index, total_datas) |
| | | FastCancelBigNumComputer().set_trade_progress(code, buy_progress_index) |
| | | SecondCancelBigNumComputer().set_transaction_index( |
| | | code, |
| | | buy_progress_index) |
| | |
| | | except Exception as e: |
| | | pass |
| | | |
| | | |
| | | def test_trade(self): |
| | | threading.Thread(target=async_log_util.run_sync, daemon=True).start() |
| | | code = "600203" |
| | |
| | | l2_market_datas = l2_market_datas.get(code) |
| | | if l2_market_datas: |
| | | l2_market_datas.reverse() |
| | | |
| | | |
| | | pos_list = log_export.get_l2_process_position(code) |
| | | # pos_list.insert(108,(375,448)) |
| | |
| | | |
| | | print("----------------处理位置", indexs) |
| | | for l2_m in l2_market_datas: |
| | | if l2_m["dataTimeStamp"] < int(total_datas[indexs[0]]["val"]["time"].replace(":","")): |
| | | if l2_m["dataTimeStamp"] < int(total_datas[indexs[0]]["val"]["time"].replace(":", "")): |
| | | time_str = f"{l2_m['dataTimeStamp']}" |
| | | if time_str.startswith("9"): |
| | | time_str = "0" + time_str |
| | | time_str = time_str[:6] |
| | | time_str = f"{time_str[0:2]}:{time_str[2:4]}:{time_str[4:6]}" |
| | | L2MarketSellManager().set_current_total_sell_data(code,time_str,l2_m["totalAskVolume"]*l2_m["avgAskPrice"]) |
| | | L2MarketSellManager().set_current_total_sell_data(code, time_str, |
| | | l2_m["totalAskVolume"] * l2_m["avgAskPrice"]) |
| | | break |
| | | |
| | | l2.l2_data_manager_new.L2TradeDataProcessor.process_add_datas(code, total_datas[indexs[0]:indexs[1] + 1], 0, |
| | |
| | | GCancelBigNumComputer, SecondCancelBigNumComputer, LCancelRateManager, LatestCancelIndexManager |
| | | from l2.huaxin import huaxin_target_codes_manager |
| | | from l2.huaxin.huaxin_target_codes_manager import HuaXinL1TargetCodesManager |
| | | from l2.l2_data_manager_new import L2TradeDataProcessor |
| | | from l2.l2_data_util import L2DataUtil |
| | | from l2.l2_sell_manager import L2MarketSellManager |
| | | from l2.l2_transaction_data_manager import HuaXinTransactionDatasProcessor |