Skip to content

Commit

Permalink
improve/profitStatsTracker: Add a parameter for window to sum up trades
Browse files Browse the repository at this point in the history
  • Loading branch information
andycheng123 committed Aug 11, 2023
1 parent 6379cab commit a74562e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions config/supertrend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,6 @@ exchangeStrategies:
accumulatedProfitReport:
profitMAWindow: 60
shortTermProfitWindow: 14
accumulateTradeWindow: 30
tsvReportPath: res.tsv
trackParameters: false
7 changes: 5 additions & 2 deletions pkg/report/profit_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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++ {
Expand All @@ -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])
Expand Down

0 comments on commit a74562e

Please sign in to comment.