Administrator
2024-02-28 121fff615da5cd19236ba9e59156e86bd8fe772e
添加只根据封单撤规则/委托列表输出API修改
7个文件已修改
269 ■■■■ 已修改文件
inited_data.py 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/cancel_buy_strategy.py 108 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_data_manager_new.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_transaction_data_processor.py 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/huaxin/huaxin_trade_server.py 112 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/sell/sell_rule_manager.py 35 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/trade_result_manager.py 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inited_data.py
@@ -98,8 +98,6 @@
        gpcode_manager.PauseBuyCodesManager().clear()
        # 清除L撤数据
        LCancelBigNumComputer().clear()
        # 清除D撤数据
        DCancelBigNumComputer().clear()
        # 清除大单成交数据
        DealOrderNoManager().clear()
        # 最近是否有最大量
l2/cancel_buy_strategy.py
@@ -22,6 +22,7 @@
from l2.l2_transaction_data_manager import HuaXinTransactionDataManager
from log_module import async_log_util
from trade.deal_big_money_manager import DealOrderNoManager
from trade.sell.sell_rule_manager import TradeRuleManager
from utils import tool
from l2.transaction_progress import TradeBuyQueue
from trade import trade_queue_manager, l2_trade_factor, trade_record_log_util
@@ -726,7 +727,6 @@
class DCancelBigNumComputer:
    __db = 0
    __redis_manager = redis_manager.RedisManager(0)
    __cancel_real_order_index_cache = {}
    __instance = None
@@ -740,11 +740,7 @@
    def __load_datas(cls):
        __redis = cls.__get_redis()
        try:
            keys = RedisUtils.keys(__redis, "d_cancel_real_order_index-*")
            for k in keys:
                code = k.split("-")[-1]
                val = RedisUtils.get(__redis, k)
                CodeDataCacheUtil.set_cache(cls.__cancel_real_order_index_cache, code, int(val))
            pass
        finally:
            RedisUtils.realse(__redis)
@@ -752,81 +748,23 @@
    def __get_redis(cls):
        return cls.__redis_manager.getRedis()
    def __set_real_order_index(self, code, index):
        CodeDataCacheUtil.set_cache(self.__cancel_real_order_index_cache, code, index)
        RedisUtils.setex_async(self.__db, f"d_cancel_real_order_index-{code}", tool.get_expire(), f"{index}")
    # 是否有撤买的规则
    def has_auto_cancel_rules(self, code):
        rules = self.get_auto_cancel_rules(code)
        return True if rules else False
    def __del_real_order_index(self, code):
        CodeDataCacheUtil.clear_cache(self.__cancel_real_order_index_cache, code)
        RedisUtils.delete_async(self.__db, f"d_cancel_real_order_index-{code}")
    def get_auto_cancel_rules(self, code):
        rules = TradeRuleManager().list_can_excut_rules_cache([TradeRuleManager.TYPE_BUY_CANCEL], code)
        return rules
    def __get_real_order_index(self, code):
        val = RedisUtils.get(self.__db, f"d_cancel_real_order_index-{code}")
        if val:
            return int(val)
        return None
    def __get_real_order_index_cache(self, code):
        cache_result = CodeDataCacheUtil.get_cache(self.__cancel_real_order_index_cache, code)
        if cache_result[0]:
            return cache_result[1]
        return None
    def clear(self, code=None):
        if code:
            self.__del_real_order_index(code)
        else:
            keys = RedisUtils.keys(self.__get_redis(), "d_cancel_real_order_index-*")
            if keys:
                for k in keys:
                    code = k.replace("d_cancel_real_order_index-", "")
                    self.__del_real_order_index(code)
    # 设置成交位
    def set_trade_progress(self, code, index, buy_exec_index, total_data, m_base_value,
                           limit_up_price):
        # 离下单执行位2分钟内的有效
        sub_time = tool.trade_time_sub(total_data[-1]['val']['time'], total_data[buy_exec_index]['val']['time'])
        if sub_time > constant.D_CANCEL_EXPIRE_TIME or sub_time < constant.D_CANCEL_START_TIME:
            return False, "超过D撤守护时间"
        real_order_index = self.__get_real_order_index_cache(code)
        if not real_order_index:
            return False, "尚未获取到真实下单位置"
        left_num = 0
        for i in range(index + 1, real_order_index):
            data = total_data[i]
            val = data['val']
            if not L2DataUtil.is_limit_up_price_buy(val):
                continue
            if val['num'] * val['price'] < 5900:
                continue
            left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code, i,
                                                                                                     total_data,
                                                                                                     local_today_canceled_buyno_map.get(
                                                                                                         code))
            left_num += val['num'] * left_count
        # 剩下的不足动态M值的1/2
        rate = round(float(limit_up_price) * left_num * 100 / m_base_value, 3)
        l2_log.d_cancel_debug(code,
                              f"成交进度({index})到下单位置({real_order_index})的剩余笔数:{left_num},撤单比例:{rate},m值:{m_base_value}")
        if rate < constant.D_CANCEL_RATE:
            l2_log.cancel_debug(code, "D撤撤单,比例为:{},目标比例{}", rate, constant.D_CANCEL_RATE)
            return True, f"D撤比例为:{rate}"
        return False, ""
    # 设置真实的下单位置
    def set_real_order_index(self, code, index):
        self.__set_real_order_index(code, index)
        l2_log.d_cancel_debug(code, f"下单位置设置:{index}")
    def place_order_success(self, code):
        self.clear(code)
    def cancel_success(self, code):
        self.clear(code)
    def need_cancel(self, code, buy1_volume):
        rules = self.get_auto_cancel_rules(code)
        if rules:
            for r in rules:
                if r.buy1_volume >= buy1_volume:
                    # 量低于
                    return True, r.id_
        return False, None
