| | |
| | | # from datetime import time |
| | | # from datetime import timedelta |
| | | import time |
| | | |
| | | import constant |
| | | import utils.tool |
| | | from log_module import async_log_util |
| | | from log_module.log import logger_kpl_jingxuan_in, logger_common |
| | |
| | | from strategy import basic_methods |
| | | from strategy import account_management |
| | | from strategy import order_methods |
| | | from strategy.forbidden_plates_manager import ForbiddenPlatesManager |
| | | from strategy.order_methods import TodayBuyCodeManager |
| | | |
| | | from utils import tool, huaxin_util |
| | | |
| | |
| | | # 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"]): |
| | | 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: |
| | |
| | | # # 如果没有找到,打印提示信息 |
| | | # print(f"没有在概念缓存列表中找到:{symbol_to_search}。") |
| | | |
| | | # 声明要检查过滤不可用的概念板块名称常量 【代表着 是否有无概念及跟随概念的可能性(有明显个股增长特性的不可跟随)】 |
| | | check_plate_list = {'无', 'ST摘帽', 'ST板块', '超跌', '次新股', '北交所', '科创板', |
| | | '年报增长', '年报预增', '并购重组', '股权转让', '送转填权', '高送转', '壳资源', '资产管理', '举牌', |
| | | '专用设备'} |
| | | # 声明要检查过滤不可用的概念板块名称常量 【代表着 是否有无概念及跟随概念的可能性(有明显个股独特增长特性的不可跟随,因为概念本身是宽泛的,许多不同概念的个股都有这个概念)】 |
| | | # check_plate_list = constant.check_plate_list | set(ForbiddenPlatesManager().list_plates()) |
| | | check_plate_list = constant.check_plate_list |
| | | |
| | | # 查询当前个股的代码是否在板块强度个股列表中(低吸优选目标) |
| | | strength_list_have_it = False # 是否有强度赋初值 |
| | |
| | | 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}") |
| | | async_log_util.info(logger, |
| | | f"单一板块内瞬时拉升数为:{len(values)},分别为===={values}") |
| | | # 如果子列表长度大于1且第二个元素包含 当前进入涨幅视界的symbol_code |
| | | strength_list_have_it = True |
| | | strength_plate = correlation_plate_list |
| | |
| | | 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}%。") |
| | | |
| | | 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 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} 亿。") |
| | | elif now_time <= datetime.time(9, 30, 5).strftime("%H:%M:%S"): |
| | | 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}%。") |
| | | elif limit_up_day < 1 and tick_growth < 1: |
| | | 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中的第二个和第三个元素 |
| | | elif limit_up_day > 6 and any( |
| | | 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}") |
| | | elif k_line_data[0]['attribute'] in data_cache.frying_plate_type: |
| | | return |
| | | if 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: |
| | | return |
| | | if 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: |
| | | 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"【不利】昨日高开低走 且 放量下跌,不买!!") |
| | | elif k_line_data[0]['attribute'] == 'down_down' and k_line_data[0][ |
| | | 'today_volume_shape'] == 'increases_down': |
| | | if k_line_data[0]['attribute'] == 'down_down' and k_line_data[0]['today_volume_shape'] == 'increases_down': |
| | | logger_info(f"【不利】昨日低开低走 且 放量下跌,不买!!") |
| | | elif throwing_pressure_position[0] is True: |
| | | 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}") |
| | | elif throwing_pressure_position[1] is True: |
| | | 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}") |
| | | elif throwing_pressure_position[2] is True: |
| | | 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}") |
| | | elif ( |
| | | 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}") |
| | | elif ( |
| | | free_market_value == 0 or free_market_value == 0.0) and free_market_value > 100 and L2_found_big_order is False: |
| | | 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}") |
| | | elif len(intersection_plate) > 0: |
| | | 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}") |
| | | elif data_cache.have_plate_buy_times >= 3: |
| | | logger_info(f"【不利】有概念买入已经 3 次了!不买了!!公司名称:{k_line_data[0]['sec_name']},") |
| | | elif len(data_cache.addition_position_symbols_set) >= 3: |
| | | logger_info(f"【不利】当日已经买了3只票!不买了!!公司名称:{k_line_data[0]['sec_name']},") |
| | | elif now_time < data_cache.OPENING_TIME or now_time > data_cache.NOON_MARKET_TIME: |
| | | 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"************************************************【有概念有强度指标下单】************************************************") |
| | | 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)}") |
| | | logger_info( |
| | | f"大盘综合强度分数:{data_cache.real_time_market_strong},大盘指数情绪预期分数==={data_cache.index_trend_expectation_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}") |
| | | f"【{k_line_data[0]['sec_name']}】交易成功!持仓集合:{data_cache.position_symbols_set}") |
| | | # 传给GUI显示 |
| | | 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: |
| | |
| | | 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} 亿。") |
| | | elif now_time <= datetime.time(9, 30, 5).strftime("%H:%M:%S"): |
| | | 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}%。") |
| | | elif now_time <= datetime.time(9, 35, 00).strftime("%H:%M:%S"): |
| | | 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}%。") |
| | | elif today_growth < 3: |
| | | return |
| | | if today_growth < 3: |
| | | logger_info( |
| | | f"【不利】当日当时涨幅小于3%,信心不足,不太可能有强度,不买!瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%,瞬时涨幅: {tick_growth:.2f}%,当日当时涨幅:{today_growth}%。") |
| | | elif limit_up_day < 1 and tick_growth < 1: |
| | | 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中的第二个和第三个元素 |
| | | elif limit_up_day > 6 and any( |
| | | 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}") |
| | | elif k_line_data[0]['attribute'] in data_cache.frying_plate_type: |
| | | return |
| | | if 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: |
| | | return |
| | | if 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: |
| | | return |
| | | if 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"【不利】昨日高开低走 且 放量下跌,不买!!") |
| | | elif k_line_data[0]['attribute'] == 'down_down' and k_line_data[0][ |
| | | 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"【不利】昨日低开低走 且 放量下跌,不买!!") |
| | | elif throwing_pressure_position[0] is True: |
| | | 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}") |
| | | elif throwing_pressure_position[1] is True: |
| | | 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}") |
| | | elif throwing_pressure_position[2] is True: |
| | | 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}") |
| | | elif ( |
| | | 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}") |
| | | elif len(intersection_plate) > 0: |
| | | 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}") |
| | | elif data_cache.have_plate_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"【不利】当日已经买了3只票!不买了!!公司名称:{k_line_data[0]['sec_name']},") |
| | | elif now_time < data_cache.OPENING_TIME or now_time > data_cache.NOON_MARKET_TIME: |
| | | 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"************************************************【有概念无强度指标下单】************************************************") |
| | | f"【{k_line_data[0]['sec_name']}】交易成功!持仓集合:{data_cache.position_symbols_set}") |
| | | # 传给GUI显示 |
| | | 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"最新价: {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)}") |
| | | # 调用下单方法下单 |
| | | # order_methods.buy_order_by_value(symbol, 1000, |
| | | # k_line_data[0]['sec_name'], |
| | | # current_price) |
| | | # # 将有概念买入次数自加1 |
| | | # data_cache.have_plate_buy_times += 1 |
| | | # # 将买入个股的当时概念添加到全局变量中存储 |
| | | # data_cache.bought_plate.extend(limit_up_plate_included_list) |
| | | # 检测持仓代码集合中有无下单个股,才认为交易成功 |
| | | 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}") |
| | | f"已成交股票详情列表:{data_cache.purchased_stocks_details_list} ") |
| | | ''' |
| | | 无概念 有强度视界 |
| | | ''' |
| | | if len(limit_up_plate_included) == 0 or limit_up_plate_included.issubset( |
| | | check_plate_list) is True: |
| | | # logger_info(f"【无概念】") |
| | | # logger_info(f"【无概念 或 概念在屏蔽概念组中】") |
| | | if strength_list_have_it is True: |
| | | logger_info( |
| | | f"【{k_line_data[0]['sec_name']}】--------------------------------------------------------------------------------------------------------[有强度视界]") |
| | |
| | | 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 < 1: |
| | | 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: |
| | | if tick_growth >= 1 and today_growth >= 1: |
| | | logger_info( |
| | | f"【有强度 有小量换大涨幅 有强拉】瞬时涨幅 > 1% !瞬时涨幅:{round(tick_growth, 2)}%") |
| | | 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中的第二个和第三个元素 |
| | | elif limit_up_day > 6 and any( |
| | | 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: |
| | | 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 k_line_data[0]['attribute'] in data_cache.frying_plate_type: |
| | | return |
| | | if 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: |
| | | return |
| | | if 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: |
| | | return |
| | | if 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': |
| | | 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"【不利】昨日高开低走 且 放量下跌,不买!!") |
| | | elif k_line_data[0]['attribute'] == 'down_down' and k_line_data[0]['today_volume_shape'] == 'increases_down': |
| | | logger_info( |
| | | f"【不利】昨日低开低走 且 放量下跌,不买!!") |
| | | elif throwing_pressure_position[0] is True: |
| | | # 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}") |
| | | elif throwing_pressure_position[1] is True: |
| | | 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}") |
| | | elif throwing_pressure_position[2] is True: |
| | | 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}") |
| | | elif ( |
| | | free_market_value == 0 or free_market_value == 0.0) and free_market_value < 6: |
| | | 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}") |
| | | elif have_leading_increase is False: |
| | | logger_info( |
| | | f"【不利】有强度的板块中没有发现领涨次数!不买!! 公司名称:{k_line_data[0]['sec_name']},最新价: {current_price}") |
| | | elif (free_market_value == 0 or free_market_value == 0.0) and free_market_value > 100 and L2_found_big_order is False: |
| | | 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}") |
| | | elif data_cache.have_strength_buy_times >= 1: |
| | | logger_info(f"【不利】有强度买入 1 次了!不买了!!公司名称:{k_line_data[0]['sec_name']},") |
| | | elif len(data_cache.addition_position_symbols_set) >= 3: |
| | | logger_info(f"【不利】当日已经买了3只票!不买了!!公司名称:{k_line_data[0]['sec_name']},") |
| | | elif now_time < data_cache.OPENING_TIME or now_time > data_cache.NOON_MARKET_TIME: |
| | | 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"************************************************【有强度有强拉指标下单】************************************************") |
| | | f"【{k_line_data[0]['sec_name']}】交易成功!持仓集合:{data_cache.position_symbols_set}") |
| | | # 传给GUI显示 |
| | | purchased_stock_details = { |
| | | "name": k_line_data[0]['sec_name'], |
| | | "policy_name": "无概念有强度策略分支", |
| | | "plate_name": strength_plate, |
| | | "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"最新价: {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.real_time_market_strong},大盘指数情绪预期分数==={data_cache.index_trend_expectation_score}分,设想的下单金额:{get_order_money()}") |
| | | # 调用下单方法下单 |
| | | order_methods.buy_order_by_value(symbol, |
| | | get_order_money(), |
| | | k_line_data[0]['sec_name'], |
| | | current_price) |
| | | # # 将有强度买入次数自加1 |
| | | # data_cache.have_strength_buy_times += 1 |
| | | # # 将买入个股的当时概念添加到全局变量中存储 |
| | | # data_cache.bought_plate.extend(strength_plate) |
| | | # 检测持仓代码集合中有无下单个股,才认为交易成功 |
| | | 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}") |
| | | f"已成交股票详情列表:{data_cache.purchased_stocks_details_list} ") |
| | | ''' |
| | | 无概念无强度 有小量换大涨幅度视界 |
| | | ''' |
| | |
| | | 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: |
| | | 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( |
| | |
| | | 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']},") |
| | | 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']},") |
| | |
| | | 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}") |
| | | # buying_ratio = basic_methods.maximum_buying_ratio(len(data_cache.addition_position_symbols_set)) |
| | | # 调用下单方法下单 |
| | | # order_methods.buy_order_by_value(symbol, 1000, |
| | | # k_line_data[0]['sec_name'], |
| | | # current_price) |
| | | # # 将有小量换大涨幅买入次数自加1 |
| | | # data_cache.have_small_turn_large_buy_times += 1 |
| | | # # 将买入个股的当时概念添加到全局变量中存储 |
| | | # data_cache.bought_plate.append(k_line_data[0]['sec_name']) |
| | | # 检测持仓代码集合中有无下单个股,才认为交易成功 |
| | | if symbol_code not in data_cache.position_symbols_set: |
| | | logger_info( |
| | |
| | | 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}") |
| | | |
| | | ''' |
| | | 昨日涨停视界,今日连板预期盯视界 |
| | | ''' |
| | |
| | | 'volume'] * 1.5: |
| | | logger_info( |
| | | f"【不利】过于显著票 且 前日或上前日涨停板 当日量还不足昨日量的1.5倍!不买!! 今日当时成交量为昨日等比量的{round(current_volume / k_line_data[0]['volume'], 2)}倍,90天内涨停天数:{limit_up_day}") |
| | | elif len(data_cache.addition_position_symbols_set) >= 3: |
| | | 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: |
| | |
| | | 'volume'] * 1.5: |
| | | logger_info( |
| | | f"【不利】过于显著票 且 上日或上上涨停板 当日量还不足昨日量的1.5倍!不买!! 今日当时成交量为昨日等比量的{round(current_volume / k_line_data[0]['volume'], 2)}倍,90天内涨停天数:{limit_up_day}") |
| | | elif len(data_cache.addition_position_symbols_set) >= 3: |
| | | 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: |