Administrator
2023-11-19 6b002b4a90fd73db0daca682aec7a8b1318f1bff
炸板过后的票下午买入需要看板块不是独苗
3个文件已修改
99 ■■■■■ 已修改文件
l2/l2_data_manager_new.py 23 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_sell_manager.py 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
third_data/kpl_data_manager.py 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_data_manager_new.py
@@ -1,3 +1,4 @@
import copy
import logging
import random
import time as t
@@ -15,7 +16,7 @@
from utils import global_util, ths_industry_util, tool
import l2_data_util
from db import redis_manager_delegate as redis_manager
from third_data.code_plate_key_manager import CodePlateKeyBuyManager, KPLCodeJXBlockManager
from third_data.code_plate_key_manager import CodePlateKeyBuyManager, KPLCodeJXBlockManager, LimitUpCodesPlateKeyManager
from trade import trade_manager, trade_queue_manager, l2_trade_factor, l2_trade_util, \
    trade_result_manager, current_price_process_manager, trade_data_manager, trade_huaxin, trade_record_log_util
from l2 import l2_data_manager, l2_log, l2_data_source_util, code_price_manager, \
@@ -330,7 +331,6 @@
                l2_data_log.l2_time_log(code, "开始保存数据")
                l2.l2_data_util.save_l2_data(code, None, datas)
            origin_datas.clear()
    @classmethod
    def process_add_datas(cls, code, add_datas, capture_timestamp, __start_time):
@@ -888,6 +888,20 @@
                float(open_limit_up_lowest_price) - price_pre_close) / price_pre_close < 0.05:
            return False, True, f"炸板后最低价跌至5%以下"
        # 回封的票,下13:15买入需要判断板块是否为独苗
        if open_limit_up_lowest_price and int(tool.get_now_time_str().replace(":", "")) > 131500:
            # 获取当前票的涨停原因
            if code in LimitUpCodesPlateKeyManager.today_total_limit_up_reason_dict:
                limit_up_reason = kpl_data_manager.KPLLimitUpDataRecordManager.get_current_block(code)
                if limit_up_reason not in constant.KPL_INVALID_BLOCKS:
                    # 判断是否是独苗
                    codes = kpl_data_manager.KPLLimitUpDataRecordManager.get_current_codes_by_block(limit_up_reason)
                    if codes:
                        codes = copy.deepcopy(codes)
                        codes.discard(code)
                    if not codes:
                        return False, True, f"13:15以后炸板之后下单,({limit_up_reason}) 为独苗"
        # limit_up_info = cls.__Buy1PriceManager.get_limit_up_info(code)
        # if limit_up_info[0] is None and False:
        #     total_data = local_today_datas.get(code)
@@ -1122,7 +1136,8 @@
                        # 股价新高或者逼近前高
                        order_begin_pos.threshold_money = int(sell_info[1])
                    else:
                        if float(total_datas[buy_single_index]["val"]["price"]) >= 3 and cls.volume_rate_info[code][0] > 0.3 and sell_info[1] > 2000 * 10000:
                        if float(total_datas[buy_single_index]["val"]["price"]) >= 3 and cls.volume_rate_info[code][
                            0] > 0.3 and sell_info[1] > 2000 * 10000:
                            # 暂时打8折
                            # order_begin_pos.threshold_money = int(sell_info[1] * 0.8)
                            # 深证总卖大于1000万的票,m值打5折
@@ -1214,7 +1229,7 @@
            # 保存闪电下单的买入信息
            if order_begin_pos.mode == OrderBeginPosInfo.MODE_FAST:
                cls.__latest_fast_place_order_info_dict[code] = (
                order_begin_pos.sell_info[0], order_begin_pos.sell_info[1])
                    order_begin_pos.sell_info[0], order_begin_pos.sell_info[1])
            # 数据是否处理完毕
            if new_buy_exec_index < compute_end_index:
l2/l2_sell_manager.py
@@ -13,6 +13,7 @@
from utils.tool import CodeDataCacheUtil
# 卖行情信息
class L2MarketSellManager:
    __db = 0
    __redis_manager = redis_manager.RedisManager(0)
