improve/profitStatsTracker: Add a parameter for window to sum up trades

This commit is contained in:
Andy Cheng 2023-08-11 13:16:53 +08:00
parent 6379cab65e
commit a74562ed31
No known key found for this signature in database
GPG Key ID: 936427CF651A9D28
2 changed files with 6 additions and 2 deletions

View File

@ -119,5 +119,6 @@ exchangeStrategies:
accumulatedProfitReport:
profitMAWindow: 60
shortTermProfitWindow: 14
accumulateTradeWindow: 30
tsvReportPath: res.tsv
trackParameters: false

View File

@ -25,6 +25,9 @@ type AccumulatedProfitReport struct {
types.IntervalWindow
// ProfitMAWindow Accumulated profit SMA window
AccumulateTradeWindow int `json:"accumulateTradeWindow"`
// Accumulated profit
accumulatedProfit fixedpoint.Value
accumulatedProfitPerInterval *types.Float64Series
@ -119,7 +122,7 @@ func (r *AccumulatedProfitReport) CsvHeader() []string {
"accumulatedFee",
"winRatio",
"profitFactor",
fmt.Sprintf("%s%d Trades", r.Interval, r.Window),
fmt.Sprintf("%s%d Trades", r.Interval, r.AccumulateTradeWindow),
}
for i := 0; i < len(r.strategyParameters); i++ {
@ -143,7 +146,7 @@ func (r *AccumulatedProfitReport) CsvRecords() [][]string {
strconv.FormatFloat(r.accumulatedFeePerInterval.Last(i), 'f', 4, 64),
strconv.FormatFloat(r.winRatioPerInterval.Last(i), 'f', 4, 64),
strconv.FormatFloat(r.profitFactorPerInterval.Last(i), 'f', 4, 64),
strconv.FormatFloat(r.accumulatedTradesPerInterval.Last(i), 'f', 4, 64),
strconv.FormatFloat(r.accumulatedTradesPerInterval.Last(i)-r.accumulatedTradesPerInterval.Last(i+r.AccumulateTradeWindow), 'f', 4, 64),
}
for j := 0; j < len(r.strategyParameters); j++ {
values = append(values, r.strategyParameters[j][1])