# ---------------------------------L撤-------------------------------
@@ -1640,7 +1578,8 @@
    def __set_real_order_index(self, code, index, is_default):
        CodeDataCacheUtil.set_cache(self.__real_order_index_cache, code, (index, is_default))
        RedisUtils.setex_async(self.__db, f"f_cancel_real_order_index-{code}", tool.get_expire(), json.dumps((index, is_default)))
        RedisUtils.setex_async(self.__db, f"f_cancel_real_order_index-{code}", tool.get_expire(),
                               json.dumps((index, is_default)))
    def __del_real_order_index(self, code):
        CodeDataCacheUtil.clear_cache(self.__real_order_index_cache, code)
@@ -1728,7 +1667,7 @@
        # 统计未撤订单的数量与金额
        total_datas = local_today_datas.get(code)
        # 是否是下单5分钟内
        if tool.trade_time_sub(tool.get_now_time_str(),total_datas[real_order_index]['val']['time']) > 5*60:
        if tool.trade_time_sub(tool.get_now_time_str(), total_datas[real_order_index]['val']['time']) > 5 * 60:
            return False, "下单超过5分钟"
        total_left_count = 0
@@ -1749,12 +1688,9 @@
                total_left_count += left_count
                total_left_num += val["num"] * left_count
        limit_up_price = gpcode_manager.get_limit_up_price(code)
        if total_left_count < 10 and limit_up_price and total_left_num * float(limit_up_price) < 1000*100:
            return True, f"剩余笔数({total_left_count})/金额({round(total_left_num * float(limit_up_price)*100)})不足,成交进度:{trade_index},真实下单位置:{real_order_index}"
        if total_left_count < 10 and limit_up_price and total_left_num * float(limit_up_price) < 1000 * 100:
            return True, f"剩余笔数({total_left_count})/金额({round(total_left_num * float(limit_up_price) * 100)})不足,成交进度:{trade_index},真实下单位置:{real_order_index}"
        return False, "不满足撤单条件"
