mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-06 12:30:59 +08:00
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:
@@ -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. 构建上下文
|
||||
|
||||
Reference in New Issue
Block a user