mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-21 22:43:52 +00:00
use the time of the first trade as the report start time
This commit is contained in:
parent
c9f5d51556
commit
6e033461bb
18
cmd/run.go
18
cmd/run.go
|
@ -82,14 +82,16 @@ var runCmd = &cobra.Command{
|
|||
trader.AttachCrossExchangeStrategy(strategy)
|
||||
}
|
||||
|
||||
// TODO: load these from config file
|
||||
trader.ReportPnL(notifier).
|
||||
AverageCostBySymbols("BTCUSDT", "BNBUSDT").
|
||||
Of("binance").When("@daily", "@hourly")
|
||||
|
||||
trader.ReportPnL(notifier).
|
||||
AverageCostBySymbols("MAXUSDT").
|
||||
Of("max").When("@daily", "@hourly")
|
||||
for _, report := range userConfig.PnLReporters {
|
||||
if len(report.AverageCostBySymbols) > 0 {
|
||||
trader.ReportPnL(notifier).
|
||||
AverageCostBySymbols(report.AverageCostBySymbols...).
|
||||
Of(report.Of...).
|
||||
When(report.When...)
|
||||
} else {
|
||||
return errors.Errorf("unsupported PnL reporter: %+v", report)
|
||||
}
|
||||
}
|
||||
|
||||
err = trader.Run(ctx)
|
||||
if err != nil {
|
||||
|
|
|
@ -35,5 +35,5 @@ exchangeStrategies:
|
|||
buyandhold:
|
||||
symbol: "BTCUSDT"
|
||||
interval: "1m"
|
||||
baseQuantity: 0.1
|
||||
minDropPercentage: -0.05
|
||||
baseQuantity: 0.01
|
||||
minDropPercentage: -0.02
|
||||
|
|
|
@ -2,7 +2,6 @@ package pnl
|
|||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
|
@ -10,8 +9,6 @@ import (
|
|||
)
|
||||
|
||||
type AverageCostCalculator struct {
|
||||
Symbol string
|
||||
StartTime time.Time
|
||||
TradingFeeCurrency string
|
||||
}
|
||||
|
||||
|
@ -89,9 +86,9 @@ func (c *AverageCostCalculator) Calculate(symbol string, trades []types.Trade, c
|
|||
|
||||
return &AverageCostPnlReport{
|
||||
Symbol: symbol,
|
||||
StartTime: c.StartTime,
|
||||
CurrentPrice: currentPrice,
|
||||
NumTrades: len(trades),
|
||||
StartTime: trades[0].Time,
|
||||
|
||||
BidVolume: bidVolume,
|
||||
AskVolume: askVolume,
|
||||
|
|
Loading…
Reference in New Issue
Block a user