# ---------------------------------G撤-------------------------------
l2/l2_data_manager_new.py
@@ -586,7 +586,7 @@
        #     cancel_data, cancel_msg = s_cancel(buy_single_index, buy_exec_index)
        if not cancel_data:
            cancel_data, cancel_msg = h_cancel(order_begin_pos.buy_single_index, order_begin_pos.buy_exec_index)
        if cancel_data:
        if cancel_data and not DCancelBigNumComputer().has_auto_cancel_rules(code):
            l2_log.debug(code, "触发撤单,撤单位置:{} ,撤单原因:{}", cancel_data["index"], cancel_msg)
            # 撤单
l2/l2_transaction_data_processor.py
@@ -4,7 +4,7 @@
from code_attribute import gpcode_manager
from l2 import l2_data_util, l2_data_manager, l2_data_source_util, transaction_progress
from l2.cancel_buy_strategy import FCancelBigNumComputer, LCancelBigNumComputer, LCancelRateManager, \
    GCancelBigNumComputer, SecondCancelBigNumComputer, HourCancelBigNumComputer
    GCancelBigNumComputer, SecondCancelBigNumComputer, HourCancelBigNumComputer, DCancelBigNumComputer
from l2.l2_data_manager_new import L2TradeDataProcessor
from l2.l2_data_util import L2DataUtil, local_today_canceled_buyno_map
from l2.l2_transaction_data_manager import HuaXinTransactionDataManager
@@ -54,7 +54,7 @@
                # 已经下单的需要统计F撤
                try:
                    for d in datas:
                        if FCancelBigNumComputer().need_cancel(d)[0]:
                        if FCancelBigNumComputer().need_cancel(d)[0] and not DCancelBigNumComputer().has_auto_cancel_rules(code):
                            L2TradeDataProcessor.cancel_buy(code, f"F撤撤单:{d}")
                            order_begin_pos = None
                            break
@@ -63,7 +63,7 @@
                try:
                    # 下单2s后才开始生效
                    cresult = LCancelBigNumComputer().add_transaction_datas(code, datas)
                    if cresult[0]:
                    if cresult[0] and not DCancelBigNumComputer().has_auto_cancel_rules(code):
                        L2TradeDataProcessor.cancel_buy(code, f"L后成交太快撤单:{cresult[1]}")
                        order_begin_pos = None
                except Exception as e:
@@ -110,7 +110,7 @@
                    HourCancelBigNumComputer().set_transaction_index(code, order_begin_pos.buy_single_index,
                                                                     buy_progress_index)
                    cresult = FCancelBigNumComputer().need_cancel_for_deal_fast(code,buy_progress_index)
                    if cresult[0]:
                    if cresult[0] and not DCancelBigNumComputer().has_auto_cancel_rules(code):
                        L2TradeDataProcessor.cancel_buy(code, f"下单5分钟内排单不足:{cresult[1]}")
                    # ---------------------------------判断板块是否跟上来了-------------------------------
                    try:
trade/huaxin/huaxin_trade_server.py
@@ -31,7 +31,7 @@
from l2 import l2_data_manager_new, l2_log, code_price_manager, l2_data_util, l2_data_manager, transaction_progress, \
    l2_data_source_util, cancel_buy_strategy
from l2.cancel_buy_strategy import LCancelBigNumComputer, GCancelBigNumComputer, SecondCancelBigNumComputer, \
    LCancelRateManager
    LCancelRateManager, DCancelBigNumComputer
