Administrator
2024-06-07 1a0be577a89727ef6b80245b6b53c8ddf43ca7d9
可购买创业板
26个文件已修改
408 ■■■■■ 已修改文件
code_attribute/code_data_util.py 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
code_attribute/code_nature_analyse.py 143 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
code_attribute/first_target_code_data_processor.py 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
code_attribute/gpcode_manager.py 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
huaxin_client/l1_client.py 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
huaxin_client/l1_client_for_trade.py 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
huaxin_client/l1_subscript_codes_manager.py 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
huaxin_client/l2_client.py 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
huaxin_client/l2_market_client.py 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
huaxin_client/trade_client.py 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/huaxin/huaxin_delegate_postion_manager.py 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_data_manager_new.py 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
test/test_code_attribute.py 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
third_data/code_plate_key_manager.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
third_data/data_server.py 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
third_data/feed_analysis.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
third_data/history_k_data_util.py 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
third_data/kpl_block_util.py 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/current_price_process_manager.py 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/huaxin/huaxin_trade_api_server.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/huaxin/huaxin_trade_server.py 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/l2_trade_factor.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/trade_huaxin.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/trade_juejin.py 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
utils/init_data_util.py 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
utils/tool.py 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
code_attribute/code_data_util.py
@@ -21,8 +21,8 @@
        print('进入调试')
    # 昨日收盘价
    price_close = gpcode_manager.CodePrePriceManager.get_price_pre_cache(code)
    max_price = tool.to_price(decimal.Decimal(str(price_close)) * decimal.Decimal("1.1"))
    min_price = tool.to_price(decimal.Decimal(str(price_close)) * decimal.Decimal("0.9"))
    max_price = tool.to_price(decimal.Decimal(str(price_close)) * decimal.Decimal(tool.get_limit_up_rate(code)))
    min_price = tool.to_price(decimal.Decimal(str(price_close)) * decimal.Decimal(tool.get_limit_down_rate(code)))
    if min_price <= decimal.Decimal(str(price)) <= max_price:
        return True
    return False
code_attribute/code_nature_analyse.py
@@ -5,15 +5,13 @@
# 是否有涨停
import copy
import json
import random
import time
from code_attribute import gpcode_manager
# 代码股性记录管理
from db import redis_manager
from utils import tool
from db.redis_manager_delegate import RedisManager, RedisUtils
from db.redis_manager_delegate import RedisUtils
from utils.tool import CodeDataCacheUtil
@@ -191,23 +189,23 @@
# 设置历史K线
def set_record_datas(code, limit_up_price, record_datas):
    k_format = get_k_format(float(limit_up_price), record_datas)
    k_format = get_k_format(code, float(limit_up_price), record_datas)
    CodeNatureRecordManager().save_k_format(code, k_format)
    natures = get_nature(record_datas)
    natures = get_nature(code, record_datas)
    CodeNatureRecordManager().save_nature(code, natures)
# 获取K线形态
# 返回 (15个交易日涨幅是否大于24.9%,是否破前高,是否超跌,是否接近前高,是否N,是否V,是否有形态,天量大阳信息,是否具有辨识度,近2天有10天内最大量,上个交易日是否炸板)
def get_k_format(limit_up_price, record_datas):
    p1_data = get_lowest_price_rate(record_datas)
def get_k_format(code, limit_up_price, record_datas):
    p1_data = get_lowest_price_rate(code, record_datas)
    p1 = p1_data[0] >= 0.249, p1_data[1]
    p2 = __is_new_top(limit_up_price, record_datas)
    p3 = __is_lowest(record_datas)
    p4 = __is_near_new_top(limit_up_price, record_datas)
    p5 = __is_n_model(record_datas)
    p6 = __is_v_model(record_datas)
    p8 = __get_big_volumn_info(record_datas)
    p2 = __is_new_top(code, limit_up_price, record_datas)
    p3 = __is_lowest(code, record_datas)
    p4 = __is_near_new_top(code, limit_up_price, record_datas)
    p5 = __is_n_model(code, record_datas)
    p6 = __is_v_model(code, record_datas)
    p8 = __get_big_volumn_info(code, record_datas)
    # # N字型包含了N字型
    # if p5:
@@ -216,21 +214,22 @@
    p7 = (p1[0] or p2[0] or p3[0] or p4[0] or p5[0] or p6[0], '')
    # 是否具有辨识度
    p9 = is_special(record_datas)
    p10 = is_latest_10d_max_volume_at_latest_2d(record_datas)
    p9 = is_special(code, record_datas)
    p10 = is_latest_10d_max_volume_at_latest_2d(code, record_datas)
    # 最近5天是否炸板
    p11 = __is_latest_open_limit_up(record_datas, 5)
    p11 = __is_latest_open_limit_up(code, record_datas, 5)
    # 30天内是否有涨停
    p12 = __has_limit_up(record_datas, 30)
    p12 = __has_limit_up(code, record_datas, 30)
    # 最近5天是否跌停
    p13 = __is_latest_limit_down(record_datas, 5)
    p13 = __is_latest_limit_down(code, record_datas, 5)
    return p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13
# 是否具有K线形态
def is_has_k_format(limit_up_price, record_datas):
def is_has_k_format(code, limit_up_price, record_datas):
    is_too_high, is_new_top, is_lowest, is_near_new_top, is_n, is_v, has_format, volume_info, is_special, has_max_volume, open_limit_up, is_limit_up_in_30days, is_latest_limit_down = get_k_format(
        code,
        float(limit_up_price), record_datas)
    if not has_format:
        return False, "不满足K线形态"
@@ -239,21 +238,21 @@
# 获取股性
# 返回(是否涨停,首板溢价率,首板炸板溢价率)
def get_nature(record_datas):
    limit_up_count = get_first_limit_up_count(record_datas)
    premium_rate = get_limit_up_premium_rate(record_datas)
    open_premium_rate = get_open_limit_up_premium_rate(record_datas)
def get_nature(code, record_datas):
    limit_up_count = get_first_limit_up_count(code, record_datas)
    premium_rate = get_limit_up_premium_rate(code, record_datas)
    open_premium_rate = get_open_limit_up_premium_rate(code, record_datas)
    result = (limit_up_count, premium_rate, open_premium_rate)
    return result
