Improve(interface): replace some struct with interface for testing (#994)

* fix(trader): get peakPnlPct using posKey

* fix(docs): keep readme at the same page

* improve(interface): replace with interface

* refactor mcp

---------

Co-authored-by: zbhan <zbhan@freewheel.tv>
This commit is contained in:
Shui
2025-11-13 22:22:05 -05:00
committed by tangmengqiu
parent 79358d4776
commit 3f5f964a67
8 changed files with 164 additions and 93 deletions

View File

@@ -64,6 +64,22 @@ type DecisionAction struct {
Error string `json:"error"` // 错误信息
}
// IDecisionLogger 决策日志记录器接口
type IDecisionLogger interface {
// LogDecision 记录决策
LogDecision(record *DecisionRecord) error
// GetLatestRecords 获取最近N条记录按时间正序从旧到新
GetLatestRecords(n int) ([]*DecisionRecord, error)
// GetRecordByDate 获取指定日期的所有记录
GetRecordByDate(date time.Time) ([]*DecisionRecord, error)
// CleanOldRecords 清理N天前的旧记录
CleanOldRecords(days int) error
// GetStatistics 获取统计信息
GetStatistics() (*Statistics, error)
// AnalyzePerformance 分析最近N个周期的交易表现
AnalyzePerformance(lookbackCycles int) (*PerformanceAnalysis, error)
}
// DecisionLogger 决策日志记录器
type DecisionLogger struct {
logDir string
@@ -71,7 +87,7 @@ type DecisionLogger struct {
}
// NewDecisionLogger 创建决策日志记录器
func NewDecisionLogger(logDir string) *DecisionLogger {
func NewDecisionLogger(logDir string) IDecisionLogger {
if logDir == "" {
logDir = "decision_logs"
}