| | |
| | | if data_cache.real_time_market_strong < 30: |
| | | # 如果大盘综合强度分数小于30,将低迷情绪分数比例设置为0.01,可用资金缩小一百倍 |
| | | ideal_trading_market_score = 0.01 |
| | | if data_cache.real_time_market_strong <= 10: |
| | | ideal_trading_market_score = 0 |
| | | logger.info(f"理想交易行情分数===={ideal_trading_market_score * 100}%") |
| | | |
| | | data_cache.index_trend_expectation_score = index_trend_expectation() |
| | |
| | | logger.info(f"今日的剩余新增持仓数量==={Unfinished_opening_plan_number}") |
| | | usefulMoney = data_cache.account_finance_dict[0].get('usefulMoney', 0) |
| | | logger.info(f"账户可用资金==={usefulMoney}元") |
| | | # 如果一日三仓的计划还未完成 且 未设置过开仓计划金额 |
| | | if Unfinished_opening_plan_number != 0 and data_cache.today_planned_order_amount <= 0: |
| | | # 如果GUI看盘手动设置了具体的下单金额【ata_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: |
| | | # 根据账户可用金额 计算今日计划下单金额 |
| | | # 账户可用金额 默认乘以0.95,永远留一点钱,一方面也冗余一些计算误差 |
| | | # ((大盘综合强度分数 + 大盘指数情绪预期分数) * 0.01) * (账户可用金额 * 0.9 * 极端低迷情绪比例 / 今日最大新增持仓票数) |
| | | # data_cache.today_planned_order_amount = ((data_cache.real_time_market_strong + data_cache.index_trend_expectation_score) * 0.01) * ( |
| | | # usefulMoney * 0.9 * low_emotion_mood_ratio / Unfinished_opening_plan_number) |
| | | data_cache.today_planned_order_amount = usefulMoney * 0.95 * ideal_trading_market_score / Unfinished_opening_plan_number |
| | | logger.info(f"采用开仓策略计算方式=》今日计划下单金额:{data_cache.today_planned_order_amount}") |
| | | # 开仓策略计算结果 |
| | | # 根据账户可用金额 计算今日计划下单金额 |
| | | # 账户可用金额 默认乘以0.95,永远留一点钱,一方面也冗余一些计算误差 |
| | | # ((大盘综合强度分数 + 大盘指数情绪预期分数) * 0.01) * (账户可用金额 * 0.9 * 极端低迷情绪比例 / 今日最大新增持仓票数) |
| | | # data_cache.today_planned_order_amount = ((data_cache.real_time_market_strong + data_cache.index_trend_expectation_score) * 0.01) * ( |
| | | # usefulMoney * 0.9 * low_emotion_mood_ratio / Unfinished_opening_plan_number) |
| | | # 除以3应该是一个常量,如果以Unfinished_opening_plan_number,会出现float division by zero 错误 |
| | | data_cache.today_planned_order_amount = usefulMoney * 0.95 * ideal_trading_market_score / 3 |
| | | # 开仓计划运行时间段 |
| | | 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_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) |
| | | logger.error(f"实时设置计划持仓数量 函数报错: {error}") |