"""
|
这里就是交易策略模块
|
总览处理各个类型的策略及各个策略的分支逻辑
|
"""
|
|
# import json
|
import datetime
|
# from datetime import time
|
# from datetime import timedelta
|
import time
|
import utils.tool
|
from log_module import async_log_util
|
from log_module.log import logger_kpl_jingxuan_in, logger_common
|
# import dateutil
|
# 引入掘金API
|
# from gm.api import *
|
from strategy import data_cache, L2_data_analysis
|
from strategy import basic_methods
|
from strategy import account_management
|
from strategy import order_methods
|
from strategy.order_methods import TodayBuyCodeManager
|
|
from utils import tool, huaxin_util
|
|
# 获取logger实例
|
logger = logger_common
|
|
|
# 构建获取个股记录下来的实时当日开盘价函数
|
def get_symbol_current_open(symbol):
|
if data_cache.all_stocks_current_open.get(symbol) is not None:
|
return data_cache.all_stocks_current_open[symbol]['current_open']
|
else:
|
return None
|
|
|
# 构建获取个股记录下来的实时当日最高价函数
|
def get_symbol_current_high(symbol):
|
if data_cache.all_stocks_current_high_and_low.get(symbol) is not None:
|
return data_cache.all_stocks_current_high_and_low[symbol]['current_high']
|
else:
|
return None
|
|
|
# 构建获取个股记录下来的实时当日最低价函数
|
def get_symbol_current_low(symbol):
|
if data_cache.all_stocks_current_high_and_low.get(symbol) is not None:
|
return data_cache.all_stocks_current_high_and_low[symbol]['current_low']
|
else:
|
return None
|
|
|
# 构建一个更新当前最新总成交量的对象
|
class VolumeTracker:
|
# 初始化 前一个当前总成交量
|
def __init__(self):
|
self.__previous_current_volume = 0
|
self.__last_deal_volume = 0
|
|
# 更新 当前总成交量的函数
|
def update_current_volume(self, new_current_volume):
|
"""
|
设置最新量
|
:param new_current_volume:
|
:return:
|
"""
|
# 更新previous_current_volume为新的current_volume
|
self.__last_deal_volume = new_current_volume - self.__previous_current_volume
|
self.__previous_current_volume = new_current_volume
|
return self.__last_deal_volume
|
|
def get_last_deal_volume(self):
|
"""
|
获取瞬时成交量
|
:return:
|
"""
|
return self.__last_deal_volume
|
|
def get_previous_current_volume(self):
|
return self.__previous_current_volume
|
|
|
# 创建一个字典来存储每只股票的VolumeTracker实例
|
symbol_volume_trackers = {}
|
|
|
# 更新个股成交量函数
|
def update_symbol_volume(symbol, new_volume):
|
# 确保股票代码在字典中有对应的VolumeTracker实例
|
if symbol not in symbol_volume_trackers:
|
symbol_volume_trackers[symbol] = VolumeTracker()
|
# 检索对应的VolumeTracker实例并更新成交量
|
tracker: VolumeTracker = symbol_volume_trackers[symbol]
|
# 获取上一个交易量
|
# previous_current_volume = tracker.get_previous_current_volume()
|
# 计算顺势交易量
|
last_volume = tracker.update_current_volume(new_volume)
|
# if last_volume:
|
# print(
|
# f"瞬时量变 {symbol}: 上一个:{previous_current_volume} -> 最新:{new_volume} 瞬时成交量 {last_volume}")
|
return last_volume
|
|
|
def logger_info(content):
|
"""
|
日志记录
|
:param content:
|
:return:
|
"""
|
async_log_util.info(logger, content)
|
|
|
# 获取具体的下单金额【具体选用哪一个参数作为下单金额,判断依据有优先级】
|
def get_order_money():
|
"""
|
获取下单金额
|
:return:
|
"""
|
if data_cache.BUY_MONEY_PER_CODE > 0:
|
logger.info(f"采用GUI设置方式=》今日计划下单金额:{data_cache.BUY_MONEY_PER_CODE}")
|
return data_cache.BUY_MONEY_PER_CODE
|
if data_cache.today_first_planned_order_amount > 0:
|
logger.info(f"采用开仓策略首次计算结果=》今日计划下单金额:{data_cache.today_first_planned_order_amount}")
|
return data_cache.today_first_planned_order_amount
|
logger.info(f"采用开仓策略实时计算方式=》今日计划下单金额:{data_cache.today_planned_order_amount}")
|
return data_cache.today_planned_order_amount
|
|
|
# 涨幅视界策略【根据涨幅进入视界为起始的策略】
|
def growth_view_strategy(current_info):
|
symbol_code = current_info[0] # 券商接口为纯数字编号
|
symbol = basic_methods.format_stock_symbol(symbol_code) # 掘金数据来源的股票代码
|
# symbol_code = symbol.split('.')[1] # 将掘金格式的股票代码转化为纯数字类型
|
# pre_close = current_info[1] # 昨日收盘价
|
current_price = current_info[2] # 获取当前最新价
|
current_open = get_symbol_current_open(symbol) # 当日开盘价
|
current_high = get_symbol_current_high(symbol) # 当日当时最高价
|
current_low = get_symbol_current_low(symbol) # 当日当时最低价
|
current_volume = current_info[3] # 当日当时的总成交量
|
current_last_volume = update_symbol_volume(symbol, current_volume) # 获取瞬时交易量
|
# current_amount = current_info[4] # 当日当时的总成交额
|
current_quotes_buy = current_info[5] # 买5档数据
|
current_quotes_sell = current_info[6] # 卖5档数据
|
# current_quotes_buy == [[23.25, 800], [23.24, 1100], [23.23, 1100], [23.22, 2200], [23.21, 2300]]
|
# current_quotes_sell == [[23.27, 500], [23.29, 200], [23.3, 6900], [23.31, 500], [23.32, 200]]
|
current_created_at = current_info[7] # 当前信息创建时间
|
# 如果最新价获取失败,就取买一价
|
if current_price <= 0:
|
current_price = current_quotes_buy[0][0]
|
if type(current_created_at) == int:
|
current_created_at = huaxin_util.convert_time(current_created_at)
|
# 获取不到开盘价就不处理后续操作【此操作还包括了current_high,current_low 也一并处理了】
|
if current_open is None:
|
return
|
# print(f"current_created_at====={current_created_at}")
|
# print(f"current_created_at type====={type(current_created_at)}")
|
|
# 调用涨幅公式计算对应的股票tick瞬时涨幅
|
tick_growth = basic_methods.tick_growth(symbol, current_price)
|
# 在字典K线下的查询当前个股的K线并赋值以便使用
|
k_line_data = data_cache.all_stocks_all_K_line_property_dict.get(symbol, None)
|
if k_line_data is not None:
|
# 调用方法算出当日涨停价
|
today_limit_up_price = basic_methods.limit_up_price(k_line_data[0]['close'])
|
# 调用方法算出当日当时涨幅变量
|
today_growth = basic_methods.intraday_growth(current_price, k_line_data[0]['close'])
|
# 调用方法算出当日开盘涨幅
|
today_open_growth = basic_methods.intraday_growth(current_open, k_line_data[0]['close'])
|
# 由于会存在分时L1数据中最新价为0导致current_low==0的情况,所以当出现这一情况时,将它直接赋值为昨收价(目前没有办法根本解决)
|
if current_low == 0:
|
current_low = k_line_data[0]['close']
|
# logger_info(f"current_low == 0 赋值为K线昨收价")
|
|
# 如果公司名称中不包含["ST", "退市", "退", "XD", "XR", "DR", "N", "C"] 则继续逻辑判断C:次新股
|
if not any(
|
keyword in k_line_data[0]['sec_name'] for keyword in ["ST", "退市", "退", "XD", "XR", "DR", "N", "C"]):
|
# print(f"非ST, 退市, 退, XD, N==={k_line_data[0]['sec_name']} 继续判断")
|
# print(f"{k_line_data[0]['sec_name']} 继续判断")
|
if current_low is not None:
|
deep_low = (current_low - k_line_data[0]['close']) / k_line_data[0]['close'] * 100 # 当日最大跌幅比
|
else:
|
deep_low = 0 # 当日最大跌幅比
|
# logger_info(f"current_low is None or current_low == 0 按照K线昨收价作为当日当时最低价赋值,强行将最大跌幅比赋值为0")
|
# 由于已经把回调的涨停概念数据全局化了,所以直接使用这个数据列表,并且直接去重后列表化
|
limit_up_block_names = list(set(data_cache.limit_up_block_names))
|
# 在循环监测个股瞬时行情时进入涨幅视界的情况 *************************************************************【涨幅视界】********************************************************
|
if tick_growth is not None and tick_growth >= 0.3:
|
async_log_util.info(logger, f"上证指数 开盘涨幅 ====》》》 {round(data_cache.Shanghai_open_growth, 4)}%")
|
async_log_util.info(logger, f"深证指数 开盘涨幅 ====》》》 {round(data_cache.Shenzhen_open_growth, 4)}%")
|
async_log_util.info(logger, f"创业板指 开盘涨幅 ====》》》 {round(data_cache.TSXV_open_growth, 4)}%")
|
now = datetime.datetime.now()
|
async_log_util.info(logger,
|
f"获取时间========================================={current_created_at}=========================================")
|
# 调用安全交易量公式
|
ratios = basic_methods.secure_volume(now)
|
# print(f"ratios==================={ratios} ,")
|
# 查询个股板块中是否包含涨停的概念板块
|
# 要检索的股票代码
|
symbol_to_search = symbol_code
|
# 尝试从股票数据中获取自由市值 # 如果不存在,则使用0作为默认值
|
free_market_value = round(
|
data_cache.all_stocks_plate_dict.get(symbol_to_search, {}).get('free_market_value', 0) / 100000000,
|
2)
|
# print(f"自由市值=========={free_market_value} 亿")
|
# 使用 get 方法安全地获取板块列表,如果股票代码不存在则返回 None 或一个空列表作为默认值
|
stocks_plates = data_cache.all_stocks_plate_dict.get(symbol_to_search, {}).get("plate", [])
|
async_log_util.info(logger, f"【{k_line_data[0]['sec_name']}】概念板块=========={stocks_plates} ")
|
async_log_util.info(logger, f"【大盘当前】涨停概念=========={limit_up_block_names}")
|
# 将获取的板块列表转换为集合,并计算与涨停板块的交集
|
stocks_plates_set = set(stocks_plates)
|
limit_up_plate_set = set(limit_up_block_names)
|
limit_up_plate_included = stocks_plates_set & limit_up_plate_set
|
# 如果在找到匹配的元素,则打印它们
|
# if limit_up_plate_included:
|
# print(f"涨停列表中包含【板块】的概念:{limit_up_plate_included}")
|
# else:
|
# # 如果没有找到,打印提示信息
|
# print(f"没有在概念缓存列表中找到:{symbol_to_search}。")
|
|
# 声明要检查过滤不可用的概念板块名称常量 【代表着 是否有无概念及跟随概念的可能性(有明显个股独特增长特性的不可跟随,因为概念本身是宽泛的,许多不同概念的个股都有这个概念)】
|
check_plate_list = {'无', 'ST摘帽', 'ST板块', '超跌', '次新股', '北交所', '科创板',
|
'年报增长', '年报预增', '并购重组', '股权转让', '送转填权', '高送转', '壳资源',
|
'资产管理', '举牌',
|
'专用设备', '创投'}
|
|
# 查询当前个股的代码是否在板块强度个股列表中(低吸优选目标)
|
strength_list_have_it = False # 是否有强度赋初值
|
have_leading_increase = False # 是否有领涨次数赋初值
|
strength_plate = []
|
market_sift_plate_stock_dict = data_cache.market_sift_plate_stock_dict
|
if market_sift_plate_stock_dict is not None:
|
# 遍历字典的每个键值对
|
for key, values in market_sift_plate_stock_dict.items():
|
# 遍历每个键对应的列表中的列表
|
for stock_list in values:
|
if len(stock_list) > 1 and symbol_code in stock_list[1]:
|
async_log_util.info(logger,
|
f"在板块强度个股列表中找到了 {key}:{k_line_data[0]['sec_name']}。")
|
# 打印概念对应的个股列表
|
# print(f"stock_list=={stock_list}")
|
# 将个股精选的相关两个概念字符串转化为列表
|
correlation_plate_list = stock_list[4].split('、')
|
async_log_util.info(logger,
|
f"【{stock_list[0]}】,当日当时涨幅:{stock_list[2]}%,当时涨速:{stock_list[3]},个股精选相关板块=={correlation_plate_list} ,领涨次数:{stock_list[6]}")
|
# 如果只需要找到一个就停止,可以在这里使用 break
|
if len(values) >= 2:
|
async_log_util.info(logger,
|
f"单一板块内瞬时拉升数为:{len(values)},分别为===={values}")
|
# 如果子列表长度大于1且第二个元素包含 当前进入涨幅视界的symbol_code
|
strength_list_have_it = True
|
strength_plate = correlation_plate_list
|
if stock_list[6] >= 1:
|
async_log_util.info(logger, f"包含有强度的板块中,任意一次领涨次数>=1")
|
have_leading_increase = True
|
'''
|
初始化K线近期显著指标的序号 并找出来,如果没有,则返回空值
|
'''
|
# 调用历史K累计涨停天数函数
|
limit_up_day = basic_methods.count_limit_up_day(k_line_data)
|
# 调用大抛压位计算函数
|
throwing_pressure_position = basic_methods.position_of_throwing_pressure(k_line_data, current_open,
|
current_volume,
|
today_limit_up_price)
|
# print(f"throwing_pressure_position === {throwing_pressure_position}")
|
# 计算瞬时量幅比
|
# 瞬时量幅比 = 瞬时交易量 / 昨日交易量 / 瞬时涨幅
|
last_volume_to_growth_ratio = (round(current_last_volume / 10000, 2) / round(
|
k_line_data[0]['volume'] / 10000, 2)) / (round(tick_growth, 2) / 100)
|
|
async_log_util.info(logger,
|
f"当日当时涨幅:{today_growth}%,当日当时总成交量:{round(current_volume / 10000, 2)}万,昨日的总成交量{round(k_line_data[0]['volume'] / 10000, 2)}万,瞬时成交量:{round(current_last_volume / 10000, 2)}万,瞬时涨幅:{round(tick_growth, 2)}%,瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%")
|
# print(
|
# f"卖一量:{current_quotes[0]['ask_v']},卖二量:{current_quotes[1]['ask_v']},卖三量:{current_quotes[2]['ask_v']},卖四量:{current_quotes[3]['ask_v']},卖五量:{current_quotes[4]['ask_v']}")
|
# print(
|
# f"买一量:{current_quotes[0]['bid_v']},买二量:{current_quotes[1]['bid_v']},买三量:{current_quotes[2]['bid_v']},买四量:{current_quotes[3]['bid_v']},买五量:{current_quotes[4]['bid_v']}")
|
# 委买比是否比委卖强势函数
|
buying_strong = basic_methods.get_buying_strength(current_quotes_buy, current_quotes_sell)
|
# print(f"buying_strong==={buying_strong}")
|
if len(data_cache.bought_plate) > 0:
|
async_log_util.info(logger, f"已买入的概念板块==={data_cache.bought_plate}")
|
# 创建一个已买板块集合
|
bought_plate_set = set(data_cache.bought_plate)
|
# 设定当前时间点
|
now_time = tool.get_now_time_str()
|
'''
|
新多分支条件逻辑视界【概念?强度?强拉?消息?价值?】
|
'''
|
# 进入未持仓视界
|
if symbol_code not in data_cache.position_symbols_set:
|
# 进入当日最低跌幅大于 负三 视界(要排除deep_low最终没有更新出结果的情况)
|
if deep_low > -3 and deep_low is not None:
|
# 进入乐观涨幅区间
|
if 0 <= today_growth <= 6.5:
|
# logger_info(f"进入乐观涨幅区间!公司名称:{k_line_data[0]['sec_name']},当日当时涨幅:{today_growth},当前时间:{current_data['created_at']}")
|
# 调用L2大单记录在否函数检查返回结果
|
L2_found_big_order = L2_data_analysis.find_L2_big_order_of_code(symbol_code)
|
# 进入无高位风险 且 无二次近前高风险等 视界
|
if k_line_data[0]['risk_position'] not in ['recent_high_position_risk',
|
'recent_second_break_near_high_position_risk',
|
'recent_second_break_risk',
|
'recent_monster_second_break_risk']:
|
'''
|
有概念视界
|
'''
|
if len(limit_up_plate_included) != 0 and limit_up_plate_included.issubset(
|
check_plate_list) is False:
|
logger_info(
|
f"【{k_line_data[0]['sec_name']}】--------------------------------------------------------------------------------------------------------[有概念视界]")
|
logger_info(f"包含涨停概念:{limit_up_plate_included}")
|
if len(limit_up_plate_included) >= 3:
|
logger_info(f"包含多个涨停概念:{limit_up_plate_included}")
|
limit_up_plate_included_list = list(limit_up_plate_included)
|
intersection_plate = bought_plate_set.intersection(limit_up_plate_included)
|
if len(intersection_plate) > 0:
|
logger_info(f"重复相交概念==={intersection_plate}")
|
|
logger_info(f"【有概念】(涨停列表中包含自身概念 且 不是唯一包含概念不可用) !最新价: {current_price},,当日当时涨幅:{today_growth}%。")
|
# 有概念有强度视界
|
if strength_list_have_it is True:
|
logger_info(f"【有概念 有强度】出现在板块强度大于2的列表中 瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%,当日当时涨幅:{today_growth}%。")
|
if tick_growth < 0.5 and (free_market_value <= 100 and current_price <= 10):
|
logger_info(f"【有概念 有强度 无强拉】瞬时涨幅 < 0.5% !瞬时涨幅:{round(tick_growth, 2)}%")
|
return
|
if last_volume_to_growth_ratio > 0.8 and (free_market_value <= 40 and current_price <= 20):
|
logger_info(f"【不利】瞬时量幅比> 0.8 且 (小自由市值<40亿 或 最新价小于20元 )!,瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%,自由市值:{free_market_value} 亿。")
|
return
|
if now_time <= datetime.time(9, 30, 5).strftime("%H:%M:%S"):
|
logger_info(
|
f"【不利】早盘第一个tick,瞬时涨幅计算恐有误,不买!瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%,瞬时涨幅: {tick_growth:.2f}%,当日当时涨幅:{today_growth}%。")
|
return
|
if limit_up_day < 1 and tick_growth < 1:
|
logger_info(
|
f"【不利】冷票 且 瞬时涨幅小于 1 !不买!!,瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%,90天内涨停天数:{limit_up_day}")
|
return
|
# for d in k_line_data[1:3] 只检查k_line_data中的第二个和第三个元素
|
if limit_up_day > 6 and any(
|
'attribute' in d and d['attribute'] in data_cache.limit_up_type for d in
|
k_line_data[1:3]) and current_volume <= k_line_data[0]['volume'] * 1.5:
|
logger_info(
|
f"【不利】过于显著票 且 上日或上上涨停板 当日量还不足昨日量的1.5倍!不买!! 今日当时成交量为昨日等比量的{round(current_volume / k_line_data[0]['volume'], 2)}倍,最新价: {current_price},,90天内涨停天数:{limit_up_day}")
|
return
|
if k_line_data[0]['attribute'] in data_cache.frying_plate_type:
|
logger_info(f"【不利】昨日炸板!不买!!")
|
return
|
if k_line_data[0]['attribute'] in data_cache.limit_up_type:
|
logger_info(f"【不利】昨日涨停!不买!!")
|
return
|
if k_line_data[0]['attribute'] in data_cache.limit_down_type:
|
logger_info(f"【不利】昨日跌停!不买!!")
|
return
|
# 调用充分交易量函数
|
sufficient_volume = basic_methods.sufficient_volume(current_volume, k_line_data[0]['volume'], today_growth)
|
logger_info(
|
f"【{k_line_data[0]['sec_name']}】当日当时量是否相对涨幅充足?===【{sufficient_volume}】 !当时与昨日成交率占比:{(current_volume / k_line_data[0]['volume'])}%,当日当时总成交量:{round(current_volume / 10000, 2)}万,昨日的总成交量{round(k_line_data[0]['volume'] / 10000, 2)}万,当日当时涨幅:{today_growth}%。")
|
# elif k_line_data[0]['attribute'] == 'up_down' and k_line_data[0]['today_volume_shape'] == 'increases_down':
|
# logger_info(f"【不利】昨日高开低走 且 放量下跌,不买!!")
|
if k_line_data[0]['attribute'] == 'down_down' and k_line_data[0]['today_volume_shape'] == 'increases_down':
|
logger_info(f"【不利】昨日低开低走 且 放量下跌,不买!!")
|
return
|
if throwing_pressure_position[0] is True:
|
# 最近涨停日期:{k_line_data[limit_up_day_min_index]['bob']} ,
|
logger_info(
|
f"【不利】接近涨停大抛压价位 近7日涨停过票 且 当前价和今日涨停价 且 当日量还不足涨停次日量的1.5倍!且 次日最高价小于涨停最高价的1.02倍 不买!! 今日当时成交量为昨日等比量的{round(current_volume / k_line_data[0]['volume'], 2)}倍,90天内涨停天数:{limit_up_day}")
|
return
|
if throwing_pressure_position[1] is True:
|
# 最近涨停日期:{k_line_data[frying_plate_day_min_index]['bob']} ,炸板次日量{round(k_line_data[frying_plate_day_min_index - 1]['volume'], 2)},
|
logger_info(
|
f"【不利】接近炸板大抛压价位 近7日炸板过票 且 当前价和今日涨停价 且 当日量还不足涨停次日量的1.5倍!且 次日最高价小于炸板最高价的1.02倍 不买!! ,90天内涨停天数:{limit_up_day}")
|
return
|
if throwing_pressure_position[2] is True:
|
# 最近涨停日期:{k_line_data[limit_down_day_min_index]['bob']} ,
|
logger_info(
|
f"【不利】接近跌停大抛压价位[跌停日的最高价或最低价] 近7日跌停过票 且 当前价和今日涨停价 且当日量还不足昨日量的1.5倍!不买!!今日当时成交量为昨日等比量的{round(current_volume / k_line_data[0]['volume'], 2)}倍,90天内涨停天数:{limit_up_day}")
|
return
|
if (
|
free_market_value == 0 or free_market_value == 0.0) and free_market_value < 6:
|
logger_info(
|
f"【不利】自由市值小于6亿!不买!! 公司名称:{k_line_data[0]['sec_name']},最新价: {current_price}")
|
return
|
if (
|
free_market_value == 0 or free_market_value == 0.0) and free_market_value > 100 and L2_found_big_order is False:
|
logger_info(
|
f"【不利】自由市值大于100亿,且未发现大单!不买!! 公司名称:{k_line_data[0]['sec_name']},最新价: {current_price}")
|
return
|
if current_volume < k_line_data[0]['volume'] * ratios:
|
logger_info(
|
f"【不利】当日成交量小于昨日成交量的{ratios}倍!不买!!公司名称:{k_line_data[0]['sec_name']},当日当时总成交量:{current_volume},最新价: {current_price}")
|
return
|
data_cache.willing_buy_list.append(k_line_data[0]['sec_name'])
|
logger_info(f"当前有意购买:{k_line_data[0]['sec_name']},有意购买列表:{data_cache.willing_buy_list}")
|
willing_buy_times = basic_methods.count_willing_buy_times(k_line_data[0]['sec_name'])
|
if data_cache.have_plate_buy_times >= 1 and willing_buy_times < 2:
|
logger_info(
|
f"【不利因素】有概念买入已经 1 次,且进入有意购买列表次数<2,不买了!!公司名称:{k_line_data[0]['sec_name']},")
|
# return
|
if len(intersection_plate) > 0:
|
logger_info(
|
f"【不利】同概念只买一次,不买了,公司名称:{k_line_data[0]['sec_name']},重复相交概念==={intersection_plate}")
|
return
|
if data_cache.have_plate_buy_times >= 3:
|
logger_info(
|
f"【不利】有概念买入已经 3 次了!不买了!!公司名称:{k_line_data[0]['sec_name']},")
|
return
|
if len(TodayBuyCodeManager().get_buy_codes()) >= 3:
|
logger_info(
|
f"【不利】当日已经买了3只票!不买了!!公司名称:{k_line_data[0]['sec_name']},")
|
return
|
if now_time < data_cache.OPENING_TIME or now_time > data_cache.NOON_MARKET_TIME:
|
logger_info(f"【不利】不在9:30-13:05时间内!不买!!")
|
return
|
logger_info(
|
f"************************************************【有概念有强度指标下单】************************************************")
|
logger_info(
|
f"最新价: {current_price}, 当日最高价:{current_high},瞬时涨幅: {tick_growth:.2f}%,瞬时量幅比:{last_volume_to_growth_ratio:.2f}%,当日当时涨幅:{today_growth}%,公司名称:{k_line_data[0]['sec_name']},当前时间:{current_created_at},低于水位线:{deep_low:.2f},交易量今日与昨日的比例{round(current_volume / k_line_data[0]['volume'], 2)}")
|
logger_info(
|
f"大盘综合强度分数:{data_cache.real_time_market_strong},理想交易行情分数==={data_cache.ideal_trading_market_score}分,设想的下单金额:{get_order_money()}")
|
# 调用下单方法下单
|
order_methods.buy_order_by_value(symbol,
|
get_order_money(),
|
k_line_data[0]['sec_name'],
|
current_price)
|
# 检测持仓代码集合中有无下单个股,才认为交易成功
|
if symbol_code not in data_cache.position_symbols_set:
|
logger_info(
|
f"【{k_line_data[0]['sec_name']}】交易失败~持仓集合:{data_cache.position_symbols_set}")
|
else:
|
# 将有概念买入次数自加1
|
data_cache.have_plate_buy_times += 1
|
# 将买入个股的当时概念添加到全局变量中存储
|
data_cache.bought_plate.extend(limit_up_plate_included_list)
|
logger_info(
|
f"【{k_line_data[0]['sec_name']}】交易成功!持仓集合:{data_cache.position_symbols_set}")
|
purchased_stock_details = {
|
"name": k_line_data[0]['sec_name'],
|
"policy_name": "有概念有强度策略分支",
|
"plate_name": limit_up_plate_included,
|
"buy_time_trading_volume_ratio": (current_volume / k_line_data[0]['volume']),
|
}
|
data_cache.purchased_stocks_details_list.append(purchased_stock_details)
|
logger_info(f"已成交股票详情列表:{data_cache.purchased_stocks_details_list} ")
|
|
# 有概念无强度视界
|
if strength_list_have_it is False:
|
logger_info(
|
f"【有概念 无强度】未出现在板块强度大于2的列表中 瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%,当日当时涨幅:{today_growth}%。")
|
if tick_growth >= 0.8:
|
logger_info(
|
f"【有概念 无强度 有强拉】瞬时涨幅 > 0.8% !瞬时涨幅:{round(tick_growth, 2)}%")
|
if last_volume_to_growth_ratio > 0.8 and (
|
free_market_value < 40 and current_price < 20):
|
logger_info(
|
f"【不利】瞬时量幅比> 0.8 且 (小自由市值<40亿 或 最新价小于20元 )!,瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%,自由市值:{free_market_value} 亿。")
|
return
|
if now_time <= datetime.time(9, 30, 5).strftime("%H:%M:%S"):
|
logger_info(
|
f"【不利】早盘第一个tick,瞬时涨幅计算恐有误,不买!瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%,瞬时涨幅: {tick_growth:.2f}%,当日当时涨幅:{today_growth}%。")
|
return
|
if now_time <= datetime.time(9, 35, 00).strftime("%H:%M:%S"):
|
logger_info(
|
f"【不利】早盘前5分钟,不做有概念无强度试验,不买!瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%,瞬时涨幅: {tick_growth:.2f}%,当日当时涨幅:{today_growth}%。")
|
return
|
if today_growth < 3:
|
logger_info(
|
f"【不利】当日当时涨幅小于3%,信心不足,不太可能有强度,不买!瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%,瞬时涨幅: {tick_growth:.2f}%,当日当时涨幅:{today_growth}%。")
|
return
|
if limit_up_day < 1 and tick_growth < 1:
|
logger_info(
|
f"【不利】冷票 且 瞬时涨幅小于 1 !不买!!,瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%,90天内涨停天数:{limit_up_day}")
|
return
|
# for d in k_line_data[1:3] 只检查k_line_data中的第二个和第三个元素
|
if limit_up_day > 6 and any(
|
'attribute' in d and d['attribute'] in data_cache.limit_up_type
|
for d in k_line_data[1:3]) and current_volume <= k_line_data[0][
|
'volume'] * 1.5:
|
logger_info(
|
f"【不利】过于显著票 且 上日或上上涨停板 当日量还不足昨日量的1.5倍!不买!! 今日当时成交量为昨日等比量的{round(current_volume / k_line_data[0]['volume'], 2)}倍,最新价: {current_price},,90天内涨停天数:{limit_up_day}")
|
return
|
if k_line_data[0]['attribute'] in data_cache.frying_plate_type:
|
logger_info(f"【不利】昨日炸板!不买!!")
|
return
|
if k_line_data[0]['attribute'] in data_cache.limit_up_type:
|
logger_info(f"【不利】昨日涨停!不买!!")
|
return
|
if k_line_data[0]['attribute'] in data_cache.limit_down_type:
|
logger_info(f"【不利】昨日跌停!不买!!")
|
return
|
# 调用充分交易量函数
|
sufficient_volume = basic_methods.sufficient_volume(current_volume, k_line_data[0]['volume'], today_growth)
|
logger_info(
|
f"【{k_line_data[0]['sec_name']}】当日当时量是否相对涨幅充足?===【{sufficient_volume}】 !当时与昨日成交率占比:{(current_volume / k_line_data[0]['volume'])}%,当日当时总成交量:{round(current_volume / 10000, 2)}万,昨日的总成交量{round(k_line_data[0]['volume'] / 10000, 2)}万,当日当时涨幅:{today_growth}%。")
|
if k_line_data[0]['attribute'] == 'up_down' and k_line_data[0]['today_volume_shape'] == 'increases_down':
|
logger_info(f"【不利】昨日高开低走 且 放量下跌,不买!!")
|
return
|
if k_line_data[0]['attribute'] == 'down_down' and k_line_data[0][
|
'today_volume_shape'] == 'increases_down':
|
logger_info(f"【不利】昨日低开低走 且 放量下跌,不买!!")
|
return
|
if throwing_pressure_position[0] is True:
|
# 最近涨停日期:{k_line_data[limit_up_day_min_index]['bob']} ,
|
logger_info(
|
f"【不利】接近涨停大抛压价位 近7日涨停过票 且 当前价和今日涨停价 且 当日量还不足涨停次日量的1.5倍!且 次日最高价小于涨停最高价的1.02倍 不买!! 今日当时成交量为昨日等比量的{round(current_volume / k_line_data[0]['volume'], 2)}倍,90天内涨停天数:{limit_up_day}")
|
return
|
if throwing_pressure_position[1] is True:
|
# 最近涨停日期:{k_line_data[frying_plate_day_min_index]['bob']} ,炸板次日量{round(k_line_data[frying_plate_day_min_index - 1]['volume'], 2)},
|
logger_info(
|
f"【不利】接近炸板大抛压价位 近7日炸板过票 且 当前价和今日涨停价 且 当日量还不足涨停次日量的1.5倍!且 次日最高价小于炸板最高价的1.02倍 不买!! ,90天内涨停天数:{limit_up_day}")
|
return
|
if throwing_pressure_position[2] is True:
|
# 最近涨停日期:{k_line_data[limit_down_day_min_index]['bob']} ,
|
logger_info(
|
f"【不利】接近跌停大抛压价位[跌停日的最高价或最低价] 近7日跌停过票 且 当前价和今日涨停价 且当日量还不足昨日量的1.5倍!不买!!今日当时成交量为昨日等比量的{round(current_volume / k_line_data[0]['volume'], 2)}倍,90天内涨停天数:{limit_up_day}")
|
return
|
if (
|
free_market_value == 0 or free_market_value == 0.0) and free_market_value < 6:
|
logger_info(
|
f"【不利】自由市值小于6亿!不买!! 公司名称:{k_line_data[0]['sec_name']},最新价: {current_price}")
|
return
|
if (
|
free_market_value == 0 or free_market_value == 0.0) and free_market_value > 100 and L2_found_big_order is False:
|
logger_info(
|
f"【不利】自由市值大于100亿,且未发现大单!不买!! 公司名称:{k_line_data[0]['sec_name']},最新价: {current_price}")
|
return
|
if len(intersection_plate) > 0:
|
logger_info(
|
f"【不利】同概念只买一次,不买了,公司名称:{k_line_data[0]['sec_name']},重复相交概念==={intersection_plate}")
|
return
|
if data_cache.have_plate_buy_times >= 1:
|
logger_info(
|
f"【不利】有概念无强度买入已经1次了!不买了!!公司名称:{k_line_data[0]['sec_name']},")
|
return
|
if len(data_cache.addition_position_symbols_set) >= 4:
|
logger_info(
|
f"【不利】当日已经买了3只票!不买了!!公司名称:{k_line_data[0]['sec_name']},")
|
return
|
if now_time < data_cache.OPENING_TIME or now_time > data_cache.NOON_MARKET_TIME:
|
logger_info(f"【不利】不在9:30-13:05时间内!不买!!")
|
return
|
logger_info(
|
f"************************************************【有概念无强度指标下单】************************************************")
|
logger_info(
|
f"最新价: {current_price}, 当日最高价:{current_high},瞬时涨幅: {tick_growth:.2f}%,瞬时量幅比:{last_volume_to_growth_ratio:.2f}%,当日当时涨幅:{today_growth}%,公司名称:{k_line_data[0]['sec_name']},当前时间:{current_created_at},低于水位线:{deep_low:.2f},交易量今日与昨日的比例{round(current_volume / k_line_data[0]['volume'], 2)}")
|
# 检测持仓代码集合中有无下单个股,才认为交易成功
|
if symbol_code not in data_cache.position_symbols_set:
|
logger_info(
|
f"【{k_line_data[0]['sec_name']}】交易失败~持仓集合:{data_cache.position_symbols_set}")
|
else:
|
# 将有概念买入次数自加1
|
data_cache.have_plate_buy_times += 1
|
# 将买入个股的当时概念添加到全局变量中存储
|
data_cache.bought_plate.extend(limit_up_plate_included_list)
|
logger_info(
|
f"【{k_line_data[0]['sec_name']}】交易成功!持仓集合:{data_cache.position_symbols_set}")
|
'''
|
无概念 有强度视界
|
'''
|
if len(limit_up_plate_included) == 0 and limit_up_plate_included.issubset(
|
check_plate_list) is False:
|
# logger_info(f"【无概念】")
|
if strength_list_have_it is True:
|
logger_info(
|
f"【{k_line_data[0]['sec_name']}】--------------------------------------------------------------------------------------------------------[有强度视界]")
|
logger_info(
|
f"【无概念 有强度】出现在板块强度大于2的列表中!瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%,最新价: {current_price},瞬时涨幅:{round(tick_growth, 2)}%,当日当时涨幅:{today_growth}%,当前时间:{current_created_at}。")
|
# logger_info(
|
# f"【强度数据】 == {data_cache.market_sift_plate_stock_dict}")
|
strength_plate_set = set(strength_plate)
|
intersection_plate = bought_plate_set.intersection(strength_plate_set)
|
if len(intersection_plate) > 0:
|
logger_info(f"重复相交强度==={intersection_plate}")
|
if last_volume_to_growth_ratio < 0.8:
|
logger_info(
|
f"【有强度 有小量换大涨幅】瞬时量幅比< 1 !瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%,最新价: {current_price},瞬时涨幅:{round(tick_growth, 2)}%,当日当时涨幅:{today_growth}%,当前时间:{current_created_at}。")
|
if tick_growth >= 1 and today_growth >= 1:
|
logger_info(
|
f"【有强度 有小量换大涨幅 有强拉】瞬时涨幅 >= 1% 且 当日当时涨幅 >=1!瞬时涨幅:{round(tick_growth, 2)}%, 当日当时涨幅:{round(today_growth, 2)}%")
|
if limit_up_day < 1:
|
logger_info(
|
f"【不利】冷票 !不买!!,瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%,90天内涨停天数:{limit_up_day}")
|
return
|
# for d in k_line_data[1:3] 只检查k_line_data中的第二个和第三个元素
|
if limit_up_day > 6 and any(
|
'attribute' in d and d['attribute'] in data_cache.limit_up_type
|
for d in k_line_data[1:3]) and current_volume <= k_line_data[0]['volume'] * 1.5:
|
logger_info(
|
f"【不利】过于显著票 且 上日或上上涨停板 当日量还不足昨日量的1.5倍!不买!! 今日当时成交量为昨日等比量的{round(current_volume / k_line_data[0]['volume'], 2)}倍,90天内涨停天数:{limit_up_day}")
|
return
|
if k_line_data[0]['attribute'] in data_cache.frying_plate_type:
|
logger_info(f"【不利】昨日炸板!不买!!")
|
return
|
if k_line_data[0]['attribute'] in data_cache.limit_up_type:
|
logger_info(f"【不利】昨日涨停!不买!!")
|
return
|
if k_line_data[0]['attribute'] in data_cache.limit_down_type:
|
logger_info(f"【不利】昨日跌停!不买!!")
|
return
|
# 调用充分交易量函数
|
sufficient_volume = basic_methods.sufficient_volume(current_volume, k_line_data[0]['volume'], today_growth)
|
logger_info(
|
f"【{k_line_data[0]['sec_name']}】当日当时量是否相对涨幅充足?===【{sufficient_volume}】 !当时与昨日成交率占比:{(current_volume / k_line_data[0]['volume'])}%,当日当时总成交量:{round(current_volume / 10000, 2)}万,昨日的总成交量{round(k_line_data[0]['volume'] / 10000, 2)}万,当日当时涨幅:{today_growth}%。")
|
# if k_line_data[0]['attribute'] == 'up_down' and k_line_data[0]['today_volume_shape'] == 'increases_down':
|
# logger_info(
|
# f"【不利】昨日高开低走 且 放量下跌,不买!!")
|
# return
|
if k_line_data[0]['attribute'] == 'down_down' and k_line_data[0]['today_volume_shape'] == 'increases_down':
|
logger_info(f"【不利】昨日低开低走 且 放量下跌,不买!!")
|
return
|
if throwing_pressure_position[0] is True:
|
# 最近涨停日期:{k_line_data[limit_up_day_min_index]['bob']} ,
|
logger_info(
|
f"【不利】接近涨停大抛压价位 近7日涨停过票 且 当前价和今日涨停价 且 当日量还不足涨停次日量的1.5倍!且 次日最高价小于涨停最高价的1.02倍 不买!! 今日当时成交量为昨日等比量的{round(current_volume / k_line_data[0]['volume'], 2)}倍,90天内涨停天数:{limit_up_day}")
|
return
|
if throwing_pressure_position[1] is True:
|
# 最近涨停日期:{k_line_data[frying_plate_day_min_index]['bob']} ,炸板次日量{round(k_line_data[frying_plate_day_min_index - 1]['volume'], 2)},
|
logger_info(
|
f"【不利】接近炸板大抛压价位 近7日炸板过票 且 当前价和今日涨停价 且 当日量还不足涨停次日量的1.5倍!且 次日最高价小于炸板最高价的1.02倍 不买!!90天内涨停天数:{limit_up_day}")
|
return
|
if throwing_pressure_position[2] is True:
|
# 最近涨停日期:{k_line_data[limit_down_day_min_index]['bob']} ,
|
logger_info(
|
f"【不利】接近跌停大抛压价位[跌停日的最高价或最低价] 近7日跌停过票 且 当前价和今日涨停价 且当日量还不足昨日量的1.5倍!不买!!今日当时成交量为昨日等比量的{round(current_volume / k_line_data[0]['volume'], 2)}倍,,90天内涨停天数:{limit_up_day}")
|
return
|
if (free_market_value == 0 or free_market_value == 0.0) and free_market_value < 6:
|
logger_info(
|
f"【不利】自由市值小于6亿!不买!! 公司名称:{k_line_data[0]['sec_name']},最新价: {current_price}")
|
return
|
# if have_leading_increase is False:
|
# logger_info(
|
# f"【不利】有强度的板块中没有发现领涨次数!不买!! 公司名称:{k_line_data[0]['sec_name']},最新价: {current_price}")
|
# return
|
if (free_market_value == 0 or free_market_value == 0.0) and free_market_value > 100 and L2_found_big_order is False:
|
logger_info(
|
f"【不利】自由市值大于100亿,且未发现大单!不买!! 公司名称:{k_line_data[0]['sec_name']},最新价: {current_price}")
|
return
|
if data_cache.have_strength_buy_times >= 1:
|
logger_info(
|
f"【不利】有强度买入 1 次了!不买了!!公司名称:{k_line_data[0]['sec_name']},")
|
return
|
if len(TodayBuyCodeManager().get_buy_codes()) >= 3:
|
logger_info(
|
f"【不利】当日已经买了3只票!不买了!!公司名称:{k_line_data[0]['sec_name']},")
|
return
|
if now_time < data_cache.OPENING_TIME or now_time > data_cache.NOON_MARKET_TIME:
|
logger_info(f"【不利】不在9:30-13:05时间内!不买!!")
|
return
|
logger_info(
|
f"************************************************【有强度有强拉指标下单】************************************************")
|
logger_info(
|
f"最新价: {current_price}, 当日最高价:{current_high},瞬时涨幅: {tick_growth:.2f}%,瞬时量幅比:{last_volume_to_growth_ratio:.2f}%,当日当时涨幅:{today_growth}%,公司名称:{k_line_data[0]['sec_name']},当前时间:{current_created_at},低于水位线:{deep_low:.2f},交易量今日与昨日的比例{round(current_volume / k_line_data[0]['volume'], 2)}") # 输出当前价格和3秒涨幅信息
|
logger_info(
|
f"大盘综合强度分数:{data_cache.real_time_market_strong},理想交易行情分数==={data_cache.ideal_trading_market_score}分,设想的下单金额:{get_order_money()}")
|
# 调用下单方法下单
|
order_methods.buy_order_by_value(symbol,
|
get_order_money(),
|
k_line_data[0]['sec_name'],
|
current_price)
|
# 检测持仓代码集合中有无下单个股,才认为交易成功
|
if symbol_code not in data_cache.position_symbols_set:
|
logger_info(
|
f"【{k_line_data[0]['sec_name']}】交易失败~持仓集合:{data_cache.position_symbols_set}")
|
else:
|
# 将有概念买入次数自加1
|
data_cache.have_strength_buy_times += 1
|
# 将买入个股的当时概念添加到全局变量中存储
|
data_cache.bought_plate.extend(strength_plate)
|
logger_info(
|
f"【{k_line_data[0]['sec_name']}】交易成功!持仓集合:{data_cache.position_symbols_set}")
|
'''
|
无概念无强度 有小量换大涨幅度视界
|
'''
|
if len(limit_up_plate_included) == 0 or limit_up_plate_included.issubset(
|
check_plate_list) is True:
|
# logger_info(f"【无概念】")
|
if strength_list_have_it is False:
|
logger_info(
|
f"【{k_line_data[0]['sec_name']}】--------------------------------------------------------------------------------------------------------[小量大涨幅视界]")
|
logger_info(
|
f"【无概念 无强度】未出现在板块强度大于2的列表中!瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%,最新价: {current_price},瞬时涨幅:{round(tick_growth, 2)}%,当日当时涨幅:{today_growth}%。")
|
# logger_info(
|
# f"【强度数据】 == {data_cache.market_sift_plate_stock_dict}")
|
if last_volume_to_growth_ratio < 0.8:
|
logger_info(
|
f"【无概念 无强度 有小量换大涨幅】瞬时量幅比< 0.8 !瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%。")
|
if tick_growth >= 0.8:
|
logger_info(
|
f"【无概念 无强度 有小量换大涨幅 有强拉】瞬时涨幅 > 0.8% !瞬时涨幅:{round(tick_growth, 2)}%")
|
if current_volume < k_line_data[0]['volume'] * ratios:
|
logger_info(
|
f"【不利】今日成交量 < 昨日的{ratios}倍,不买!!公司名称:{k_line_data[0]['sec_name']},今日目前成交量为昨日的{round(current_volume / k_line_data[0]['volume'], 2)}")
|
elif buying_strong is not True and current_volume <= k_line_data[0]['volume'] * ratios and now_time > data_cache.MORN_MARKET_TIME:
|
logger_info(
|
f"【不利】买一量小于卖一量 且 挂买总量小于挂卖总量 且 当日量不足 (9:35后实施)!不买!!公司名称:{k_line_data[0]['sec_name']},自由市值:{free_market_value} 亿,最新价: {current_price}")
|
# logger_info(
|
# f"目前获取的精选板块股票强度数据 == {data_cache.market_sift_plate_stock_dict}")
|
elif current_high - current_price > 0.05:
|
logger_info(
|
f"【不利】当前最新价小于今日最高价!不买!!公司名称:{k_line_data[0]['sec_name']},,最新价: {current_price},,当日最高价:{current_high}")
|
elif limit_up_day < 1 and current_volume <= k_line_data[0][
|
'volume'] * 2:
|
logger_info(
|
f"【不利】冷票 且 (瞬时涨幅小于1 或 瞬时量与昨总量比与瞬时涨幅的比值大于0.8)且 当日量还不足昨日量的1.5倍!不买!! 公司名称:{k_line_data[0]['sec_name']},最新价: {current_price},,90天内涨停天数:{limit_up_day}")
|
# for d in k_line_data[1:3] 只检查k_line_data中的第二个和第三个元素
|
elif limit_up_day > 6 and any(
|
'attribute' in d and d['attribute'] in data_cache.limit_up_type
|
for d in
|
k_line_data[1:3]) and current_volume <= k_line_data[0][
|
'volume'] * 1.5:
|
logger_info(
|
f"【不利】过于显著票 且 上日或上上涨停板 当日量还不足昨日量的1.5倍!不买!! 公司名称:{k_line_data[0]['sec_name']},今日当时成交量为昨日等比量的{round(current_volume / k_line_data[0]['volume'], 2)}倍,最新价: {current_price},,90天内涨停天数:{limit_up_day}")
|
elif k_line_data[0]['attribute'] in data_cache.frying_plate_type:
|
logger_info(f"【不利】昨日炸板!不买!!")
|
elif k_line_data[0]['attribute'] in data_cache.limit_up_type:
|
logger_info(f"【不利】昨日涨停!不买!!")
|
elif k_line_data[0]['attribute'] in data_cache.limit_down_type:
|
logger_info(f"【不利】昨日跌停!不买!!")
|
# elif k_line_data[0]['attribute'] == 'up_down' and k_line_data[0]['today_volume_shape'] == 'increases_down':
|
# logger_info(f"【不利】昨日高开低走 且 放量下跌,不买!!公司名称:{k_line_data[0]['sec_name']}")
|
elif k_line_data[0]['attribute'] == 'down_down' and k_line_data[0][
|
'today_volume_shape'] == 'increases_down':
|
logger_info(
|
f"【不利】昨日低开低走 且 放量下跌,不买!!公司名称:{k_line_data[0]['sec_name']}")
|
elif throwing_pressure_position[0] is True:
|
# 最近涨停日期:{k_line_data[limit_up_day_min_index]['bob']} ,
|
logger_info(
|
f"【不利】近7日涨停过票 且 当前价和今日涨停价 接近涨停大抛压价位 且 当日量还不足涨停次日量的1.5倍!且 次日最高价小于涨停最高价的1.02倍 不买!! 公司名称:{k_line_data[0]['sec_name']},今日当时成交量为昨日等比量的{round(current_volume / k_line_data[0]['volume'], 2)}倍,最新价: {current_price}")
|
elif throwing_pressure_position[1] is True:
|
# 最近涨停日期:{k_line_data[frying_plate_day_min_index]['bob']} ,炸板次日量{round(k_line_data[frying_plate_day_min_index - 1]['volume'], 2)},
|
logger_info(
|
f"【不利】近7日炸板过票 且 当前价和今日涨停价 接近炸板大抛压价位 且 当日量还不足涨停次日量的1.5倍!且 次日最高价小于炸板最高价的1.02倍 不买!! 公司名称:{k_line_data[0]['sec_name']},最新价: {current_price}")
|
elif throwing_pressure_position[2] is True:
|
# 最近涨停日期:{k_line_data[limit_down_day_min_index]['bob']} ,
|
logger_info(
|
f"【不利】近7日跌停过票 且 当前价和今日涨停价 接近跌停大抛压价位[跌停日的最高价或最低价] 且当日量还不足昨日量的1.5倍!不买!! 公司名称:{k_line_data[0]['sec_name']},最新价: {current_price}")
|
elif (
|
free_market_value == 0 or free_market_value == 0.0) and free_market_value < 6:
|
logger_info(
|
f"【不利】自由市值小于6亿!不买!! 公司名称:{k_line_data[0]['sec_name']},最新价: {current_price}")
|
elif data_cache.have_small_turn_large_buy_times >= 1:
|
logger_info(
|
f"【不利】有小量换大涨幅买入已经 1 次了!不买了!!公司名称:{k_line_data[0]['sec_name']},")
|
elif len(data_cache.addition_position_symbols_set) >= 4:
|
logger_info(
|
f"【不利】当日已经买了4只票!不买了!!公司名称:{k_line_data[0]['sec_name']},")
|
elif (
|
data_cache.MORN_MARKET_TIME < now_time < data_cache.NOON_MARKET_TIME) is False or free_market_value < 100 or (
|
today_open_growth < 5 or today_growth < 5):
|
logger_info(
|
f"【不利】不在9:35-13:05时间内!或自由市值小于100亿!或开盘涨幅或当日当时涨幅都小于5%!不买!!")
|
else:
|
logger_info(
|
f"************************************************【小量大涨幅指标】************************************************")
|
logger_info(
|
f"最新价: {current_price}, 当日最高价:{current_high},瞬时涨幅: {tick_growth:.2f}%,当日当时涨幅:{today_growth}%,公司名称:{k_line_data[0]['sec_name']},当前时间:{current_created_at},低于水位线:{deep_low:.2f},交易量今日与昨日的比例{round(current_volume / k_line_data[0]['volume'], 2)}") # 输出当前价格和3秒涨幅信息
|
logger_info(
|
f"目前获取的精选板块股票强度数据 == {data_cache.market_sift_plate_stock_dict}")
|
# 检测持仓代码集合中有无下单个股,才认为交易成功
|
if symbol_code not in data_cache.position_symbols_set:
|
logger_info(
|
f"【{k_line_data[0]['sec_name']}】交易失败~持仓集合:{data_cache.position_symbols_set}")
|
else:
|
# 将有概念买入次数自加1
|
data_cache.have_small_turn_large_buy_times += 1
|
# 将买入个股的当时概念添加到全局变量中存储
|
data_cache.bought_plate.extend(k_line_data[0]['sec_name'])
|
logger_info(
|
f"【{k_line_data[0]['sec_name']}】交易成功!持仓集合:{data_cache.position_symbols_set}")
|
'''
|
昨日涨停视界,今日连板预期盯视界
|
'''
|
if k_line_data[0]['attribute'] in data_cache.limit_up_type:
|
# logger_info(f"昨日涨停")
|
if k_line_data[1]['attribute'] not in data_cache.limit_up_type and k_line_data[2][
|
'attribute'] not in data_cache.limit_up_type:
|
# logger_info(f"前日大前日未涨停")
|
if today_open_growth > 1:
|
logger_info(
|
f"【{k_line_data[0]['sec_name']}】--------------------------------------------------------------------------------------------------------[昨日涨停视界]")
|
logger_info(
|
f"【{k_line_data[0]['sec_name']}】,瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%,最新价: {current_price},,当日当时涨幅:{today_growth}%,当前时间:{current_created_at}")
|
logger_info(f"昨日首板涨停,当日中等以上高开 {today_open_growth}% !")
|
if limit_up_day > 6 and any(
|
'attribute' in d and d['attribute'] in data_cache.limit_up_type for
|
d in k_line_data[1:3]) and current_volume <= k_line_data[0][
|
'volume'] * 1.5:
|
logger_info(
|
f"【不利】过于显著票 且 前日或上前日涨停板 当日量还不足昨日量的1.5倍!不买!! 今日当时成交量为昨日等比量的{round(current_volume / k_line_data[0]['volume'], 2)}倍,90天内涨停天数:{limit_up_day}")
|
elif len(TodayBuyCodeManager().get_buy_codes()) >= 3:
|
logger_info(
|
f"【不利】当日已经买了3只票!不买!!")
|
elif now_time < data_cache.OPENING_TIME or now_time > data_cache.MORN_MARKET_TIME:
|
logger_info(
|
f"【不利】不在9:30-9:35时间内!不买!!")
|
else:
|
# logger_info(
|
# f"************************************************【昨日首板指标下单】************************************************")
|
logger_info(
|
f"最新价: {current_price}, 当日最高价:{current_high},瞬时涨幅: {tick_growth:.2f}%,当日当时涨幅:{today_growth}%,公司名称:{k_line_data[0]['sec_name']},当前时间:{current_created_at},低于水位线:{deep_low:.2f},交易量今日与昨日的比例{round(current_volume / k_line_data[0]['volume'], 2)}") # 输出当前价格和3秒涨幅信息
|
# order_methods.buy_order_by_value(symbol, 10000,k_line_data[0]['sec_name'],today_limit_up_price)
|
logger_info(f"昨日首版涨停,今日高开5%!考虑下叉")
|
'''
|
昨日炸板,今日涨停预期盯视界
|
'''
|
if k_line_data[0]['attribute'] in data_cache.frying_plate_type:
|
# logger_info(
|
# f"昨日炸板!公司名称:{k_line_data[0]['sec_name']},当前时间:{current_data['created_at']}")
|
if k_line_data[0]['attribute'] == 'first_frying_plate':
|
# logger_info(
|
# f"昨日首炸板!公司名称:{k_line_data[0]['sec_name']},当前时间:{current_data['created_at']}")
|
if today_open_growth > 4:
|
logger_info(
|
f"【{k_line_data[0]['sec_name']}】--------------------------------------------------------------------------------------------------------[昨日首炸板视界]")
|
logger_info(
|
f"【{k_line_data[0]['sec_name']}】,瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%,最新价: {current_price},,当日当时涨幅:{today_growth}%,当前时间:{current_created_at}")
|
logger_info(f"昨日首板炸板,当日中等以上高开 {today_open_growth}% !")
|
# 在买票预设时间段 视界
|
if limit_up_day > 6 and any(
|
'attribute' in d and d['attribute'] in data_cache.limit_up_type for
|
d in k_line_data[1:3]) and current_volume <= k_line_data[0][
|
'volume'] * 1.5:
|
logger_info(
|
f"【不利】过于显著票 且 上日或上上涨停板 当日量还不足昨日量的1.5倍!不买!! 今日当时成交量为昨日等比量的{round(current_volume / k_line_data[0]['volume'], 2)}倍,90天内涨停天数:{limit_up_day}")
|
elif len(TodayBuyCodeManager().get_buy_codes()) >= 3:
|
logger_info(
|
f"【不利】当日已经买了3只票!不买!!")
|
elif now_time < data_cache.OPENING_TIME or now_time > data_cache.MORN_MARKET_TIME:
|
logger_info(
|
f"【不利】不在9:30-9:05时间内!不买!!")
|
else:
|
# logger_info(
|
# f"************************************************【昨日首炸板指标下单】************************************************")
|
logger_info(
|
f"最新价: {current_price}, 当日最高价:{current_high},瞬时涨幅: {tick_growth:.2f}%,当日当时涨幅:{today_growth}%,公司名称:{k_line_data[0]['sec_name']},当前时间:{current_created_at},低于水位线:{deep_low:.2f},交易量今日与昨日的比例{round(current_volume / k_line_data[0]['volume'], 2)}") # 输出当前价格和3秒涨幅信息
|
# order_methods.buy_order_by_value(symbol, 10000,k_line_data[0]['sec_name'],today_limit_up_price)
|
logger_info(f"昨日首版炸板,今日高开5%!考虑下叉")
|
'''
|
昨日跌停,今日涨停预期盯视界
|
'''
|
if k_line_data[0]['attribute'] in data_cache.limit_down_type:
|
# logger_info(
|
# f"昨日跌停!公司名称:{k_line_data[0]['sec_name']},当前时间:{current_data['created_at']}")
|
pass
|
else:
|
logger_info(
|
f"当前高位风险 或 其他二次近前高等风险,不买!公司名称:【{k_line_data[0]['sec_name']}】")
|
else:
|
logger_info(
|
f"当日当时涨幅不在预设范围,不买!公司名称:【{k_line_data[0]['sec_name']}】,当日当时涨幅:{round(today_growth, 2)}%")
|
else:
|
logger_info(
|
f"当日最低跌幅低于 -3% ,不买!公司名称:【{k_line_data[0]['sec_name']}】,当日当时最低价:{current_low} 当日当时最大跌幅:{deep_low} ,当日当时最新价:{current_price},买五档:{current_quotes_buy},K线昨收价{k_line_data[0]['close']}")
|
else:
|
logger_info(f"已持仓,不买!公司名称:【{k_line_data[0]['sec_name']}】")
|
# 以下部分主要计算整体的花费时间
|
# 将current_created_at转换为datetime对象,这里假设是今天的日期
|
# 注意:这里使用了datetime.now()来获取当前日期,但你可以根据需要调整
|
created_at = datetime.datetime.strptime(tool.get_now_date_str() + " " + current_created_at,
|
"%Y-%m-%d %H:%M:%S").timestamp()
|
# print(f"created_at===={created_at}")
|
# print(f"created_at type===={type(created_at)}")
|
now_end = time.time()
|
# print(f"now_end===={now_end}")
|
# print(f"now_end type===={type(now_end)}")
|
now_start_to_end = abs(created_at - now_end)
|
logger_info(f"获取到判断花费==={round(now_start_to_end, 2)} 秒")
|
# print(f" now_end=={now_end} created_at=={created_at}")
|
# 设定一个时间阈值(比如9秒)
|
threshold_4 = datetime.timedelta(seconds=4).total_seconds()
|
if now_start_to_end > threshold_4:
|
logger_info(f"获取到判断花费大于4秒啦!!!")
|
threshold_6 = datetime.timedelta(seconds=6).total_seconds()
|
if now_start_to_end > threshold_6:
|
logger_info(f"获取到判断花费大于6秒啦!!!")
|
logger_info(
|
f"完成时间======================================{tool.to_time_str(now_end)}======================================")
|
else:
|
pass
|
# 如果K线数据为空,则不进入后续判断
|
# print(f"代码:{symbol},k_line_data is None,未get到该股的K线属性,或为新股、次新股第一天的时候确实没有历史K线")
|