# 获取涨幅
def get_lowest_price_rate(record_datas):
def get_lowest_price_rate(code, record_datas):
    datas = copy.deepcopy(record_datas)
    datas.sort(key=lambda x: x["bob"])
    datas = datas[-10:]
    for data in datas:
        limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(data["pre_close"]))
        limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(code, data["pre_close"]))
        if abs(limit_up_price - data["high"]) < 0.01:
            date = data['bob'].strftime("%Y-%m-%d")
            return round((datas[-1]["close"] - data["close"]) / data["close"], 4), date
@@ -261,7 +260,7 @@
# 是否涨得太高
def is_up_too_high_in_10d_with_limit_up(record_datas):
def is_up_too_high_in_10d_with_limit_up(code, record_datas):
    datas = copy.deepcopy(record_datas)
    datas.sort(key=lambda x: x["bob"])
    datas = datas[-10:]
@@ -269,7 +268,7 @@
    limit_up_count = 0
    max_price = datas[0]["high"]
    for data in datas:
        limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(data["pre_close"]))
        limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(code, data["pre_close"]))
        date = data['bob'].strftime("%Y-%m-%d")
        if data["high"] > max_price:
            max_price = data["high"]
@@ -300,7 +299,7 @@
# 10天内的最高量是否集中在最近两天
def is_latest_10d_max_volume_at_latest_2d(record_datas):
def is_latest_10d_max_volume_at_latest_2d(code, record_datas):
    datas = copy.deepcopy(record_datas)
    datas.sort(key=lambda x: x["bob"])
    datas = datas[-10:]
@@ -315,11 +314,12 @@
# 120 天内是否长得太高
def is_up_too_high_in_120d(record_datas):
def is_up_too_high_in_120d(code, record_datas):
    datas = copy.deepcopy(record_datas)
    datas.sort(key=lambda x: x["bob"])
    datas = datas[-120:]
    today_limit_up_price = round(float(gpcode_manager.get_limit_up_price_by_preprice(datas[-1]["close"])), 2)
    today_limit_up_price = round(
        float(gpcode_manager.get_limit_up_price_by_preprice(code, datas[-1]["close"])), 2)
    max_price = 0
    for data in datas:
        if data["high"] > max_price:
@@ -342,19 +342,20 @@
# 暂时不使用
# 从最近一次涨停开始,是否涨幅过高
def is_up_too_high_from_latest_limit_up(record_datas):
def is_up_too_high_from_latest_limit_up(code, record_datas):
    datas = copy.deepcopy(record_datas)
    datas.sort(key=lambda x: x["bob"])
    datas = datas[-20:]
    datas.reverse()
    today_limit_up_price = round(float(gpcode_manager.get_limit_up_price_by_preprice(datas[0]["close"])), 2)
    today_limit_up_price = round(
        float(gpcode_manager.get_limit_up_price_by_preprice(code, datas[0]["close"])), 2)
    max_price = 0
    limit_up_price = None
    for i in range(0, len(datas)):
        item = datas[i]
        if item['high'] > max_price:
            max_price = item['high']
        if __is_limited_up(item):
        if __is_limited_up(code, item):
            limit_up_price = item['high']
            break
    if not limit_up_price:
@@ -367,7 +368,7 @@
# 最近几天是否有最大量
def is_have_latest_max_volume(record_datas, day_count):
def is_have_latest_max_volume(code, record_datas, day_count):
    datas = copy.deepcopy(record_datas)
    datas.sort(key=lambda x: x["bob"])
    datas = datas[-120:]
@@ -381,7 +382,7 @@
# 在最近几天内股价是否长得太高
def is_price_too_high_in_days(record_datas, limit_up_price, day_count=5):
def is_price_too_high_in_days(code, record_datas, limit_up_price, day_count=5):
    datas = copy.deepcopy(record_datas)
    datas.sort(key=lambda x: x["bob"])
    datas = datas[0 - day_count:]
@@ -406,7 +407,7 @@
# 连续涨停后是否回调不足够
def is_continue_limit_up_not_enough_fall_dwon(record_datas):
def is_continue_limit_up_not_enough_fall_dwon(code, record_datas):
    # 10 天内是否有连续3板
    datas = copy.deepcopy(record_datas)
    datas.sort(key=lambda x: x["bob"])
@@ -416,7 +417,7 @@
    for i in range(len(datas)):
        item = datas[i]
        if __is_limit_up(item):
        if __is_limit_up(code, item):
            if not limit_up_continue_count_info:
                limit_up_continue_count_info = [1, i]
            else:
@@ -452,13 +453,13 @@
# 是否有涨停
def get_first_limit_up_count(datas):
def get_first_limit_up_count(code, datas):
    datas = copy.deepcopy(datas)
    count = 0
    for i in range(len(datas)):
        item = datas[i]
        # 获取首板涨停次数
        if __is_limit_up(item) and i > 0 and not __is_limit_up(datas[i - 1]):
        if __is_limit_up(code, item) and i > 0 and not __is_limit_up(code, datas[i - 1]):
            # 首板涨停
            count += 1
@@ -466,7 +467,7 @@
# 是否破前高
def __is_new_top(limit_up_price, datas):
def __is_new_top(code, limit_up_price, datas):
    datas = copy.deepcopy(datas)
    datas.sort(key=lambda x: x["bob"])
    datas = datas[-80:]
@@ -479,16 +480,16 @@
    return False, ''
def is_new_top(limit_up_price, datas):
    return __is_new_top(float(limit_up_price), datas)[0]
def is_new_top(code, limit_up_price, datas):
    return __is_new_top(code, float(limit_up_price), datas)[0]
def is_near_top(limit_up_price, datas):
    return __is_near_new_top(float(limit_up_price), datas)[0]
def is_near_top(code, limit_up_price, datas):
    return __is_near_new_top(code, float(limit_up_price), datas)[0]
# 接近新高
def __is_near_new_top(limit_up_price, datas):
def __is_near_new_top(code, limit_up_price, datas):
    datas = copy.deepcopy(datas)
    datas.sort(key=lambda x: x["bob"])
    datas = datas[-80:]
@@ -507,7 +508,7 @@
# 是否跌破箱体
def __is_lowest(datas):
def __is_lowest(code, datas):
    datas = copy.deepcopy(datas)
    datas.sort(key=lambda x: x["bob"])
    datas = datas[-80:]
