diff --git a/cmd/run.go b/cmd/run.go index a6ffda619..d822d79ad 100644 --- a/cmd/run.go +++ b/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 { diff --git a/config/bbgo.yaml b/config/bbgo.yaml index 6b7078f57..adc09ce12 100644 --- a/config/bbgo.yaml +++ b/config/bbgo.yaml @@ -35,5 +35,5 @@ exchangeStrategies: buyandhold: symbol: "BTCUSDT" interval: "1m" - baseQuantity: 0.1 - minDropPercentage: -0.05 + baseQuantity: 0.01 + minDropPercentage: -0.02 diff --git a/pkg/accounting/pnl/avg_cost.go b/pkg/accounting/pnl/avg_cost.go index b1df3c056..bc7c51382 100644 --- a/pkg/accounting/pnl/avg_cost.go +++ b/pkg/accounting/pnl/avg_cost.go @@ -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,