from l2.code_price_manager import Buy1PriceManager
from l2.huaxin import huaxin_target_codes_manager
from l2.huaxin.huaxin_target_codes_manager import HuaXinL1TargetCodesManager
@@ -60,7 +60,7 @@
from trade.huaxin.huaxin_trade_record_manager import PositionManager, DealRecordManager, DelegateRecordManager
from trade.l2_trade_factor import L2PlaceOrderParamsManager
from trade.sell import sell_manager
from trade.sell.sell_rule_manager import SellRuleManager, SellRule
from trade.sell.sell_rule_manager import TradeRuleManager, SellRule
from trade.trade_manager import TradeTargetCodeModeManager, MarketSituationManager, AutoCancelSellModeManager
from utils import socket_util, data_export_util, middle_api_protocol, tool, huaxin_util, output_util, sell_util
@@ -293,7 +293,7 @@
    @classmethod
    def __sell(cls, datas):
        rules = SellRuleManager().list_can_excut_rules_cache()
        rules = TradeRuleManager().list_can_excut_rules_cache(types=[TradeRuleManager.TYPE_SELL])
        excuted_rule_ids = set()
        if rules:
            for d in datas:
@@ -323,13 +323,13 @@
                                    continue
                                # 请求卖出锁
                                SellRuleManager().require_sell_lock(r.id_)
                                TradeRuleManager().require_sell_lock(r.id_)
                                try:
                                    if r.id_ in excuted_rule_ids:
                                        continue
                                    excuted_rule_ids.add(r.id_)
                                    # 获取最新的执行状况
                                    r = SellRuleManager().get_by_id(r.id_)
                                    r = TradeRuleManager().get_by_id(r.id_)
                                    if r.excuted:
                                        continue
                                    # 提交卖
@@ -338,11 +338,11 @@
                                    huaxin_sell_util.start_sell(code, r.sell_volume, r.sell_price_type, limit_up_price,
                                                                limit_down_price,
                                                                buy1_price)
                                    SellRuleManager().excute_sell(r.id_)
                                    TradeRuleManager().excuted(r.id_)
                                except Exception as e:
                                    logger_debug.exception(e)
                                finally:
                                    SellRuleManager().release_sell_lock(r.id_)
                                    TradeRuleManager().release_sell_lock(r.id_)
    # 保存现价
    @classmethod
@@ -408,6 +408,18 @@
        buy_1_price, buy_1_volume = data["buy"][0]
        sell_1_price, sell_1_volume = data["sell"][0]
        limit_up_price = gpcode_manager.get_limit_up_price(code)
        # -----------------------判断是是否有自动撤单规则-----------------------
        try:
            if DCancelBigNumComputer().has_auto_cancel_rules(code):
                need_cancel, rule_id = DCancelBigNumComputer().need_cancel(code, buy_1_volume)
                if need_cancel:
                    try:
                        l2_data_manager_new.L2TradeDataProcessor.cancel_buy(code, f"盯封单撤:{time_str}-{buy_1_volume}")
                    finally:
                        TradeRuleManager().excuted(rule_id)
        except Exception as e:
            logger_debug.exception(e)
        if limit_up_price is not None:
            average_rate = None