@@ -528,7 +529,7 @@
# N字形
def __is_n_model(datas):
def __is_n_model(code, datas):
    datas = copy.deepcopy(datas)
    datas.sort(key=lambda x: x["bob"])
    datas = datas[-80:]
@@ -538,7 +539,7 @@
        for i in range(len(datas) - 5, len(datas)):
            item = datas[i]
            print(item)
            limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(item["pre_close"]))
            limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(code, item["pre_close"]))
            if abs(limit_up_price - item["high"]) < 0.001 and abs(
                    limit_up_price - datas[i - 1]["high"]) >= 0.001:
                # 涨停,前一天非涨停
@@ -552,25 +553,25 @@
# 最近几天是否有炸板或跌停
def __is_latest_open_limit_up(datas, day_count):
def __is_latest_open_limit_up(code, datas, day_count):
    datas = copy.deepcopy(datas)
    datas.sort(key=lambda x: x["bob"])
    items = datas[0 - day_count:]
    for item in items:
        limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(item["pre_close"]))
        limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(code, item["pre_close"]))
        if abs(limit_up_price - item["high"]) < 0.001 and abs(limit_up_price - item["close"]) > 0.001:
            # 炸板
            return True
    return False
def __is_latest_limit_down(datas, day_count):
def __is_latest_limit_down(code, datas, day_count):
    datas = copy.deepcopy(datas)
    datas.sort(key=lambda x: x["bob"])
    items = datas[0 - day_count:]
    for item in items:
        # 是否有跌停
        limit_down_price = float(gpcode_manager.get_limit_down_price_by_preprice(item["pre_close"]))
        limit_down_price = float(gpcode_manager.get_limit_down_price_by_preprice(code, item["pre_close"]))
        if abs(limit_down_price - item["close"]) < 0.001:
            # 跌停
            return True
@@ -578,7 +579,7 @@
# V字形
def __is_v_model(datas):
def __is_v_model(code, datas):
    datas = copy.deepcopy(datas)
    datas.sort(key=lambda x: x["bob"])
    datas = datas[-30:]
@@ -589,11 +590,9 @@
            max_price = datas[i]["close"]
            max_price_index = i
    min_price = max_price
    min_price_index = max_price_index
    for i in range(max_price_index, len(datas)):
        if min_price > datas[i]["close"]:
            min_price = datas[i]["close"]
            min_price_index = i
    if (max_price - min_price) / max_price > 0.249:
        return True, ''
@@ -602,7 +601,7 @@
# 是否天量大阳
def __get_big_volumn_info(datas):
def __get_big_volumn_info(code, datas):
    datas = copy.deepcopy(datas)
    datas.sort(key=lambda x: x["bob"])
    datas = datas[-30:]
@@ -617,40 +616,40 @@
# 是否涨停
def __is_limit_up(data):
    limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(data["pre_close"]))
def __is_limit_up(code, data):
    limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(code, data["pre_close"]))
    return abs(limit_up_price - data["close"]) < 0.001
# 是否涨停过
def __is_limited_up(data):
    limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(data["pre_close"]))
def __is_limited_up(code, data):
    limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(code, data["pre_close"]))
    return abs(limit_up_price - data["high"]) < 0.001
# 多少天内是否有涨停/曾涨停
def __has_limit_up(datas, day_count):
def __has_limit_up(code, datas, day_count):
    datas = copy.deepcopy(datas)
    datas.sort(key=lambda x: x["bob"])
    datas = datas[0 - day_count:]
    if len(datas) >= 1:
        for i in range(0, len(datas)):
            item = datas[i]
            if __is_limit_up(item):
            if __is_limit_up(code, item):
                return True
    return False
# 首板涨停溢价率
def get_limit_up_premium_rate(datas):
def get_limit_up_premium_rate(code, datas):
    datas = copy.deepcopy(datas)
    datas.sort(key=lambda x: x["bob"])
    first_rate_list = []
    for i in range(0, len(datas)):
        item = datas[i]
        limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(item["pre_close"]))
        limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(code, item["pre_close"]))
        if abs(limit_up_price - item["close"]) < 0.001:
            if 0 < i < len(datas) - 1 and not __is_limit_up(datas[i - 1]):
            if 0 < i < len(datas) - 1 and not __is_limit_up(code, datas[i - 1]):
                # 首板涨停
                rate = (datas[i + 1]["high"] - datas[i + 1]["pre_close"]) / datas[i + 1]["pre_close"]
                first_rate_list.append(rate)
@@ -664,18 +663,16 @@
# 首板炸板溢价率
def get_open_limit_up_premium_rate(datas):
def get_open_limit_up_premium_rate(code, datas):
    datas = copy.deepcopy(datas)
    datas.sort(key=lambda x: x["bob"])
    first_rate_list = []
    for i in range(0, len(datas)):
        item = datas[i]
        limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(item["pre_close"]))
        limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(code, item["pre_close"]))
        if abs(limit_up_price - item["high"]) < 0.001 and abs(limit_up_price - item["close"]) > 0.001:
            #
            limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(datas[i - 1]["pre_close"]))
            if 0 < i < len(datas) - 1 and not __is_limit_up(datas[i - 1]):
            if 0 < i < len(datas) - 1 and not __is_limit_up(code, datas[i - 1]):
                # 前一天未涨停
                rate = (datas[i + 1]["high"] - item["high"]) / item["high"]
                first_rate_list.append(rate)
@@ -689,7 +686,7 @@
# 是否具有辨识度
def is_special(datas):
def is_special(code, datas):
    datas = copy.deepcopy(datas)
    datas.sort(key=lambda x: x["bob"])
    datas_30 = datas[-30:]
@@ -699,7 +696,7 @@
    continue_count = 0
    has_continue = False
    for item in datas_30:
        if __is_limit_up(item):
        if __is_limit_up(code, item):
            continue_count += 1
            count += 1
            if continue_count >= 4:
@@ -713,7 +710,7 @@
    has_continue = False
    # 90个交易日内涨停次数≥6次
    for item in datas_90:
        if __is_limit_up(item):
        if __is_limit_up(code, item):
            continue_count += 1
            count += 1
            if continue_count >= 4:
