Administrator
2 天以前 556942d1132123ef608c174d9bca91aa818f6ccb
bug修复/接口修改/续买bug修改
5个文件已修改
102 ■■■■ 已修改文件
cancel_strategy/s_l_h_cancel_strategy.py 61 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
code_attribute/today_max_price_manager.py 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
servers/data_server.py 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
servers/huaxin_trade_server.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/trade_manager.py 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cancel_strategy/s_l_h_cancel_strategy.py
@@ -615,7 +615,7 @@
                                deal_big_order_info = radical_buy_data_manager.get_total_deal_big_order_info(code,
                                                                                                             gpcode_manager.get_limit_up_price_as_num(
                                                                                                                 code))
                                if deal_big_order_info and deal_big_order_info[5]>5000e4:
                                if deal_big_order_info and deal_big_order_info[5] > 5000e4:
                                    temp_rate = round(deal_big_order_info[1] / deal_big_order_info[5], 2)
                                    threshold_rate = min(max(temp_rate, 0.3), 0.9)
                        except:
@@ -711,10 +711,32 @@
    def __init__(self):
        # L后撤单
        self.l_down = {}
        self.__db = 3
        self.__redis_manager = redis_manager.RedisManager(self.__db)
        self.__load_data()
    def __load_data(self):
        keys = RedisUtils.keys(self.__get_redis(), "l_down_cancel_rate_human-{}")
        if keys:
            for k in keys:
                code = k.split("-")[1]
                val = RedisUtils.get(self.__get_redis(), k)
                if val:
                    self.l_down[code] = round(float(val), 2)
    def __get_redis(self):
        return self.__redis_manager.getRedis()
    def set_l_down(self, code, rate):
        """
        设置L后撤比例
        @param code:
        @param rate:
        @return:
        """
        async_log_util.info(logger_l2_l_cancel, f"人为修改L后撤单比例:{code}-{rate}")
        self.l_down[code] = rate
        RedisUtils.setex_async(self.__db, f"l_down_cancel_rate_human-{code}", tool.get_expire(), rate)
    def get_l_down(self, code):
        return self.l_down.get(code)
@@ -722,6 +744,7 @@
    def remove_l_down(self, code):
        if code in self.l_down:
            self.l_down.pop(code)
            RedisUtils.delete_async(self.__db, f"l_down_cancel_rate_human-{code}")
@tool.singleton
@@ -1085,6 +1108,10 @@
                            logger_l2_l_cancel.exception(e)
                    if len(watch_indexes) >= MAX_COUNT:
                        break
                if not watch_indexes:
                    l2_log.l_cancel_debug(code, f"计算L后囊括范围没找到可囊括索引,{start_index}, {re_start_index}, {end_index}")
                    return
                if watch_indexes:
                    ##判断监听的数据中是否有大单##
                    # 之前的大单为100w,现在改为正常大单
@@ -1775,7 +1802,8 @@
            real_place_order_info = self.__real_place_order_index_dict.get(code)
            is_default_place_order_index = real_place_order_info[1] if real_place_order_info else False
            if is_default_place_order_index:
            if is_default_place_order_index and not cancel_rate_info[2][1]:
                # 人为设置的不能取最小
                thresh_hold_rate = min(0.49, thresh_hold_rate)
            l2_log.l_cancel_debug(code,
                                  f"L后计算范围:{start_index}-{end_index},已撤单比例:{rate}/{thresh_hold_rate},  下单位之后的索引:{after_place_order_index_dict}, 最大单-({max_num},{max_num_count}), 人为设置-{cancel_rate_info}, 真实下单位-{real_place_order_info}")
@@ -2064,7 +2092,7 @@
        """
        统计L后的大单信息
        @param code:
        @return: 囊括金额列表, 成交金额列表, 撤单金额列表, 待成交列表
        @return: [(索引,金额,手数,状态)]
        """
        watch_indexes_info = self.__get_watch_indexes_cache(code)
        if not watch_indexes_info:
@@ -2100,15 +2128,20 @@
                deal_indexes.add(index)
                continue
            not_deal_indexes.add(index)
        all_money_list = [int(float(total_datas[x]['val']['price'] * total_datas[x]['val']['num'] * 100)) for x in
                          all_indexes]
        deal_money_list = [int(float(total_datas[x]['val']['price'] * total_datas[x]['val']['num'] * 100)) for x in
                           deal_indexes]
        canceled_money_list = [int(float(total_datas[x]['val']['price'] * total_datas[x]['val']['num'] * 100)) for x in
                               canceled_indexes]
        not_deal_money_list = [int(float(total_datas[x]['val']['price'] * total_datas[x]['val']['num'] * 100)) for x in
                               not_deal_indexes]
        return all_money_list, deal_money_list, canceled_money_list, not_deal_money_list
        fdatas = []
        for x in all_indexes:
            item = [x, int(float(total_datas[x]['val']['price'] * total_datas[x]['val']['num'] * 100)), total_datas[x]['val']['num']]
            if x in deal_indexes:
                item.append(trade_constant.TRADE_STATE_BUY_SUCCESS)
            elif x in canceled_indexes:
                item.append(trade_constant.TRADE_STATE_BUY_CANCEL_SUCCESS)
            elif x in not_deal_indexes:
                item.append(trade_constant.TRADE_STATE_BUY_DELEGATED)
            else:
                item.append(trade_constant.TRADE_STATE_NOT_TRADE)
            fdatas.append(item)
        fdatas.sort(key=lambda  x: x[0])
        return fdatas
    # def statistic_total_big_order_info(self, code):
    #     """
