mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 16:25:16 +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 (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"math"
|
"math"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
@ -203,6 +204,38 @@ func (s *TradeStats) SetIntervalProfitCollector(c *IntervalProfitCollector) {
|
||||||
s.IntervalProfits[c.Interval] = c
|
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) {
|
func (s *TradeStats) Add(profit *Profit) {
|
||||||
if s.Symbol != "" && profit.Symbol != s.Symbol {
|
if s.Symbol != "" && profit.Symbol != s.Symbol {
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue
Block a user