code_attribute/first_target_code_data_processor.py
@@ -135,17 +135,19 @@
                continue
            try:
                volumes_data = init_data_util.get_volumns_by_code(code, 150)
                volumes = init_data_util.parse_max_volume(volumes_data[:90],
                                                          code_nature_analyse.is_new_top(
                                                              limit_up_price,
                                                              volumes_data[:90]) or code_nature_analyse.is_near_top(
                volumes = init_data_util.parse_max_volume(code, volumes_data[:90],
                                                          code_nature_analyse.is_new_top(code,
                                                                                         limit_up_price,
                                                                                         volumes_data[
                                                                                         :90]) or code_nature_analyse.is_near_top(
                                                              code,
                                                              limit_up_price,
                                                              volumes_data[:90]))
                logger_first_code_record.info("{} 获取到首板60天最大量:{}", code, volumes)
                code_volumn_manager.set_histry_volumn(code, volumes[0], volumes[1], volumes[2], volumes[3])
                # 保存K线形态
                k_format = code_nature_analyse.get_k_format(limit_up_price, volumes_data)
                k_format = code_nature_analyse.get_k_format(code, limit_up_price, volumes_data)
                code_nature_analyse.CodeNatureRecordManager().save_k_format(code, k_format)
                # 是否具有辨识度
@@ -163,13 +165,13 @@
                            l2_trade_util.forbidden_trade(code,
                                                          f"无辨识度,涨停价({limit_up_price})>50")
                            continue
                    if code_nature_analyse.is_price_too_high_in_days(volumes_data, limit_up_price)[0]:
                    if code_nature_analyse.is_price_too_high_in_days(code, volumes_data, limit_up_price)[0]:
                        # 判断是否太高
                        l2_trade_util.forbidden_trade(code, "6天内股价长得太高")
                        continue
                        pass
                    if code_nature_analyse.is_continue_limit_up_not_enough_fall_dwon(volumes_data):
                    if code_nature_analyse.is_continue_limit_up_not_enough_fall_dwon(code, volumes_data):
                        # 判断是否太高
                        l2_trade_util.forbidden_trade(code, "回踩不够")
                        continue
@@ -178,17 +180,17 @@
                        l2_trade_util.forbidden_trade(code, "最近5天有ST/非正常状态")
                        continue
                if code_nature_analyse.is_up_too_high_in_10d_with_limit_up(volumes_data):
                if code_nature_analyse.is_up_too_high_in_10d_with_limit_up(code, volumes_data):
                    # 判断是否太高
                    HighIncreaseCodeManager().add_code(code)
                if code_nature_analyse.is_up_too_high_in_120d(volumes_data):
                if code_nature_analyse.is_up_too_high_in_120d(code, volumes_data):
                    # 判断是否太高
                    # l2_trade_util.forbidden_trade(code, "120天内股价长得太高")
                    # HighIncreaseCodeManager().add_code(code)
                    pass
                if code_nature_analyse.is_have_latest_max_volume(volumes_data, 2):
                if code_nature_analyse.is_have_latest_max_volume(code, volumes_data, 2):
                    # 最近2天是否是最高量
                    code_nature_analyse.LatestMaxVolumeManager().set_has_latest_max_volume(code)
code_attribute/gpcode_manager.py
@@ -696,9 +696,9 @@
        data = get_gp_list()
    list = []
    for d in data:
        if d[0:2] == '00':
        if tool.is_sz_code(d):
            list.append("SZSE.{}".format(d))
        elif d[0:2] == '60':
        elif tool.is_sh_code(d):
            list.append("SHSE.{}".format(d))
    return list
@@ -746,7 +746,7 @@
    price = CodePrePriceManager.get_price_pre_cache(code)
    if price is None:
        return None
    limit_up_price = tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal("1.1"))
    limit_up_price = tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal(tool.get_limit_up_rate(code)))
    __limit_up_price_dict[code] = limit_up_price
    return limit_up_price
@@ -757,16 +757,16 @@
    return None
def get_limit_up_price_by_preprice(price):
def get_limit_up_price_by_preprice(code, price):
    if price is None:
        return None
    return tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal("1.1"))
    return tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal(f"{tool.get_limit_up_rate(code)}"))
def get_limit_down_price_by_preprice(price):
def get_limit_down_price_by_preprice(code, price):
    if price is None:
        return None
    return tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal("0.9"))
    return tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal(f"{tool.get_limit_down_rate(code)}"))
# 获取跌停价
@@ -774,7 +774,7 @@
    price = CodePrePriceManager.get_price_pre_cache(code)
    if price is None:
        return None
    return tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal("0.9"))
    return tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal(f"{tool.get_limit_down_rate(code)}"))
# 获取现价
huaxin_client/l1_client.py
@@ -10,6 +10,7 @@
import xmdapi
from huaxin_client import tool, constant
from log_module.log import logger_system, logger_local_huaxin_l1, logger_l2_codes_subscript
from utils import tool as out_tool
################B类##################
ADDRESS = "udp://224.224.1.19:7880"
@@ -112,7 +113,7 @@
            return
        if pMarketDataField.SecurityName.find("ST") >= 0:
            return
        close_price = round(pMarketDataField.UpperLimitPrice / 1.1, 2)
        close_price = round(pMarketDataField.UpperLimitPrice / out_tool.get_limit_up_rate(pMarketDataField.SecurityID), 2)
        rate = round((pMarketDataField.LastPrice - close_price) * 100 / close_price, 2)
        # print(pMarketDataField.SecurityID, pMarketDataField.SecurityName, rate, pMarketDataField.Volume)
huaxin_client/l1_client_for_trade.py
@@ -11,6 +11,8 @@
from log_module.log import logger_system, logger_local_huaxin_l1, logger_local_huaxin_l1_trade_info
################B类##################
from utils import tool
ADDRESS = "udp://224.224.1.19:7880"
################A类##################
@@ -52,9 +54,10 @@
        codes_sh = []
        codes_sz = []
        for code in codes:
            if code.find("60") == 0:
            market_type = tool.get_market_type(code)
            if market_type == tool.MARKET_TYPE_SSE:
                codes_sh.append(code.encode("utf-8"))
            elif code.find("00") == 0:
            elif market_type == tool.MARKET_TYPE_SZSE:
                codes_sz.append(code.encode("utf-8"))
        return codes_sh, codes_sz