@@ -674,19 +686,28 @@
                            raise e
                else:
                    if not price:
                        # 没有传入价格,以最新价买入
                        current_price = TradeServerProcessor.get_l1_current_price(code)
                        if not current_price:
                            raise Exception("尚未获取到现价")
                        # 获取买1金额
                        price = round(float(current_price), 2)
                        buy1_info = TradeServerProcessor.current_buy1_dict.get(code)
                        if buy1_info and buy1_info[0] * buy1_info[1] > 50 * 10000:
                            # 如果买1在50w以上就加一档
                            price += 0.01
                        limit_up_price = gpcode_manager.get_limit_up_price(code)
                        if limit_up_price and price > float(limit_up_price):
                            price = round(float(limit_up_price), 2)
                        if tool.trade_time_sub(tool.get_now_time_str(), "09:30:00") < 0:
                            # 开盘之前
                            limit_down_price = gpcode_manager.get_limit_down_price(code)
                            if not limit_down_price:
                                raise Exception("尚未获取跌停价")
                            # 比跌停价高1分
                            price = round(float(limit_down_price) + 0.01, 2)
                        else:
                            # 开盘之后
                            # 没有传入价格,以最新价买入
                            current_price = TradeServerProcessor.get_l1_current_price(code)
                            if not current_price:
                                raise Exception("尚未获取到现价")
                            # 获取买1金额
                            price = round(float(current_price), 2)
                            buy1_info = TradeServerProcessor.current_buy1_dict.get(code)
                            if buy1_info and buy1_info[0] * buy1_info[1] > 50 * 10000:
                                # 如果买1在50w以上就加一档
                                price += 0.01
                            limit_up_price = gpcode_manager.get_limit_up_price(code)
                            if limit_up_price and price > float(limit_up_price):
                                price = round(float(limit_up_price), 2)
                        order_ref = huaxin_util.create_order_ref()
                        result = huaxin_trade_api.order(direction, code, volume, price, price_type=price_type,
                                                        sinfo=sinfo, order_ref=order_ref,
@@ -772,15 +793,16 @@
            if operate == outside_api_command_manager.OPERRATE_ADD:
                data = data["data"]
                code = data["code"]
                type = data["type"]
                buy1_price = data.get("buy1_price")
                if not buy1_price:
                    buy1_price = gpcode_manager.get_limit_up_price(code)
                    if not buy1_price:
                        raise Exception("尚未获取到涨停价")
                rule = SellRule(code=data["code"], buy1_volume=data["buy1_volume"], buy1_price=buy1_price,
                                sell_volume=data["sell_volume"], sell_price_type=data["sell_price_type"],
                                end_time=data["end_time"])
                SellRuleManager().add_rule(rule)
                                sell_volume=data.get("sell_volume"), sell_price_type=data.get("sell_price_type"),
                                end_time=data["end_time"], type=type)
                TradeRuleManager().add_rule(rule)
                self.send_response({"code": 0, "data": {}}, client_id, request_id)
            elif operate == outside_api_command_manager.OPERRATE_SET:
                data = data["data"]
@@ -792,16 +814,16 @@
                        raise Exception("尚未获取到涨停价")
                rule = SellRule(id_=data["id"], code=data["code"], buy1_volume=data["buy1_volume"],
                                buy1_price=buy1_price,
                                sell_volume=data["sell_volume"], sell_price_type=data["sell_price_type"],
                                sell_volume=data.get("sell_volume"), sell_price_type=data.get("sell_price_type"),
                                end_time=data["end_time"])
                SellRuleManager().update_rule(rule)
                TradeRuleManager().update_rule(rule)
                self.send_response({"code": 0, "data": {}}, client_id, request_id)
            elif operate == outside_api_command_manager.OPERRATE_DELETE:
                data = data["data"]
                SellRuleManager().del_rule(data["id"])
                TradeRuleManager().del_rule(data["id"])
                self.send_response({"code": 0, "data": {}}, client_id, request_id)
            elif operate == outside_api_command_manager.OPERRATE_GET:
                rules = SellRuleManager().list_rules()
                rules = TradeRuleManager().list_rules()
                fresults = []
                for rule in rules:
                    fresults.append(rule.to_dict())
