strategy/buying_strategy.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
strategy/data_cache.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
strategy/market_sentiment_analysis.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
utils/tool.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
strategy/buying_strategy.py
@@ -377,7 +377,7 @@ 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()}") 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(), @@ -466,14 +466,6 @@ 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)}") # 调用下单方法下单 # 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( @@ -564,16 +556,12 @@ 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()}") 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) # # 将有强度买入次数自加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( @@ -673,15 +661,6 @@ 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( @@ -699,8 +678,7 @@ ''' 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: 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( strategy/data_cache.py
@@ -259,6 +259,8 @@ TSXV_open_growth = 0 # 大盘指数情绪预期分数 index_trend_expectation_score = 0 # 理想交易行情比率分 满分=1 ideal_trading_market_score = 1 # 可以板上盯卖的代码 LIMIT_UP_SELL_CODES = set() strategy/market_sentiment_analysis.py
@@ -734,6 +734,9 @@ for i, signal in enumerate(signals, 1): logger.info(f"信号{i}: {signal}") # 只有在开盘时具体计算 计划下单金额 if data_cache.OPENING_TIME < now_time < data_cache.NOON_MARKET_TIME: # 理想交易行情分数【评估当前行情是否有利于低吸策略取得更高抓板率的分数(是否是理想的交易行情)】 ideal_trading_market_score = 1 # 33分是个两级分化阶梯不好,目前不好拿捏,暂时不用 @@ -765,29 +768,31 @@ # usefulMoney * 0.9 * low_emotion_mood_ratio / Unfinished_opening_plan_number) # 除以3应该是一个常量,如果以Unfinished_opening_plan_number,会出现float division by zero # 如果不为空 或 计划金额为默认值,那么就计算第一次计划金额,并固定记录下来 if not data_cache.today_planned_order_amount or data_cache.today_planned_order_amount <= 0: # 如果今日计划下单数量不为空 或 计划金额为默认值,那么就实时计算第一次计划金额,并固定记录下来 if not data_cache.today_planned_order_amount or data_cache.today_first_planned_order_amount <= 0: data_cache.today_planned_order_amount = usefulMoney * 0.95 * ideal_trading_market_score / 3 logger.info(f"第一次计划下单金额==={data_cache.today_planned_order_amount}元") logger.info(f"第一次实时计算计划下单金额==={data_cache.today_planned_order_amount}元") # 老的计算方案先后顺序方法 # 开仓计划运行时间段 if data_cache.OPENING_TIME < now_time < data_cache.NOON_MARKET_TIME: # # 如果一日三仓的计划还未完成 且 首次开仓金额为0 if Unfinished_opening_plan_number != 0 and data_cache.today_first_planned_order_amount <= 0: # 如果GUI看盘手动设置了具体的下单金额【data_cache.BUY_MONEY_PER_CODE 中默认值为-1,只有当GUI看盘手动设置了并提交才会>=0】,就按照GUI设置的金额下单。否则就按照评分策略的金额下单, # if data_cache.BUY_MONEY_PER_CODE >= 0: # data_cache.today_planned_order_amount = data_cache.BUY_MONEY_PER_CODE # logger.info(f"采用GUI设置方式=》今日计划下单金额:{data_cache.today_planned_order_amount}") # else: # # 如果今日还没有一个新增仓位,就不停计算更新计划金额 # if data_cache.OPENING_TIME < now_time < data_cache.NOON_MARKET_TIME: # # # 如果一日三仓的计划还未完成 且 首次开仓金额为0 # if Unfinished_opening_plan_number != 0 and data_cache.today_first_planned_order_amount <= 0: # # 如果GUI看盘手动设置了具体的下单金额【data_cache.BUY_MONEY_PER_CODE 中默认值为-1,只有当GUI看盘手动设置了并提交才会>=0】,就按照GUI设置的金额下单。否则就按照评分策略的金额下单, # # if data_cache.BUY_MONEY_PER_CODE >= 0: # # data_cache.today_planned_order_amount = data_cache.BUY_MONEY_PER_CODE # # logger.info(f"采用GUI设置方式=》今日计划下单金额:{data_cache.today_planned_order_amount}") # # else: # # # 如果今日还没有一个新增仓位,就不停计算更新计划金额 # # if addition_position_number > 0: # # data_cache.today_planned_order_amount = data_cache.opening_strategy_results # # logger.info(f"采用开仓策略计算方式=》今日计划下单金额:{data_cache.today_planned_order_amount}") # if addition_position_number > 0: # data_cache.today_planned_order_amount = data_cache.opening_strategy_results # logger.info(f"采用开仓策略计算方式=》今日计划下单金额:{data_cache.today_planned_order_amount}") if addition_position_number > 0: # 下过一次单过后再计算动态下单金额 data_cache.today_first_planned_order_amount = float( data_cache.today_planned_order_amount) logger.info( f"采用开仓策略计算方式--》今日(首个)新增持仓产生,将实时计算金额赋值给首笔持仓金额=》今日计划下单金额:{data_cache.today_planned_order_amount}") # # 下过一次单过后再计算动态下单金额 # data_cache.today_first_planned_order_amount = float( # data_cache.today_planned_order_amount) # logger.info( # f"采用开仓策略计算方式--》今日(首个)新增持仓产生,将实时计算金额赋值给首笔持仓金额=》今日计划下单金额:{data_cache.today_planned_order_amount}") except Exception as error: logger_debug.exception(error) utils/tool.py
@@ -304,7 +304,7 @@ price1 = math.ceil(price1 * 1000) / 1000 else: price1 = math.ceil(price1 * 100) / 100 price2 = price + 0.1 price2 = price + 0.05 return max(price1, price2)