Administrator
2024-06-05 4905b98d221044f08c8ac8db49e86a769e574bae
P撤修改/买入2000以下,买所有
5个文件已修改
119 ■■■■■ 已修改文件
code_attribute/first_target_code_data_processor.py 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
constant.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/cancel_buy_strategy.py 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_data_manager_new.py 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
third_data/history_k_data_util.py 37 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
code_attribute/first_target_code_data_processor.py
@@ -12,13 +12,31 @@
from code_attribute.gpcode_manager import WantBuyCodesManager
from log_module.log import logger_first_code_record, logger_l2_codes_subscript
from third_data.code_plate_key_manager import CodesHisReasonAndBlocksManager
from third_data.history_k_data_util import HistoryKDatasUtils
from third_data.history_k_data_util import HistoryKDatasUtils, JueJinApi
from ths import l2_code_operate
from trade import trade_data_manager, l2_trade_util
from settings.trade_setting import MarketSituationManager
from utils import global_util, tool, init_data_util, buy_condition_util
__CodesPlateKeysManager = CodesHisReasonAndBlocksManager()
def __is_normal_in_5d(code):
    """
    最近5天是否处于正常状态
    @param code:
    @return:
    """
    now_day = tool.get_now_date_str()
    results = JueJinApi.get_history_instruments(JueJinApi.get_juejin_code_list_with_prefix([code]),
                                                tool.date_sub(now_day, 30), tool.date_sub(now_day, 1))
    results = results[-5:]
    normal = True
    for r in results:
        if r["sec_level"] != 1:
            normal = False
            break
    return normal
def process_first_codes_datas(dataList, request_id=None):
@@ -156,6 +174,10 @@
                        l2_trade_util.forbidden_trade(code, "回踩不够")
                        continue
                    if not __is_normal_in_5d(code):
                        l2_trade_util.forbidden_trade(code, "最近5天有ST/非正常状态")
                        continue
                if code_nature_analyse.is_up_too_high_in_10d_with_limit_up(volumes_data):
                    # 判断是否太高
                    HighIncreaseCodeManager().add_code(code)
constant.py
@@ -179,7 +179,7 @@
########华鑫配置########
if not is_windows() or True:
    # 下单1手
    BUY_MONEY_PER_CODE = 500 if constant.IS_A else 20000
    BUY_MONEY_PER_CODE = 500 if constant.IS_A else 2000
    L2_SOURCE_TYPE = L2_SOURCE_TYPE_HUAXIN
    JUEJIN_LOCAL_API = False
    TRADE_WAY = TRADE_WAY_HUAXIN
l2/cancel_buy_strategy.py
@@ -428,18 +428,25 @@
            break
        # 是否是下单3分钟内
        if tool.trade_time_sub(total_datas[-1]['val']['time'], total_datas[real_order_index]['val']['time']) > 180:
        sub_time = tool.trade_time_sub(total_datas[-1]['val']['time'], total_datas[real_order_index]['val']['time'])
        if sub_time > 180:
            return False, "下单超过180s"
        total_left_count = 0
        if sub_time < 2:
            return False, "下单在2s内"
        limit_up_price = gpcode_manager.get_limit_up_price(code)
        # 计算我们后面的大单与涨停纯买额
        total_left_num = 0
        # 成交位到真实下单位剩余的未成交的单
        for i in range(real_trade_index + 1, real_order_index_info[0]):
        total_big_num_count = 0
        for i in range(real_order_index + 1, len(total_datas)):
            data = total_datas[i]
            val = data["val"]
            if not L2DataUtil.is_limit_up_price_buy(val):
                continue
            if val["num"] * float(val["price"]) < 5000:
            money = val["num"] * float(val["price"])
            if money < 5000:
                continue
            left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code,
                                                                                                     i,