@@ -1201,9 +1223,9 @@
                desc_list.append("【暂不买】")
            # 获取持仓
            positions = PositionManager.latest_positions
            sell_rules_count = len(SellRuleManager().list_can_excut_rules_cache())
            trade_rules_count = len(TradeRuleManager().list_can_excut_rules_cache())
            fdata = {"code": code, "total": 0, "available": 0, "sell_orders": [], "sell_rules_count": sell_rules_count,
            fdata = {"code": code, "total": 0, "available": 0, "sell_orders": [], "sell_rules_count": trade_rules_count,
                     "cost_price": 0,
                     "code_info": (code, code_name), "desc": "".join(desc_list)}
            if positions:
@@ -1412,8 +1434,10 @@
                                    total_big_num -= canceled_data["val"]["num"]
                                total_big_num += val["num"]
                            not_deal_total_big_num = 0
                            not_deal_total_big_count = 0
                            not_deal_total_big_num_pre = 0
                            not_deal_total_big_count_pre = 0
                            not_deal_total_big_num_after = 0
                            not_deal_total_big_count_after = 0
                            for i in range(trade_index, total_datas[-1]["index"] + 1):
                                val = total_datas[i]["val"]
                                if not L2DataUtil.is_limit_up_price_buy(val):
@@ -1429,10 +1453,21 @@
                                    l2_data_util.local_today_canceled_buyno_map.get(
                                        code))
                                if not canceled_data:
                                    not_deal_total_big_count += 1
                                    if i < place_order_index:
                                        not_deal_total_big_count_pre += 1
                                    else:
                                        not_deal_total_big_count_after += 1
                                else:
                                    not_deal_total_big_num -= canceled_data["val"]["num"]
                                not_deal_total_big_num += val["num"]
                                    if i < place_order_index:
                                        not_deal_total_big_num_pre -= canceled_data["val"]["num"]
                                    else:
                                        not_deal_total_big_num_after -= canceled_data["val"]["num"]
                                if i < place_order_index:
                                    not_deal_total_big_num_pre += val["num"]
                                else:
                                    not_deal_total_big_num_after += val["num"]
                            real_place_order_after_count = 0
                            real_place_order_after_num = 0
@@ -1470,9 +1505,10 @@
                                     "big_num_count": total_big_count,
                                     "big_num_money": output_util.money_desc(
                                         total_big_num * float(limit_up_price) * 100),
                                     "not_deal_big_num_count": not_deal_total_big_count,
                                     "not_deal_big_num_money": output_util.money_desc(
                                         not_deal_total_big_num * float(limit_up_price) * 100),
                                     "not_deal_big_num_count": (not_deal_total_big_count_pre, not_deal_total_big_count_after),
                                     "not_deal_big_num_money": (output_util.money_desc(
                                         not_deal_total_big_num_pre * float(limit_up_price) * 100),output_util.money_desc(
                                         not_deal_total_big_num_after * float(limit_up_price) * 100)),
                                     "left_count": total_left_count,
                                     "volume_rate": volume_rate,
                                     "left_money": output_util.money_desc(total_left_num * float(limit_up_price) * 100),
@@ -1482,7 +1518,7 @@
                        except Exception as e:
                            logger_debug.exception(e)
                result = {"code": 0, "data": {"account_available_money":account_available_money ,"delegates":fdatas}}
                result = {"code": 0, "data": {"account_available_money": account_available_money, "delegates": fdatas}}
                self.send_response(result, client_id, request_id)
            elif ctype == "set_real_place_order_index":
                # 设置真实下单位置
trade/sell/sell_rule_manager.py
@@ -12,7 +12,7 @@
class SellRule:
    def __init__(self, id_=None, code=None, buy1_volume=None, buy1_price=None, sell_volume=None, sell_price_type=None,
                 day=None, create_time=None, excuted=0,
                 end_time=None):
                 end_time=None, type=None, ):
        self.day = day
        self.create_time = create_time
        self.sell_volume = sell_volume
@@ -23,6 +23,8 @@
        self.id_ = id_
        self.excuted = 0
        self.end_time = end_time
        # 0-买入 1-买撤 2-卖 3-卖撤
        self.type = type
    def to_json_str(self):
        return json.dumps(vars(self))
@@ -40,7 +42,16 @@
        return self.id_
class SellRuleManager:
class TradeRuleManager:
    # 买入
    TYPE_BUY = 0
    # 卖撤
    TYPE_BUY_CANCEL = 1
    # 卖
    TYPE_SELL = 2
    # 卖撤
    TYPE_SELL_CANCEL = 3
    __instance = None
    __sell_rules_dict_cache = {}
    # 卖出锁
