-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
94 lines (77 loc) · 4.2 KB
/
main.py
File metadata and controls
94 lines (77 loc) · 4.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import os
import glob
from datetime import datetime
from analyzer import AdvancedStockAnalyzer
import config
def main():
"""主函数 - 智能选股分析系统入口"""
# 初始化字体配置
config.init_settings()
print("🎯 智能选股分析系统启动")
print("=" * 50)
# 默认路径,可以根据实际情况修改或添加命令行参数解析
data_folder = r"E:\DesktopFiles\量化金融研究平台\股票数据\A股数据\20250715"
if not os.path.exists(data_folder):
print(f"❌ 错误:文件夹 '{data_folder}' 不存在")
print("请确保数据文件夹路径正确,且包含股票CSV文件")
return
csv_files = glob.glob(os.path.join(data_folder, "*.csv"))
if not csv_files:
print(f"❌ 错误:在 '{data_folder}' 中没有找到CSV文件")
print("请确保数据文件夹中包含股票历史数据CSV文件")
return
print(f"📁 数据文件夹: {data_folder}")
print(f"📊 发现 {len(csv_files)} 个CSV文件")
try:
analyzer = AdvancedStockAnalyzer(data_folder)
recommendations, short_term_stocks = analyzer.run_enhanced_analysis()
if not recommendations and not short_term_stocks:
print("❌ 没有找到符合条件的股票")
return
print(f"\n✅ 分析完成!共找到 {len(recommendations)} 只综合推荐股票,{len(short_term_stocks)} 只短线推荐股票")
print("\n📈 综合推荐股票列表:")
print("-" * 50)
for i, stock in enumerate(recommendations, 1):
print(f"\n{i}. {stock['股票名称']} ({stock['股票代码']})")
print(f"综合得分: {stock['综合得分']}")
print(f"基本面得分: {stock['基本面得分']}")
print(f"技术面得分: {stock['技术面得分']}")
print(f"当前价格: ¥{stock['当前价格']:.2f}")
print(f"市值: {stock['市值']/1e8:.1f}亿")
print(f"主要信号: {', '.join(stock['主要信号'])}")
if stock['预测信息']:
print(f"5日预测涨幅: {stock['预测信息']['5日预测涨幅']:+.1f}%")
print(f"15日预测涨幅: {stock['预测信息']['15日预测涨幅']:+.1f}%")
print(f"置信度: {stock['预测信息']['置信度']:.1f}%")
print(f"投资建议: {stock['投资建议']}")
print("-" * 50)
print("\n📈 短线技术信号股票列表:")
print("-" * 50)
for i, stock in enumerate(short_term_stocks, 1):
print(f"\n{i}. {stock['股票名称']} ({stock['股票代码']})")
print(f"综合得分: {stock['综合得分']}")
print(f"基本面得分: {stock['基本面得分']}")
print(f"技术面得分: {stock['技术面得分']}")
print(f"当前价格: ¥{stock['当前价格']:.2f}")
print(f"市值: {stock['市值']/1e8:.1f}亿")
print(f"主要信号: {', '.join(stock['主要信号'])}")
if stock['预测信息']:
print(f"5日预测涨幅: {stock['预测信息']['5日预测涨幅']:+.1f}%")
print(f"15日预测涨幅: {stock['预测信息']['15日预测涨幅']:+.1f}%")
print(f"置信度: {stock['预测信息']['置信度']:.1f}%")
print(f"投资建议: {stock['投资建议']}")
print("-" * 50)
print("\n📄 生成HTML报告...")
html_content = analyzer.generate_html_report(recommendations, short_term_stocks)
output_file = f"stock_analysis_report_{datetime.now().strftime('%Y%m%d_%H%M%S')}.html"
with open(output_file, 'w', encoding='utf-8') as f:
f.write(html_content)
print(f"✅ HTML报告已成功生成:{output_file}")
print("\n💡 使用提示:请在浏览器中打开生成的HTML文件查看详细分析报告")
except Exception as e:
print(f"❌ 分析过程中发生错误: {e}")
import traceback
traceback.print_exc()
print("请检查数据文件格式或联系技术支持")
if __name__ == "__main__":
main()