diff --git a/.gitignore b/.gitignore index 439ab38..d499d7e 100644 --- a/.gitignore +++ b/.gitignore @@ -12,12 +12,6 @@ build/ venv/ .venv/ -# Database files -data/*.db -data/*.db-journal - -# Config files with secrets -config/ai_config.json # Logs *.log diff --git a/app/__pycache__/main.cpython-311.pyc b/app/__pycache__/main.cpython-311.pyc index 53add62..599f6b0 100644 Binary files a/app/__pycache__/main.cpython-311.pyc and b/app/__pycache__/main.cpython-311.pyc differ diff --git a/app/__pycache__/models.cpython-311.pyc b/app/__pycache__/models.cpython-311.pyc index 717c06d..7e08689 100644 Binary files a/app/__pycache__/models.cpython-311.pyc and b/app/__pycache__/models.cpython-311.pyc differ diff --git a/app/api/__pycache__/ai_config.cpython-311.pyc b/app/api/__pycache__/ai_config.cpython-311.pyc index 755c2e9..dafca26 100644 Binary files a/app/api/__pycache__/ai_config.cpython-311.pyc and b/app/api/__pycache__/ai_config.cpython-311.pyc differ diff --git a/app/api/__pycache__/futures_analysis.cpython-311.pyc b/app/api/__pycache__/futures_analysis.cpython-311.pyc index 4291edb..b512e47 100644 Binary files a/app/api/__pycache__/futures_analysis.cpython-311.pyc and b/app/api/__pycache__/futures_analysis.cpython-311.pyc differ diff --git a/app/services/__pycache__/cache.cpython-311.pyc b/app/services/__pycache__/cache.cpython-311.pyc index 61545ad..0dbf75b 100644 Binary files a/app/services/__pycache__/cache.cpython-311.pyc and b/app/services/__pycache__/cache.cpython-311.pyc differ diff --git a/check_ai_models.py b/check_ai_models.py new file mode 100644 index 0000000..130358c --- /dev/null +++ b/check_ai_models.py @@ -0,0 +1,22 @@ +import sqlite3 + +db_path = 'data/futures_analysis.db' + +conn = sqlite3.connect(db_path) + +print('=== AI模型配置 ===') +cursor = conn.execute("SELECT * FROM ai_model_configs") +cols = [desc[0] for desc in cursor.description] +print(f'字段: {cols}') +rows = cursor.fetchall() +print(f'记录数: {len(rows)}') +for row in rows: + print(dict(zip(cols, row))) + +print('\n=== 分析设置 ===') +cursor = conn.execute("SELECT * FROM analysis_settings") +rows = cursor.fetchall() +for row in rows: + print(row) + +conn.close() diff --git a/check_db.py b/check_db.py index 34a7c92..53fca39 100644 --- a/check_db.py +++ b/check_db.py @@ -1,55 +1,32 @@ import sqlite3 import os -from pathlib import Path -db_path = Path(__file__).parent / "data" / "futures_analysis.db" - -print("=" * 60) -print("数据库信息检查") -print("=" * 60) -print(f"数据库路径: {db_path}") -print(f"文件存在: {db_path.exists()}") - -if db_path.exists(): - print(f"文件大小: {db_path.stat().st_size} bytes") - print(f"最后修改: {db_path.stat().st_mtime}") - - conn = sqlite3.connect(str(db_path)) - cursor = conn.cursor() - - # 获取所有表 - cursor.execute("SELECT name FROM sqlite_master WHERE type='table'") - tables = cursor.fetchall() - print(f"\n数据库表 ({len(tables)}):") - for table in tables: - table_name = table[0] - cursor.execute(f"SELECT COUNT(*) FROM {table_name}") +db_path = 'data/futures_analysis.db' + +print(f'数据库文件路径: {os.path.abspath(db_path)}') +print(f'数据库存在: {os.path.exists(db_path)}') + +if os.path.exists(db_path): + print(f'数据库大小: {os.path.getsize(db_path)} 字节') + + conn = sqlite3.connect(db_path) + cursor = conn.execute("SELECT name FROM sqlite_master WHERE type='table'") + tables = [row[0] for row in cursor.fetchall()] + print(f'数据库表列表: {tables}') + + if 'ai_analysis_cache' in tables: + cursor = conn.execute("SELECT COUNT(*) FROM ai_analysis_cache") count = cursor.fetchone()[0] - print(f" - {table_name}: {count} 条记录") - - # 检查AI模型配置 - print("\n" + "=" * 60) - print("AI模型配置检查") - print("=" * 60) - try: - cursor.execute("SELECT id, provider, model_name, is_active, enabled FROM ai_model_configs") - models = cursor.fetchall() - print(f"AI模型数量: {len(models)}") - if models: - for m in models: - print(f" ID: {m[0]}") - print(f" Provider: {m[1]}") - print(f" Model Name: {m[2]}") - print(f" Active: {m[3]}") - print(f" Enabled: {m[4]}") - print() - else: - print(" 没有配置AI模型!") - except sqlite3.OperationalError as e: - print(f" 查询失败: {e}") - + print(f'AI分析记录数: {count}') + + cursor = conn.execute("SELECT id, symbol, created_at FROM ai_analysis_cache ORDER BY created_at DESC LIMIT 5") + records = cursor.fetchall() + print(f'最近5条记录:') + for r in records: + print(f' ID: {r[0]}, 合约: {r[1]}, 时间: {r[2]}') + else: + print('❌ ai_analysis_cache 表不存在!') + conn.close() else: - print("数据库文件不存在!") - -print("=" * 60) + print('❌ 数据库文件不存在!') diff --git a/config/ai_config.json b/config/ai_config.json new file mode 100644 index 0000000..7d74ea5 --- /dev/null +++ b/config/ai_config.json @@ -0,0 +1,22 @@ +{ + "models": [ + { + "model_name": "qwen3.6-plus", + "provider": "bailian", + "api_key": "sk-sp-51d0695ab1114470b913146d21baf68f", + "api_base": "https://coding.dashscope.aliyuncs.com/v1", + "model_id": "qwen3.6-plus", + "temperature": 0.7, + "max_tokens": 2000, + "enabled": true + } + ], + "active_model": "bailian", + "analysis_settings": { + "enable_technical_analysis": true, + "enable_fundamental_analysis": false, + "enable_sentiment_analysis": false, + "risk_tolerance": "medium", + "max_position_pct": 10 + } +} \ No newline at end of file diff --git a/data/futures_analysis.db b/data/futures_analysis.db new file mode 100644 index 0000000..c388f5c Binary files /dev/null and b/data/futures_analysis.db differ