@@ -49,7 +60,7 @@
    def __new__(cls, *args, **kwargs):
        if not cls.__instance:
            cls.__instance = super(SellRuleManager, cls).__new__(cls, *args, **kwargs)
            cls.__instance = super(TradeRuleManager, cls).__new__(cls, *args, **kwargs)
            cls.__instance.__load_datas()
        return cls.__instance
@@ -75,6 +86,7 @@
                rule.create_time = r[7]
                rule.excuted = r[8]
                rule.end_time = r[9]
                rule.type = r[10]
                fresults.append(rule)
        return fresults
@@ -86,9 +98,9 @@
        if not rule.day:
            rule.day = tool.get_now_date_str()
        mysql_data.Mysqldb().execute(
            "insert into sell_rules(_id,code,buy1_volume,buy1_price,sell_volume,sell_price_type,day,create_time,excuted,end_time) values ('%s','%s','%s','%s','%s','%s','%s',now() ,'%s','%s') " % (
            "insert into sell_rules(_id,code,buy1_volume,buy1_price,sell_volume,sell_price_type,day,create_time,excuted,end_time,type) values ('%s','%s','%s','%s','%s','%s','%s',now() ,'%s','%s','%s') " % (
                rule.id_, rule.code, rule.buy1_volume, rule.buy1_price, rule.sell_volume, rule.sell_price_type,
                rule.day, rule.excuted, rule.end_time))
                rule.day, rule.excuted, rule.end_time, rule.type))
        self.__sell_rules_dict_cache[_id] = rule
    def update_rule(self, rule: SellRule):
@@ -116,19 +128,22 @@
        return [self.__sell_rules_dict_cache[k] for k in self.__sell_rules_dict_cache]
    # 获取可以执行的规则
    def list_can_excut_rules_cache(self, code=None):
    def list_can_excut_rules_cache(self, types=None, code=None):
        if not types:
            types = [self.TYPE_BUY, self.TYPE_BUY_CANCEL, self.TYPE_SELL, self.TYPE_SELL_CANCEL]
        rules = []
        for k in self.__sell_rules_dict_cache:
            rule = self.__sell_rules_dict_cache[k]
            if code and code != rule.code:
                continue
            if rule.excuted == 0 and rule.day == tool.get_now_date_str() and tool.trade_time_sub(rule.end_time,
                                                                                                 tool.get_now_time_str()) > 0:
            if rule.excuted == 0 and rule.type in types and rule.day == tool.get_now_date_str() and tool.trade_time_sub(
                    rule.end_time,
                    tool.get_now_time_str()) > 0:
                rules.append(rule)
        return rules
    # 执行卖
    def excute_sell(self, _id):
    def excuted(self, _id):
        if _id in self.__sell_rules_dict_cache:
            self.__sell_rules_dict_cache[_id].excuted = 1
        self.__mysql_excute_thread_pool.submit(mysql_data.Mysqldb().execute,
@@ -151,4 +166,4 @@
if __name__ == "__main__":
    SellRuleManager().list_rules("2023-12-01")
    TradeRuleManager().list_rules("2023-12-01")
trade/trade_result_manager.py
@@ -28,7 +28,6 @@
def virtual_cancel_success(code, buy_single_index, buy_exec_index, total_datas):
    l2_data_manager.TradePointManager().delete_buy_point(code)
    SecondCancelBigNumComputer().cancel_success(code)
    DCancelBigNumComputer().cancel_success(code)
    LCancelBigNumComputer().cancel_success(code)
    GCancelBigNumComputer().cancel_success(code)
    # dask.compute(f1, f2, f5, f6, f7, f8)
@@ -100,7 +99,6 @@
    # 取消买入标识
    l2_data_manager.TradePointManager().delete_buy_point(code)
    SecondCancelBigNumComputer().cancel_success(code)
    DCancelBigNumComputer().cancel_success(code)
    LCancelBigNumComputer().cancel_success(code)
    FCancelBigNumComputer().cancel_success(code)
    GCancelBigNumComputer().cancel_success(code)