|
@@ -536,19 +536,6 @@ def load_processed_results(result_path):
|
|
|
print(f"加载结果文件时出错: {str(e)}")
|
|
print(f"加载结果文件时出错: {str(e)}")
|
|
|
print(f"错误类型: {type(e)}")
|
|
print(f"错误类型: {type(e)}")
|
|
|
|
|
|
|
|
- # 尝试打印问题行的信息
|
|
|
|
|
- if "line 40" in str(e):
|
|
|
|
|
- print("\n=== 尝试定位问题行 ===")
|
|
|
|
|
- try:
|
|
|
|
|
- with open(result_path, 'r', encoding='utf-8-sig') as f:
|
|
|
|
|
- lines = f.readlines()
|
|
|
|
|
- if len(lines) > 40:
|
|
|
|
|
- print(f"第41行内容: {lines[40]}")
|
|
|
|
|
- if len(lines) > 41:
|
|
|
|
|
- print(f"第42行内容: {lines[41]}")
|
|
|
|
|
- except:
|
|
|
|
|
- print("无法读取文件内容进行调试")
|
|
|
|
|
-
|
|
|
|
|
return pd.DataFrame(), set()
|
|
return pd.DataFrame(), set()
|
|
|
|
|
|
|
|
|
|
|
|
@@ -670,16 +657,41 @@ def is_first_continuous_trade(transaction_df, trade_pair_id, continuous_pair_id)
|
|
|
|
|
|
|
|
def get_user_decision():
|
|
def get_user_decision():
|
|
|
"""
|
|
"""
|
|
|
- 获取用户的开仓决策
|
|
|
|
|
|
|
+ 获取用户的开仓决策和信心指数
|
|
|
|
|
+
|
|
|
|
|
+ 返回:
|
|
|
|
|
+ tuple: (是否开仓, 信心指数)
|
|
|
|
|
+ - 是否开仓: bool
|
|
|
|
|
+ - 信心指数: int (1-3)
|
|
|
"""
|
|
"""
|
|
|
while True:
|
|
while True:
|
|
|
- decision = input("\n是否开仓?请输入 'y' (开仓) 或 'n' (不开仓): ").strip().lower()
|
|
|
|
|
- if decision in ['y', 'yes', '是', '开仓']:
|
|
|
|
|
- return True
|
|
|
|
|
- elif decision in ['n', 'no', '否', '不开仓']:
|
|
|
|
|
- return False
|
|
|
|
|
|
|
+ decision = input("\n是否开仓?请输入 'y,信心指数' (开仓) 或 'n,信心指数' (不开仓)\n" +
|
|
|
|
|
+ "例如: 'y,3' (开仓,高信心) 或 'n,1' (不开仓,低信心)\n" +
|
|
|
|
|
+ "信心指数: 1=低, 2=中, 3=高 (默认为2): ").strip().lower()
|
|
|
|
|
+
|
|
|
|
|
+ # 解析输入
|
|
|
|
|
+ parts = decision.split(',')
|
|
|
|
|
+ decision_part = parts[0].strip()
|
|
|
|
|
+ confidence = 2 # 默认信心指数
|
|
|
|
|
+
|
|
|
|
|
+ # 检查是否提供了信心指数
|
|
|
|
|
+ if len(parts) >= 2:
|
|
|
|
|
+ try:
|
|
|
|
|
+ confidence = int(parts[1].strip())
|
|
|
|
|
+ if confidence not in [1, 2, 3]:
|
|
|
|
|
+ print("信心指数必须是 1、2 或 3,请重新输入")
|
|
|
|
|
+ continue
|
|
|
|
|
+ except ValueError:
|
|
|
|
|
+ print("信心指数必须是数字 1、2 或 3,请重新输入")
|
|
|
|
|
+ continue
|
|
|
|
|
+
|
|
|
|
|
+ # 检查开仓决策
|
|
|
|
|
+ if decision_part in ['y', 'yes', '是', '开仓']:
|
|
|
|
|
+ return True, confidence
|
|
|
|
|
+ elif decision_part in ['n', 'no', '否', '不开仓']:
|
|
|
|
|
+ return False, confidence
|
|
|
else:
|
|
else:
|
|
|
- print("请输入有效的选项: 'y' 或 'n'")
|
|
|
|
|
|
|
+ print("请输入有效的选项: 'y' 或 'n' (可选择性添加信心指数,如 'y,3')")
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
def main():
|
|
@@ -834,8 +846,8 @@ def main():
|
|
|
partial_image_path
|
|
partial_image_path
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- # 7. 获取用户决策
|
|
|
|
|
- user_decision = get_user_decision()
|
|
|
|
|
|
|
+ # 7. 获取用户决策和信心指数
|
|
|
|
|
+ user_decision, confidence_level = get_user_decision()
|
|
|
|
|
|
|
|
# 8. 显示完整K线图
|
|
# 8. 显示完整K线图
|
|
|
print("\n=== 步骤7: 显示完整K线图 ===")
|
|
print("\n=== 步骤7: 显示完整K线图 ===")
|
|
@@ -878,6 +890,7 @@ def main():
|
|
|
'成交价': selected_trade['original_row']['成交价'],
|
|
'成交价': selected_trade['original_row']['成交价'],
|
|
|
'平仓盈亏': selected_trade['profit_loss'],
|
|
'平仓盈亏': selected_trade['profit_loss'],
|
|
|
'用户判定': '开仓' if user_decision else '不开仓',
|
|
'用户判定': '开仓' if user_decision else '不开仓',
|
|
|
|
|
+ '信心指数': confidence_level,
|
|
|
'判定收益': decision_profit,
|
|
'判定收益': decision_profit,
|
|
|
'交易对ID': selected_trade['trade_pair_id'],
|
|
'交易对ID': selected_trade['trade_pair_id'],
|
|
|
'连续交易对ID': selected_trade['continuous_pair_id'],
|
|
'连续交易对ID': selected_trade['continuous_pair_id'],
|
|
@@ -888,6 +901,7 @@ def main():
|
|
|
|
|
|
|
|
print(f"\n=== 训练完成 ===")
|
|
print(f"\n=== 训练完成 ===")
|
|
|
print(f"用户判定: {'开仓' if user_decision else '不开仓'}")
|
|
print(f"用户判定: {'开仓' if user_decision else '不开仓'}")
|
|
|
|
|
+ print(f"信心指数: {confidence_level} ({'低' if confidence_level == 1 else '中' if confidence_level == 2 else '高'})")
|
|
|
if selected_trade['continuous_total_profit'] != 'N/A':
|
|
if selected_trade['continuous_total_profit'] != 'N/A':
|
|
|
print(f"连续交易总盈亏: {profit_to_show:+.2f}")
|
|
print(f"连续交易总盈亏: {profit_to_show:+.2f}")
|
|
|
else:
|
|
else:
|