| | |
| | | while True: |
| | | try: |
| | | if data_cache.position_automatic_management_switch is True: |
| | | # 初始化分时市场情绪分数列表数据列表 |
| | | time_sharing_market_strong_dirt = {} |
| | | now = datetime.datetime.now() # 获取本机时间 |
| | | # 获取大盘综合强度分数 |
| | | data_cache.real_time_market_strong = get_market_strong() |
| | | # data_cache.time_sharing_market_strong_dirt = time_sharing_market_strong_dirt.update({now: data_cache.real_time_market_strong}) |
| | | logger.info(f"大盘行情情绪综合强度 [分数]==={data_cache.real_time_market_strong}分") |
| | | usefulMoney = data_cache.account_finance_dict[0].get('usefulMoney', 0) |
| | | logger.info(f"账户可用资金==={usefulMoney}元") |
| | | # 低迷情绪比例 |
| | | low_emotion_mood_emotion = 1 |
| | | if data_cache.real_time_market_strong <= 33: |
| | | low_emotion_mood_emotion = 0.1 |
| | | # 获取计算今天新增的持仓数量 |
| | | addition_position_number = len(data_cache.addition_position_symbols_set) |
| | | # 定义一个今日的剩余新增持仓数量的变量 |
| | | Unfinished_opening_plan_number = 3 - addition_position_number |
| | | # 根据账户可用金额 计算今日计划下单金额 |
| | | # (账户可用金额/今日最大新增持仓票数) * (大盘综合强度分数 * 0.01) |
| | | data_cache.today_planned_order_amount = (usefulMoney * low_emotion_mood_emotion / Unfinished_opening_plan_number) * (data_cache.real_time_market_strong * 0.01) |
| | | logger.info(f"低迷情绪比例===={low_emotion_mood_emotion}") |
| | | now_time = datetime.datetime.now().strftime("%H:%M:%S") |
| | | if data_cache.server_restart_time < now_time < data_cache.update_data_time: |
| | | # 获取大盘综合强度分数 |
| | | data_cache.real_time_market_strong = get_market_strong() |
| | | # data_cache.time_sharing_market_strong_dirt = time_sharing_market_strong_dirt.update({now: data_cache.real_time_market_strong}) |
| | | logger.info(f"大盘行情情绪综合强度 [分数]==={data_cache.real_time_market_strong}分") |
| | | usefulMoney = data_cache.account_finance_dict[0].get('usefulMoney', 0) |
| | | logger.info(f"账户可用资金==={usefulMoney}元") |
| | | # 低迷情绪比例 |
| | | low_emotion_mood_emotion = 1 |
| | | if data_cache.real_time_market_strong <= 33: |
| | | low_emotion_mood_emotion = 0.1 |
| | | logger.info(f"低迷情绪比例===={low_emotion_mood_emotion}") |
| | | # 获取计算今天新增的持仓数量 |
| | | addition_position_number = len(data_cache.addition_position_symbols_set) |
| | | # 定义一个今日的剩余新增持仓数量的变量 |
| | | Unfinished_opening_plan_number = 3 - addition_position_number |
| | | if Unfinished_opening_plan_number != 0: |
| | | # 根据账户可用金额 计算今日计划下单金额 |
| | | # (账户可用金额/今日最大新增持仓票数) * (大盘综合强度分数 * 0.01) |
| | | data_cache.today_planned_order_amount = (usefulMoney * low_emotion_mood_emotion / Unfinished_opening_plan_number) * (data_cache.real_time_market_strong * 0.01) |
| | | |
| | | except Exception as error: |
| | | logger.error(f"获取实时大盘行情情绪综合强度[分数] 函数报错: {error}") |
| | | finally: |