@@ -75,7 +76,6 @@
    def get_current_total_sell_data(self, code):
        return self.__current_total_sell_data_cache.get(code)
    # 获取参考卖的数据
    def get_refer_sell_data(self, code, time_str):
        cuurent = self.__current_total_sell_data_cache.get(code)
@@ -89,3 +89,57 @@
        return None
# 板上卖统计
class L2LimitUpSellManager:
    __db = 0
    __redis_manager = redis_manager.RedisManager(0)
    __instance = None
    __limit_up_sell_cache = {}
    def __new__(cls, *args, **kwargs):
        if not cls.__instance:
            cls.__instance = super(L2LimitUpSellManager, cls).__new__(cls, *args, **kwargs)
            cls.__load_datas()
        return cls.__instance
    @classmethod
    def __get_redis(cls):
        return cls.__redis_manager.getRedis()
    @classmethod
    def __load_datas(cls):
        __redis = cls.__get_redis()
        try:
            keys = RedisUtils.keys(__redis, "limit_up_sell_indexes-*")
            for k in keys:
                code = k.split("-")[-1]
                val = RedisUtils.smembers(__redis, k)
                CodeDataCacheUtil.set_cache(cls.__limit_up_sell_cache, code, val)
        except:
            pass
        finally:
            RedisUtils.realse(__redis)
    def add_limit_up_sell(self, code, index):
        if code not in self.__limit_up_sell_cache:
            self.__limit_up_sell_cache[code] = set()
        self.__limit_up_sell_cache[code].add(index)
        RedisUtils.sadd_async(self.__db, f"limit_up_sell_indexes-{code}", index)
        RedisUtils.expire_async(self.__db, f"limit_up_sell_indexes-{code}", tool.get_expire())
    def remove_limit_up_sell(self, code, index):
        if code in self.__limit_up_sell_cache:
            self.__limit_up_sell_cache[code].discard(index)
        RedisUtils.srem_async(self.__db, f"limit_up_sell_indexes-{code}", index)
    def clear(self):
        self.__limit_up_sell_cache.clear()
        keys = RedisUtils.keys(self.__get_redis(), "limit_up_sell_indexes-*")
        for k in keys:
            RedisUtils.delete_async(self.__db, k)
    # 设置当前的总卖
    def get_limit_up_sell_indexes(self, code):
        if code in self.__limit_up_sell_cache:
            return self.__limit_up_sell_cache[code]
        return set()
third_data/kpl_data_manager.py
@@ -45,6 +45,8 @@
    __kplPlatManager = KPLPlatManager()
    __LimitUpCodesPlateKeyManager = LimitUpCodesPlateKeyManager()
    __CodesPlateKeysManager = CodesHisReasonAndBlocksManager()
    __current_code_reason_dict = {}
    __current_reason_codes_dict = {}
    @classmethod
    def __load_hist_and_blocks(cls, code):
@@ -75,6 +77,16 @@
        if records:
            cls.latest_origin_datas = records
            cls.__LimitUpCodesPlateKeyManager.set_today_limit_up([(r[0], r[5]) for r in records])
        code_reason_dict = {}
        reason_code_dict = {}
        for d in records:
            code_reason_dict[d[0]] = d[5]
            if d[5] not in reason_code_dict:
                reason_code_dict[d[5]] = set()
            reason_code_dict[d[5]].add(d[0])
        cls.__current_code_reason_dict = code_reason_dict
        cls.__current_reason_codes_dict = reason_code_dict
        # 涨停数据记录
        mysqldb = mysql_data.Mysqldb()
@@ -188,6 +200,14 @@
        bs = set([b[0] for b in results])
        return bs
    @classmethod
    def get_current_block(cls, code):
        return cls.__current_code_reason_dict.get(code)
    @classmethod
    def get_current_codes_by_block(cls,block):
        return cls.__current_reason_codes_dict.get(block)
class KPLDataManager:
    __latest_datas = {}