@@ -447,35 +454,13 @@
                                                                                                     local_today_canceled_buyno_map.get(
                                                                                                         code))
            if left_count > 0:
                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 < 5 or total_left_num * float(limit_up_price) < 500 * 100:
            # 距离成交进度位5笔以内或500万以内
            # 计算我们后面的大单与涨停纯买额
            total_left_num = 0
            total_big_num_count = 0
            for i in range(real_order_index + 1, len(total_datas)):
                data = total_datas[i]
                val = data["val"]
                if not L2DataUtil.is_limit_up_price_buy(val):
                    continue
                money = val["num"] * float(val["price"])
                if money < 5000:
                    continue
                left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code,
                                                                                                         i,
                                                                                                         total_datas,
                                                                                                         local_today_canceled_buyno_map.get(
                                                                                                             code))
                if left_count > 0:
                    if money > 299 * 100:
                        total_big_num_count += 1
                    total_left_num += val["num"]
            left_money = total_left_num * float(limit_up_price)
            if total_big_num_count == 0 or left_money < 1000 * 100:
                # 实际下单位后方所有涨停纯买额≤1000万或没有任何大单(≥299万)
                return True, f"P撤:封单纯买额-{round(left_money / 100, 1)}万 大单数量-{total_big_num_count} 下单位-{real_order_index} 成交位-{real_trade_index}"
                if money > 299 * 100:
                    total_big_num_count += 1
                total_left_num += val["num"]
        left_money = total_left_num * float(limit_up_price)
        if left_money < 1000 * 100:
            # 实际下单位后方所有涨停纯买额≤1000万
            return True, f"P撤:封单纯买额-{round(left_money / 100, 1)}万 大单数量-{total_big_num_count} 下单位-{real_order_index} 成交位-{real_trade_index}"
        return False, "不满足撤单条件"
    # w撤
l2/l2_data_manager_new.py
@@ -1302,6 +1302,9 @@
    @classmethod
    def can_buy_first_new(cls, code, limit_up_price):
        if 1>0:
            return True, False, "买所有"
        now_timestamp = int(tool.get_now_time_str().replace(":", ""))
        # 判断板块
        # (可以买的板块列表, 是否是独苗, 消息简介,可买的强势主线, 板块关键词)
third_data/history_k_data_util.py
@@ -83,6 +83,13 @@
                              "skip_st": skip_st, "fields": fields})
    @classmethod
    def get_history_instruments(cls, symbols, start_date, end_date, fields):
        return cls.__request("get_history_instruments",
                             {"symbols": symbols, "start_date": start_date, "end_date": end_date, "fields": fields})
    @classmethod
    def get_previous_trading_date(cls, exchange, date):
        return cls.__request("get_previous_trading_date", {"exchange": exchange, "date": date})
@@ -164,16 +171,27 @@
    # 获取交易所的代码
    @classmethod
    def get_exchanges_codes(cls, exchanges):
    def get_exchanges_codes(cls, exchanges, skip_suspended=True, skip_st=True):
        if constant.JUEJIN_LOCAL_API:
            account_id, s_id, token = cls.getJueJinAccountInfo()
            gmapi.set_token(token)
            return gmapi.get_instruments(exchanges=exchanges, sec_types=[1], skip_suspended=True, skip_st=True,
            return gmapi.get_instruments(exchanges=exchanges, sec_types=[1], skip_suspended=skip_suspended,
                                         skip_st=skip_st,
                                         fields="symbol,sec_type,sec_id,sec_name,listed_date,sec_level,is_suspended,pre_close")
        else:
            return JueJinHttpApi.get_exchanges_codes(exchanges=exchanges, sec_types=[1], skip_suspended=True,
                                                     skip_st=True,
            return JueJinHttpApi.get_exchanges_codes(exchanges=exchanges, sec_types=[1], skip_suspended=skip_suspended,
                                                     skip_st=skip_st,
                                                     fields="symbol,sec_type,sec_id,sec_name,listed_date,sec_level,is_suspended,pre_close")
    @classmethod
    def get_history_instruments(cls, symbols, start_date, end_date, fields=None):
        if constant.JUEJIN_LOCAL_API:
            account_id, s_id, token = cls.getJueJinAccountInfo()
            gmapi.set_token(token)
            return gmapi.get_history_instruments(symbols=symbols, start_date=start_date, end_date=end_date,
                                         fields="symbol,sec_type,sec_id,sec_name,listed_date,sec_level,is_suspended,pre_close")
        else:
            return JueJinHttpApi.get_history_instruments(symbols, start_date, end_date, fields)
    @classmethod
    def get_previous_trading_date(cls, date):
@@ -316,5 +334,12 @@
if __name__ == "__main__":
    results = HistoryKDatasUtils.get_codes_limit_rate(list({"000422", "600610"}))
    print(results)
    now_day = tool.get_now_date_str()
    results = JueJinApi.get_history_instruments(JueJinApi.get_juejin_code_list_with_prefix(["600265"]), tool.date_sub(now_day,30), tool.date_sub(now_day,1))
    results = results[-5:]
    normal = True
    for r in results:
        if r["sec_level"]!=1:
            normal = False
            break
    print(normal)