huaxin_client/l1_subscript_codes_manager.py
@@ -10,6 +10,9 @@
# 请求l1订阅的目标代码
from utils import tool
def request_l1_subscript_target_codes():
    type_ = "get_level1_codes"
    fdata = json.dumps(
@@ -29,7 +32,7 @@
                codes_sh = []
                codes_sz = []
                for code in codes:
                    if code.find("00") == 0:
                    if tool.is_sz_code(code):
                        codes_sz.append(code.encode("utf-8"))
                    else:
                        codes_sh.append(code.encode("utf-8"))
huaxin_client/l2_client.py
@@ -76,9 +76,10 @@
        szse_codes = []
        sse_codes = []
        for code in codes:
            if code.find("00") == 0:
            market_type = tool.get_market_type(code)
            if market_type == tool.MARKET_TYPE_SZSE:
                szse_codes.append(code.encode())
            elif code.find("60") == 0:
            elif market_type == tool.MARKET_TYPE_SSE:
                sse_codes.append(code.encode())
        return sse_codes, szse_codes
huaxin_client/l2_market_client.py
@@ -49,10 +49,11 @@
        szse_codes = []
        sse_codes = []
        for code in codes:
            if code.find("00") == 0:
                szse_codes.append(code.encode())
            elif code.find("60") == 0:
            market_type = tool.get_market_type(code)
            if market_type == tool.MARKET_TYPE_SSE:
                sse_codes.append(code.encode())
            elif market_type == tool.MARKET_TYPE_SZSE:
                szse_codes.append(code.encode())
        return sse_codes, szse_codes
    def __unsubscribe(self, _codes):
@@ -174,7 +175,7 @@
            limit_up_count = len(self.__limit_up_codes)
            # 获取是否涨停价
            limit_up_price = float(
                tool.to_price(decimal.Decimal(str(pDepthMarketData['PreClosePrice'])) * decimal.Decimal("1.1")))
                tool.to_price(decimal.Decimal(str(pDepthMarketData['PreClosePrice'])) * decimal.Decimal(tool.get_limit_up_rate(pDepthMarketData['SecurityID']))))
            if abs(limit_up_price - pDepthMarketData['LastPrice']) < 0.001 or abs(
                    limit_up_price - pDepthMarketData['BidPrice1']) < 0.001:
                huaxin_l2_log.info(hx_logger_l2_market_data_before_open, f"{d}")
huaxin_client/trade_client.py
@@ -136,10 +136,10 @@
        # TORA_TSTP_EXD_SZSE(2): 深圳交易所
        # TORA_TSTP_EXD_HK(3): 香港交易所
        # TORA_TSTP_EXD_BSE(4): 北京证券交易所
        if code.find('00') == 0:
        if tool.is_sz_code(code):
            req_field.ExchangeID = traderapi.TORA_TSTP_EXD_SZSE
            req_field.ShareholderID = SZSE_ShareHolderID
        elif code.find('60') == 0:
        elif tool.is_sh_code(code):
            req_field.ExchangeID = traderapi.TORA_TSTP_EXD_SSE
            req_field.ShareholderID = SSE_ShareHolderID
@@ -203,7 +203,7 @@
                # 撤掉影子单
                shadow_cancel_order_ref = shadow_order_ref + 1
                # 深证停留50ms上证停留200ms
                delay_s = 0.05 if code.find("00") == 0 else 0.2
                delay_s = 0.05 if tool.is_sz_code(code) else 0.2
                self.cancel_buy(code, f"s_c_{shadow_order_ref}", order_sys_id=None,
                                order_ref=shadow_order_ref,
                                order_action_ref=None, delay_s=delay_s)
@@ -222,9 +222,9 @@
        self.req_id += 1
        # 请求撤单
        req_field = traderapi.CTORATstpInputOrderActionField()
        if code.find('00') == 0:
        if tool.is_sz_code(code):
            req_field.ExchangeID = traderapi.TORA_TSTP_EXD_SZSE
        elif code.find('60') == 0:
        elif tool.is_sh_code(code):
            req_field.ExchangeID = traderapi.TORA_TSTP_EXD_SSE
        req_field.ActionFlag = traderapi.TORA_TSTP_AF_Delete
@@ -274,10 +274,10 @@
        # TORA_TSTP_EXD_SZSE(2): 深圳交易所
        # TORA_TSTP_EXD_HK(3): 香港交易所
        # TORA_TSTP_EXD_BSE(4): 北京证券交易所
        if code.find('00') == 0:
        if tool.is_sz_code(code):
            req_field.ExchangeID = traderapi.TORA_TSTP_EXD_SZSE
            req_field.ShareholderID = SZSE_ShareHolderID
        elif code.find('60') == 0:
        elif tool.is_sh_code(code):
            req_field.ExchangeID = traderapi.TORA_TSTP_EXD_SSE
            req_field.ShareholderID = SSE_ShareHolderID
@@ -346,9 +346,9 @@
        self.req_id += 1
        # 请求撤单
        req_field = traderapi.CTORATstpInputOrderActionField()
        if code.find('00') == 0:
        if tool.is_sz_code(code):
            req_field.ExchangeID = traderapi.TORA_TSTP_EXD_SZSE
        elif code.find('60') == 0:
        elif tool.is_sh_code(code):
            req_field.ExchangeID = traderapi.TORA_TSTP_EXD_SSE
        req_field.ActionFlag = traderapi.TORA_TSTP_AF_Delete
l2/huaxin/huaxin_delegate_postion_manager.py
@@ -27,7 +27,7 @@
# 获取下单信息
def get_order_info(code):
    info = _place_order_info_dict.get(code)
    TIME_SPACE_THRESHHOD = 3 if code.find("00") == 0 else 20
    TIME_SPACE_THRESHHOD = 3 if tool.is_sz_code(code) else 20
    if info and time.time() - info[3] > TIME_SPACE_THRESHHOD:
        async_log_util.info(logger_real_place_order_position, "get_order_info 间隔{}s以上:code-{}", TIME_SPACE_THRESHHOD,
                            code)
@@ -46,7 +46,7 @@
def __compute_estimate_order_position(code, exec_buy_index, shadow_price):
    total_datas = l2_data_util.local_today_datas.get(code)
    try:
        if code.find("60") == 0:
        if tool.is_sh_code(code):
            # 通过影子单买撤数据的订单号确认大致位置
            shadow_place_order_cancel_index = None
            for i in range(exec_buy_index, total_datas[-1]['index'] + 1):
