mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 06:53:52 +00:00
types: add CsvHeaders and CsvRecords methods to TradeStats
This commit is contained in:
parent
d9cce129a0
commit
db622fbb55
|
@ -3,6 +3,7 @@ package types
|
|||
import (
|
||||
"encoding/json"
|
||||
"math"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
@ -203,6 +204,38 @@ func (s *TradeStats) SetIntervalProfitCollector(c *IntervalProfitCollector) {
|
|||
s.IntervalProfits[c.Interval] = c
|
||||
}
|
||||
|
||||
func (s *TradeStats) CsvHeader() []string {
|
||||
return []string{
|
||||
"winningRatio",
|
||||
"numOfProfitTrade",
|
||||
"numOfLossTrade",
|
||||
"grossProfit",
|
||||
"grossLoss",
|
||||
"profitFactor",
|
||||
"largestProfitTrade",
|
||||
"largestLossTrade",
|
||||
"maximumConsecutiveWins",
|
||||
"maximumConsecutiveLosses",
|
||||
}
|
||||
}
|
||||
|
||||
func (s *TradeStats) CsvRecords() [][]string {
|
||||
return [][]string{
|
||||
{
|
||||
s.WinningRatio.String(),
|
||||
strconv.Itoa(s.NumOfProfitTrade),
|
||||
strconv.Itoa(s.NumOfLossTrade),
|
||||
s.GrossProfit.String(),
|
||||
s.GrossLoss.String(),
|
||||
s.ProfitFactor.String(),
|
||||
s.LargestProfitTrade.String(),
|
||||
s.LargestLossTrade.String(),
|
||||
strconv.Itoa(s.MaximumConsecutiveWins),
|
||||
strconv.Itoa(s.MaximumConsecutiveLosses),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (s *TradeStats) Add(profit *Profit) {
|
||||
if s.Symbol != "" && profit.Symbol != s.Symbol {
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue
Block a user