Administrator
4 天以前 4f16bf0f1686e2a15fcbc43e17c727c81550609f
人为设置的累计大单的策略修改
1个文件已修改
36 ■■■■ 已修改文件
trade/buy_radical/radical_buy_data_manager.py 36 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/buy_radical/radical_buy_data_manager.py
@@ -73,9 +73,10 @@
    def __get_redis(self):
        return self.__redis_manager.getRedis()
    def set_big_order_threshold(self, code, threshold_money):
    def set_big_order_threshold(self, code, threshold_money, big_order_threshold_callback):
        """
        设置大单的阈值
        @param big_order_threshold_callback: 大单设置回调函数
        @param code:
        @param threshold_money:
        @return:
@@ -89,6 +90,7 @@
        self.__big_order_threshold[code] = threshold_money
        redis_manager.RedisUtils.setex_async(self.__db, f"radical_big_order_threshold-{code}", tool.get_expire(),
                                             f"{threshold_money}")
        big_order_threshold_callback(code, threshold_money)
    def set_big_sell_order_threshold(self, code, threshold_money):
        """
@@ -120,9 +122,11 @@
        threshold_money = max((max_money // 2 + average_money) // 2, average_money)
        return threshold_money
    def set_big_deal_order_list(self, code, buy_money_list, sell_money_list, limit_up_price):
    def set_big_deal_order_list(self, code, buy_money_list, sell_money_list, limit_up_price,
                                big_order_threshold_callback):
        """
        设置大单成交数据
        @param big_order_threshold_callback: 均大单设置回调函数
        @param code:
        @param buy_money_list:[(金额,价格,订单号)]
        @param sell_money_list:[(金额,价格,订单号)]
@@ -160,7 +164,7 @@
            total_deal_buy_money_info_list.append(info)
        if limit_up_price_money_list:
            threshold_money = self.compute_re_limit_up_big_money_threshold(limit_up_price_money_list)
            self.set_big_order_threshold(code, threshold_money)
            self.set_big_order_threshold(code, threshold_money, big_order_threshold_callback)
        self.__already_total_deal_big_order_money[code] = (total_deal_buy_money, pre_limit_up_price_money_list)
        async_log_util.info(logger_l2_radical_buy_data,
                            f"开板时间:{opened_time} 之前的大买单:{code}-{total_deal_buy_money}-{total_deal_buy_money_info_list}")
@@ -2214,16 +2218,40 @@
    @param code_:
    @return:
    """
    def big_order_threshold_callback(code, money):
        """
        设置均大单的回调
        @param money:
        @return:
        """
        async_log_util.info(logger_l2_radical_buy_data, f"均大单回调函数:{code}-{money},原均大单-{THRESHOLD_MONEY}")
        if money - THRESHOLD_MONEY > 10:
            # 新的阈大于老的阈值
            old_setting_money = TotalDealBigOrderThresholdMoneyManager().get_money_cache(code)
            if old_setting_money:
                new_setting_money = int(old_setting_money * money / THRESHOLD_MONEY)
                async_log_util.info(logger_l2_radical_buy_data,
                                    f"累计大单回调人为设置({code}): {old_setting_money}->{new_setting_money}")
                TotalDealBigOrderThresholdMoneyManager().set_money(code, new_setting_money,
                                                                   trade_manager.CodesTradeStateManager().get_trade_state_cache(
                                                                       code))
    # 只有涨停过的代码才需要拉大单
    if code_ not in LimitUpDataConstant.get_history_limit_up_codes():
        return
    result = request_deal_big_orders(code_)
    THRESHOLD_MONEY = 0
    if result:
        try:
            buy_datas, sell_datas = result[0], result[1]
            # 获取原始均大单
            THRESHOLD_MONEY, is_temp_threshold_money = BeforeSubDealBigOrderManager().get_big_order_threshold_info(
                code_)
            BeforeSubDealBigOrderManager().set_big_deal_order_list(code_, buy_datas, sell_datas,
                                                                   gpcode_manager.get_limit_up_price_as_num(code_))
                                                                   gpcode_manager.get_limit_up_price_as_num(code_),
                                                                   big_order_threshold_callback)
        except Exception as e:
            logger_debug.exception(e)