Refactor: Improve AI decision system and Sharpe ratio calculation

Major improvements:
- Use period-level Sharpe ratio (range -2 to +2) instead of annualized
- Save full user prompt in decision logs for debugging
- Format complete market data (3m + 4h candles) for AI analysis
- Prevent position stacking with duplicate position checks
- Update Sharpe ratio interpretation thresholds
Market data enhancements:
- Display full technical indicators in user prompt
- Include 3-minute and 4-hour timeframe data
- Add OI (Open Interest) change and funding rate signals
Risk control:
- Block opening duplicate positions (same symbol + direction)
- Suggest close action first before opening new position
- Prevent margin usage from exceeding limits
UI improvements:
- Update multi-language translations
- Refine AI learning dashboard display
Co-Authored-By: tinkle-community <tinklefund@gmail.com>
This commit is contained in:
tinkle-community
2025-10-29 04:44:17 +08:00
parent d2ccf516a1
commit ceaedca253
6 changed files with 104 additions and 461 deletions

View File

@@ -224,8 +224,9 @@ func (at *AutoTrader) runCycle() error {
log.Println("🤖 正在请求AI分析并决策...")
decision, err := market.GetFullTradingDecision(ctx)
// 即使有错误,也保存思维链决策用于debug
// 即使有错误,也保存思维链决策和输入prompt用于debug
if decision != nil {
record.InputPrompt = decision.UserPrompt
record.CoTTrace = decision.CoTTrace
if len(decision.Decisions) > 0 {
decisionJSON, _ := json.MarshalIndent(decision.Decisions, "", " ")
@@ -428,7 +429,8 @@ func (at *AutoTrader) buildTradingContext() (*market.TradingContext, error) {
performance, err := at.decisionLogger.AnalyzePerformance(20)
if err != nil {
log.Printf("⚠️ 分析历史表现失败: %v", err)
// 不影响主流程,继续执行
// 不影响主流程,继续执行但设置performance为nil以避免传递错误数据
performance = nil
}
// 6. 构建上下文