@@ -79,7 +79,7 @@
        async_log_util.error(logger_debug, f"真实下单位置(影子单撤单)出错:{code} - {str(e)}")
    exec_data = total_datas[exec_buy_index]
    THRESH_MS = 20 if code.find('00') == 0 else 100
    THRESH_MS = 20 if tool.is_sz_code(code) else 100
    for i in range(exec_buy_index, total_datas[-1]["index"]):
        if L2DataUtil.time_sub_as_ms(total_datas[i]['val'], exec_data["val"]) >= THRESH_MS:
            return i
@@ -120,7 +120,7 @@
        shadow_place_order_index = d["index"]
        break
    real_place_index_info = None
    estimate_time_space = 1 if code.find("00") == 0 else 2.5
    estimate_time_space = 1 if tool.is_sz_code(code) else 2.5
    if shadow_place_order_index:
        total_datas = l2_data_util.local_today_datas.get(code)
        # 找到不是同一ms的结束
l2/l2_data_manager_new.py
@@ -669,7 +669,7 @@
        @param code:
        @return:
        """
        if code.find("60") == 0:
        if tool.is_sh_code(code):
            # 上证不激进下单
            return None
@@ -998,7 +998,7 @@
        total_data = local_today_datas.get(code)
        # 9:32之前上证开1的票不买
        if code.find("60") == 0 and int(total_data[-1]["val"]["time"].replace(":", "")) <= int("093200"):
        if tool.is_sh_code(code) and int(total_data[-1]["val"]["time"].replace(":", "")) <= int("093200"):
            # 获取涨停时间
            limit_up_data = kpl_data_manager.KPLLimitUpDataRecordManager.record_code_dict.get(code)
            if limit_up_data:
@@ -1057,7 +1057,7 @@
                    return False, False, f"成交位置距离当前位置纯买额({not_cancel_money})小于m值({m_base_val})"
            # 上证下单需要有成交大单(包含主动买与被动买)或者挂买的大单
            if code.find("60") == 0:
            if tool.is_sh_code(code):
                deal_big_order_count = BigOrderDealManager().get_total_buy_count(code)
                if deal_big_order_count < 1:
                    # 统计挂买大单
@@ -1757,7 +1757,7 @@
        # (time_str, round(money), volume, sell_1_info)
        refer_sell_data = cls.__L2MarketSellManager.get_refer_sell_data(code, start_time_str)
        active_buy_blocks = cls.get_active_buy_blocks(code)
        if code.find("60") == 0:
        if tool.is_sh_code(code):
            if refer_sell_data is None:
                # 设置默认卖信息
                refer_sell_data = (start_time_str, 0, 0, (round(float(total_datas[start_index]["val"]["price"]), 2), 0))
@@ -2217,12 +2217,12 @@
        trigger_buy = True
        # 间隔最大时间为3s
        max_space_time_ms = 3 * 1000
        if code.find("00") == 0 and not is_at_limit_up:
        if tool.is_sz_code(code) and not is_at_limit_up:
            # 深证非板上放量
            max_space_time_ms = 1 * 1000
        # 上证的间隔时间为1s
        if code.find("60") == 0:
        if tool.is_sh_code(code):
            max_space_time_ms = 1 * 1000
        # 不下单的信息
@@ -2319,13 +2319,13 @@
                    # 板上下单需要安全笔数3笔
                    safe_count = 3
                else:
                    if code.find("00") == 0:
                    if tool.is_sz_code(code):
                        # 深证上板
                        safe_count = 2
                    elif code.find("60") == 0:
                    elif tool.is_sh_code(code):
                        # 上证安全笔数为3
                        safe_count = 3
            if code.find("00") == 0:
            if tool.is_sz_code(code):
                money_y = code_volumn_manager.get_reference_volume_as_money_y(code)
                # 大于8亿的安全笔数必须有8笔
                if money_y >= 8:
test/test_code_attribute.py
@@ -27,17 +27,22 @@
    limit_up_price = 14.91
    volumes_data = init_data_util.get_volumns_by_code(code, 150)
    volumes_data = volumes_data[1:]
    volumes = init_data_util.parse_max_volume(volumes_data[:90],
                                              code_nature_analyse.is_new_top(
                                                  limit_up_price,
                                                  volumes_data[:90]) or code_nature_analyse.is_near_top(
    volumes = init_data_util.parse_max_volume(code, volumes_data[:90],
                                              code_nature_analyse.is_new_top(code,
                                                                             limit_up_price,
                                                                             volumes_data[
                                                                             :90]) or code_nature_analyse.is_near_top(
                                                  code,
                                                  limit_up_price,
                                                  volumes_data[:90]))
    print(volumes)
if __name__ == "__main__":
    is_too_high()
    code = "301176"
    volumes_data = init_data_util.get_volumns_by_code(code, 150)
    print(len(volumes_data))
    # is_too_high()
    # code = "601022"
    # volumes_data = init_data_util.get_volumns_by_code(code, 150)
    # volumes_data = volumes_data[0:]
third_data/code_plate_key_manager.py
@@ -93,7 +93,7 @@
            # logger_kpl_block_can_buy.info(f"准备更新精选板块:{code}-{buy_1_price}-{limit_up_price}")
            if limit_up_price and buy_1_price:
                # 处理买1,卖1信息
                pre_close_price = round(float(limit_up_price) / 1.1, 2)
                pre_close_price = round(float(limit_up_price) / tool.get_limit_up_rate(code), 2)
                # 如果涨幅大于7%就读取板块
                price_rate = (buy_1_price - pre_close_price) / pre_close_price
                if price_rate > 0.07:
third_data/data_server.py
@@ -534,7 +534,7 @@
            statistic = {}
            for result in results:
                for c in result[1]:
                    if not tool.is_shsz_code(c):
                    if not tool.is_can_buy_code(c):
                        continue
                    if code and code != c:
                        continue
@@ -717,7 +717,7 @@
                        code = d[0]
                        limit_up_reasons[code] = d[5]
                        codes_set.add(code)
                        if tool.is_shsz_code(code):
                        if tool.is_can_buy_code(code):
                            limit_up_time = time.strftime("%H:%M:%S", time.localtime(d[2]))
                            code_price_manager.Buy1PriceManager().set_limit_up_time(code, limit_up_time)
                    add_codes = codes_set - self.__latest_limit_up_codes_set
@@ -736,7 +736,7 @@
                    if add_codes:
                        for code in add_codes:
                            # 根据涨停原因判断是否可以买
                            if tool.is_shsz_code(code):
                            if tool.is_can_buy_code(code):
                                try:
                                    # 判断是否下单
                                    trade_state = trade_manager.CodesTradeStateManager().get_trade_state(code)
third_data/feed_analysis.py
@@ -17,7 +17,7 @@
    result_list = kpl_util.parseDaBanData(json.dumps({"list": results, "errcode": 0}), kpl_util.DABAN_TYPE_LIMIT_UP)
    target_codes = set()
    for result in result_list:
        if not tool.is_shsz_code(result[0]):
        if not tool.is_can_buy_code(result[0]):
            continue
        if result[4] != '首板':
            continue
third_data/history_k_data_util.py
@@ -122,9 +122,9 @@
    def get_juejin_code_list_with_prefix(cls, codes):
        list = []
        for d in codes:
            if d[0:2] == '00':
            if tool.is_sz_code(d):
                list.append("SZSE.{}".format(d))
            elif d[0:2] == '60':
            elif tool.is_sh_code(d):
                list.append("SHSE.{}".format(d))
        return list
third_data/kpl_block_util.py
@@ -66,7 +66,7 @@
    for k in block_limit_up_dict:
        has_shsz = False
        for b in block_limit_up_dict[k]:
            if b[0].find('00') == 0 or b[0].find('60') == 0:
            if tool.is_can_buy_code(b[0]):
                has_shsz = True
                break
        if not has_shsz:
@@ -146,7 +146,7 @@
        if k[3] == code:
            # 获取当前代码涨停时间
            limit_up_time = int(k[5])
        if shsz and not tool.is_shsz_code(k[3]):
        if shsz and not tool.is_can_buy_code(k[3]):
            continue
        # 剔除高位板
        if k[3] in yesterday_current_limit_up_codes:
@@ -176,7 +176,7 @@
        if k[0] == code:
            # 获取当前代码涨停时间
            limit_up_time = int(k[2])
        if shsz and not tool.is_shsz_code(k[0]):
        if shsz and not tool.is_can_buy_code(k[0]):
            continue
        # 剔除高位板
        if k[0] in yesterday_current_limit_up_codes:
trade/current_price_process_manager.py
@@ -64,8 +64,8 @@
                try:
                    __actualPriceProcessor.save_current_price(code, price,
                                                              gpcode_manager.get_limit_up_price_by_preprice(
                                                                  pricePre) == tool.to_price(
                                                              gpcode_manager.get_limit_up_price_by_preprice(code,
                                                                                                            pricePre) == tool.to_price(
                                                                  decimal.Decimal(d["price"])))
                except Exception as e:
                    logging.exception(e)
trade/huaxin/huaxin_trade_api_server.py
@@ -455,7 +455,7 @@
                                code = d[0]
                                if code in codes:
                                    continue
                                if not tool.is_shsz_code(code):
                                if not tool.is_can_buy_code(code):
                                    continue
                                limit_up_price = gpcode_manager.get_limit_up_price(d[0])
                                if limit_up_price:
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, transaction_progress, \
    l2_data_source_util, cancel_buy_strategy, l2_data_log
from l2.cancel_buy_strategy import GCancelBigNumComputer, \
     DCancelBigNumComputer
    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
@@ -242,11 +242,12 @@
                        list_ = JueJinApi.get_exchanges_codes(["SHSE", "SZSE"])
                        fdatas = []
                        for d in list_:
                            if not tool.is_shsz_code(d["sec_id"]):
                            if not tool.is_can_buy_code(d["sec_id"]):
                                continue
                            if d["sec_level"] != 1:
                                continue
                            if d["pre_close"] * 1.1 > constant.MAX_SUBSCRIPT_CODE_PRICE:
                            if d["pre_close"] * tool.get_limit_up_rate(d["sec_id"]) > constant.MAX_SUBSCRIPT_CODE_PRICE:
                                continue
                            if (d["listed_date"] + datetime.timedelta(
                                    days=100)).timestamp() > datetime.datetime.now().timestamp():
@@ -878,7 +879,7 @@
                if operate == outside_api_command_manager.OPERRATE_SET:
                    # 先手动撤单
                    try:
                        l2_data_manager_new.L2TradeDataProcessor.cancel_buy(code,"手动拉黑")
                        l2_data_manager_new.L2TradeDataProcessor.cancel_buy(code, "手动拉黑")
                    except Exception as e:
                        logger_debug.exception(e)
                    l2_trade_util.forbidden_trade(code, msg="手动加入 trade_server")
@@ -1224,7 +1225,7 @@
        code = data.get("code")
        __start_time = time.time()
        try:
            if not tool.is_shsz_code(code):
            if not tool.is_can_buy_code(code):
                raise Exception("非主板代码")
            # 获取代码基本信息
            # 查询是否想买单/白名单/黑名单/暂不买
@@ -1588,7 +1589,8 @@
                                can_buy_result = CodePlateKeyBuyManager.can_buy(code)
                                if can_buy_result:
                                    if can_buy_result[0]:
                                        fdata['block'] = ",".join([f"{x[0]}-{x[1]+1}({x[2]}&{x[3]-x[2]})" for x in can_buy_result[0]])
                                        fdata['block'] = ",".join(
                                            [f"{x[0]}-{x[1] + 1}({x[2]}&{x[3] - x[2]})" for x in can_buy_result[0]])
                                    else:
                                        if can_buy_result[1]:
                                            if limit_up_data:
@@ -1599,7 +1601,7 @@
                                pass
                            # 获取涨停时间
                            if limit_up_data:
                                fdata['limit_up_time'] =  tool.to_time_str(limit_up_data[2])
                                fdata['limit_up_time'] = tool.to_time_str(limit_up_data[2])
                                # 获取委托队列
                            try:
@@ -1709,7 +1711,7 @@
                bigger_money = l2_data_util_old.get_big_money_val(float(gpcode_manager.get_limit_up_price(code)))
                fdatas = []
                for d in data_list:
                    if d<bigger_money:
                    if d < bigger_money:
                        continue
                    fdatas.append(d)
                results = [output_util.money_desc(d) for d in fdatas]
@@ -1795,7 +1797,8 @@
            if _type == L2TradeSingleDataManager.TYPE_PASSIVE and mode_descs:
                # 可以激进下单且必须是首次下单才能激进
                place_order_count = trade_data_manager.PlaceOrderCountManager().get_place_order_count(code)
                if code.find("00") == 0 and place_order_count == 0 and current_total_sell_data[1] > 500 * 10000 and global_util.zyltgb_map.get(
                if tool.is_sz_code(code) and place_order_count == 0 and current_total_sell_data[
                    1] > 500 * 10000 and global_util.zyltgb_map.get(
                        code) < 50 * 100000000:
                    # 首次下单,自由流通50亿以下,总卖额500w才能激进下单
                    mode_descs.insert(0, "成交触发")
@@ -1820,7 +1823,7 @@
                else:
                    l2_log.debug(code, "激进下单,不满足激进下单条件,无法激进")
            else:
                if code.find("00") != 0:
                if not tool.is_sz_code(code):
                    return
                # 找到最近的大买单
                for i in range(len(total_datas) - 1, -1, -1):
trade/l2_trade_factor.py
@@ -209,7 +209,7 @@
    # 获取m值
    def get_m_val(self):
        base_m = self.get_base_m_val(self.code)
        if self.is_first_place_order(self.code) and self.code.startswith("00"):
        if self.is_first_place_order(self.code) and tool.is_sz_code(self.code):
            base_m = int(base_m * 2)
        rate = self.get_m_val_rate(self.volume_rate_index)
        m = round(base_m * (1 + rate))
trade/trade_huaxin.py
@@ -37,7 +37,7 @@
    async_log_util.info(logger_trade, f"{code} trade_huaxin.order_volume 开始")
    try:
        price = round(float(price), 2)
        if not tool.is_shsz_code(code):
        if not tool.is_can_buy_code(code):
            raise Exception("只支持00开头与60开头的代码下单")
        # 保存下单信息
        shadow_price = tool.get_shadow_price(price)
trade/trade_juejin.py
@@ -66,12 +66,12 @@
def order_volume(code, price, count):
    if not constant.TRADE_ENABLE:
        return
    if not tool.is_shsz_code(code):
    if not tool.is_can_buy_code(code):
        raise Exception("只支持00开头与60开头的代码下单")
    code_str = code
    if code[0:2] == '00':
    if tool.is_sz_code(code):
        code_str = f"SZSE.{code}"
    elif code[0:2] == '60':
    elif tool.is_sh_code(code):
        code_str = f"SHSE.{code}"
    start_time = time.time()
    results = gmapi.order_volume(code_str, count, gmapi.OrderSide_Buy, gmapi.OrderType_Limit, gmapi.PositionEffect_Open,
utils/init_data_util.py
@@ -29,8 +29,8 @@
    return datas
def parse_max_volume(datas, is_new_or_near_top=False):
    result = __parse_max_volume(datas, is_new_or_near_top)
def parse_max_volume(code,  datas, is_new_or_near_top=False):
    result = __parse_max_volume(code, datas, is_new_or_near_top)
    refer_index = result[3]
    # 计算最低价
    refer_price = datas[refer_index]["high"]
@@ -54,11 +54,12 @@
        if datas[refer_index - 1]["volume"] > datas[refer_index]["volume"]:
            refer_index -= 1
    return datas[refer_index]["volume"], datas[refer_index]["volume"], datas[refer_index]['bob'].strftime("%Y-%m-%d"), refer_index
    return datas[refer_index]["volume"], datas[refer_index]["volume"], datas[refer_index]['bob'].strftime(
        "%Y-%m-%d"), refer_index
# 返回:(60天最大量,昨日量,量参考日期,参考量据今交易日数)
def __parse_max_volume(datas, is_new_or_near_top=False):
def __parse_max_volume(code, datas, is_new_or_near_top=False):
    max_volume = 0
    max_volume_date = None
    max_volume_index = None
@@ -70,7 +71,7 @@
            if i >= len(datas):
                break
            item = datas[i]
            limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(item["pre_close"]))
            limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(code, item["pre_close"]))
            if abs(limit_up_price - item["high"]) < 0.001:
                latest_limit_up_index = i
                break
@@ -104,7 +105,7 @@
                max_volume = volume
                max_volume_date = item['bob']
            # 是否有涨停
            limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(item["pre_close"]))
            limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(code, item["pre_close"]))
            # 不看超过60天的涨停
            if abs(limit_up_price - item["high"]) < 0.01 and i <= 59:
                # 涨停
utils/tool.py
@@ -312,11 +312,26 @@
        return False, None
# 是否为主板代码
def is_shsz_code(code):
    if code.find("00") == 0 or code.find("60") == 0:
def is_can_buy_code(code):
    if code.find("00") == 0 or code.find("60") == 0 or code.find("30") == 0:
        return True
    return False
def get_limit_up_rate(code):
    # 获取涨停倍数
    if code.find("00") == 0 or code.find("60") == 0:
        return 1.1
    else:
        return 1.2
def get_limit_down_rate(code):
    # 获取涨停倍数
    if code.find("00") == 0 or code.find("60") == 0:
        return 0.9
    else:
        return 0.8
def get_thread_id():
@@ -338,5 +353,45 @@
    return count
# 深证
MARKET_TYPE_SZSE = 1
# 上证
MARKET_TYPE_SSE = 0
# 未知
MARKET_TYPE_UNKNOWN = -1
def get_market_type(code):
    """
    根据股票代码
    :param code:
    :return:
    """
    if code.find("00") == 0 or code.find("30") == 0 or code.find("12") == 0:
        return MARKET_TYPE_SZSE
    elif code.find("60") == 0 or code.find("68") == 0 or code.find("11") == 0:
        return MARKET_TYPE_SSE
    else:
        return MARKET_TYPE_UNKNOWN
def is_sh_code(code):
    """
    是否是上证
    @param code:
    @return:
    """
    return get_market_type(code) == MARKET_TYPE_SSE
def is_sz_code(code):
    """
    是否是深证
    @param code:
    @return:
    """
    return get_market_type(code) == MARKET_TYPE_SZSE
if __name__ == "__main__":
    print(to_time_with_ms("11:29:50", 15))
    print(is_sz_code("0000"))