feat: AI analysis engine refactor, dark theme polish & virtual position management
Core changes: - Refactor FastAnalysisService: single LLM multi-factor analysis replaces 7-agent pipeline; add multi-timeframe consensus, threshold calibration, confidence calibration, multi-model ensemble voting - Add RAG memory injection and reflection validation (analysis_memory + reflection worker) - Simplify billing config: remove unused strategy_run/backtest/portfolio_monitor, add ai_code_gen separate billing (different token consumption scale) - Settings hot-reload after save, no backend restart needed Frontend: - Global dark theme overhaul: pure black palette replacing blue-tinted colors across sidebar/header/dashboard/analysis/K-line/user-manage/profile/settings/billing - Fix USDT payment modal dark theme (portal rendering broke CSS selectors) - Refactor position modal: direction + quantity + entry price, remove add/reduce logic, show raw DB values on re-open, save exactly what user inputs - Fix Polymarket prediction market dark text - i18n for position modal title Backend: - Position management: one record per symbol (DELETE+INSERT replacing ON CONFLICT with side), fixes PnL showing 0 when switching long/short - MarketDataCollector data fetching optimization - portfolio_monitor scheduled monitoring improvements - env.example reorganized: common config first, advanced config last Documentation: - README architecture diagram updated to FastAnalysisService flow - Add virtual position, AI tuning config, billing items documentation - Add INDICATOR_DEFINITIONS_CN.md, FRONTEND_FAST_ANALYSIS.md Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Run AI calibration manually (e.g. via cron).
|
||||
|
||||
Usage:
|
||||
python scripts/run_calibration.py
|
||||
AI_CALIBRATION_MARKET=Crypto python scripts/run_calibration.py
|
||||
AI_CALIBRATION_MARKETS=Crypto,USStock python scripts/run_calibration.py
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
|
||||
|
||||
from app.services.ai_calibration import AICalibrationService
|
||||
|
||||
|
||||
def main():
|
||||
markets = (os.getenv("AI_CALIBRATION_MARKETS") or os.getenv("AI_CALIBRATION_MARKET") or "Crypto").strip().split(",")
|
||||
for m in markets:
|
||||
m = m.strip()
|
||||
if not m:
|
||||
continue
|
||||
print(f"Calibrating market: {m}")
|
||||
svc = AICalibrationService()
|
||||
r = svc.calibrate_market(market=m, validate_before=True)
|
||||
if r:
|
||||
print(f" OK: accuracy={r.best_accuracy:.1f}% threshold=±{r.buy_threshold:.1f} samples={r.sample_count}")
|
||||
else:
|
||||
print(" SKIP: not enough validated samples")
|
||||
print("Done.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,19 +1,31 @@
|
||||
import sys
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# 添加项目根目录到 Python 路径
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..'))
|
||||
# 添加后端目录到 Python 路径(使得可以 import app.*)
|
||||
# 由于 app 包位于 backend_api_python/app 下,而脚本位于 backend_api_python/scripts
|
||||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
||||
|
||||
from app.services.agents.reflection import ReflectionService
|
||||
from app.services.reflection import ReflectionService
|
||||
|
||||
def main():
|
||||
# Load backend envs for DATABASE_URL, reflection switches, etc.
|
||||
# This script may be run locally, so we must load .env explicitly.
|
||||
backend_env_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '.env'))
|
||||
root_env_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '.env'))
|
||||
if os.path.exists(root_env_path):
|
||||
load_dotenv(root_env_path, override=False)
|
||||
if os.path.exists(backend_env_path):
|
||||
load_dotenv(backend_env_path, override=False)
|
||||
|
||||
"""
|
||||
运行自动反思验证任务
|
||||
建议通过 cron 或 定时任务调度器 每天运行一次
|
||||
"""
|
||||
print("Running Automated Reflection Verification Task...")
|
||||
service = ReflectionService()
|
||||
service.run_verification_cycle()
|
||||
stats = service.run_verification_cycle()
|
||||
print("Reflection stats:", stats)
|
||||
print("Task Completed.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user