@@ -2862,3 +2895,7 @@
        """
        self.__l_cancel_triggered_codes.add(code)
        self.__compute_watch_index(code, buy_single_index)
if __name__ == "__main__":
    CancelRateHumanSettingManager()
code_attribute/today_max_price_manager.py
@@ -50,31 +50,31 @@
            return False
        return True
    def set_price_info(self, code, price, time, sell1_info):
    def set_price_info(self, code, price, time_str, sell1_info):
        """
        设置价格信息
        @param sell1_info: 卖1信息:(卖1价, 卖1量)
        @param code:
        @param price:
        @param time:
        @param time_str:
        @return:
        """
        price_info = (price, time_str, sell1_info)
        old_price_info = self.__max_price_info_cache.get(code)
        if old_price_info and old_price_info[0] >= price:
            return
        price_info = (price, time, sell1_info)
        tool.CodeDataCacheUtil.set_cache(self.__max_price_info_cache, code, price_info)
        RedisUtils.setex_async(
            self.__db, "max_price_info-{}".format(code), tool.get_expire(), json.dumps(price_info))
        if not old_price_info or old_price_info[0] < price:
            tool.CodeDataCacheUtil.set_cache(self.__max_price_info_cache, code, price_info)
            RedisUtils.setex_async(
                self.__db, "max_price_info-{}".format(code), tool.get_expire(), json.dumps(price_info))
        # async_log_util.info(logger_debug, f"最大现价:{code}-{price_info}")
        # 统计涨停持续时间
        if self.__is_limit_up(code, price, sell1_info):
            if code not in self.__limit_up_latest_info_cache:
                self.__limit_up_latest_info_cache[code] = time
                self.__limit_up_latest_info_cache[code] = time_str
        else:
            if code not in self.__limit_up_records_cache:
                self.__limit_up_records_cache[code] = []
            if code in self.__limit_up_latest_info_cache:
                limit_up_info = (self.__limit_up_latest_info_cache.get(code), time)
                limit_up_info = (self.__limit_up_latest_info_cache.get(code), time_str)
                self.__limit_up_records_cache[code].append(limit_up_info)
                self.__limit_up_latest_info_cache.pop(code)
                async_log_util.info(logger_limit_up_record, f"{code}-{limit_up_info}")
servers/data_server.py
@@ -1167,7 +1167,10 @@
                        else:
                            data.append("--")
                        zylt_volume = global_util.zylt_volume_map.get(code)
                        zyltgb = zylt_volume * limit_up_price
                        if limit_up_price and zylt_volume:
                            zyltgb = zylt_volume * limit_up_price
                        else:
                            zyltgb = None
                        if latest_transaction_data:
                            data.append(
                                (latest_transaction_data[2] // 100,
@@ -1212,14 +1215,14 @@
                response_data = json.dumps({"code": 0, "data": fdatas})
            except Exception as e:
                logger_debug.exception(e)
        elif url.path == "/get_l2_down_watch_index_overview":
        elif url.path == "/get_l_down_watch_index_overview":
            try:
                ps_dict = dict([(k, v[0]) for k, v in parse_qs(url.query).items()])
                code = ps_dict.get('code')
                # 大单概览
                l2_down_data = LCancelBigNumComputer().statistic_l_down_watch_indexes_of_big_order_info(code)
                # total_big_order_info = LCancelBigNumComputer().statistic_total_big_order_info(code)
                response_data = json.dumps({"code": 0, "data": {"l_down": l2_down_data}})
                response_data = json.dumps({"code": 0, "data":  l2_down_data})
            except Exception as e:
                logger_debug.exception(e)
servers/huaxin_trade_server.py
@@ -711,7 +711,7 @@
                if len(deal_codes) >= MAX_COUNT:
                    l2_log.info(code, logger_l2_radical_buy, f"扫入成交代码个数大于{MAX_COUNT}个:{code}-{deal_codes}")
                    return True
            if code in deal_codes:
            if code in deal_codes and not CodesContinueBuyMoneyManager().get_continue_buy_money(code):
                l2_log.info(code, logger_l2_radical_buy, f"该代码已经成交:{code}")
                return True
trade/trade_manager.py
@@ -650,10 +650,12 @@
                l2_trade_util.forbidden_trade(code, msg="交易成功", force=True)
            state = CodesTradeStateManager().get_trade_state_cache(code)
            if state != trade_constant.TRADE_STATE_BUY_SUCCESS:
                CodesTradeStateManager().set_trade_state(code, trade_constant.TRADE_STATE_BUY_SUCCESS)
                # 删除买撤记录的临时信息
                kp_client_msg_manager.add_msg(code, "买入成交")
                l2_data_manager.TradePointManager().delete_buy_point(code)
                if not CodesContinueBuyMoneyManager().get_continue_buy_money(code):
                    # 没设置续买
                    CodesTradeStateManager().set_trade_state(code, trade_constant.TRADE_STATE_BUY_SUCCESS)
                    # 删除买撤记录的临时信息
                    kp_client_msg_manager.add_msg(code, "买入成交")
                    l2_data_manager.TradePointManager().delete_buy_point(code)
            # 交易成功时间过去3s之后,且当前委托列表里面还有该代码数据就再次执行撤单
            # 新版下单不处理
            if not constant.IS_NEW_VERSION_PLACE_ORDER: