mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-14 08:16:56 +08:00
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:
@@ -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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user