mirror of
https://github.com/c9s/bbgo.git
synced 2024-09-20 08:11:08 +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)
|
trader.AttachCrossExchangeStrategy(strategy)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: load these from config file
|
for _, report := range userConfig.PnLReporters {
|
||||||
trader.ReportPnL(notifier).
|
if len(report.AverageCostBySymbols) > 0 {
|
||||||
AverageCostBySymbols("BTCUSDT", "BNBUSDT").
|
trader.ReportPnL(notifier).
|
||||||
Of("binance").When("@daily", "@hourly")
|
AverageCostBySymbols(report.AverageCostBySymbols...).
|
||||||
|
Of(report.Of...).
|
||||||
trader.ReportPnL(notifier).
|
When(report.When...)
|
||||||
AverageCostBySymbols("MAXUSDT").
|
} else {
|
||||||
Of("max").When("@daily", "@hourly")
|
return errors.Errorf("unsupported PnL reporter: %+v", report)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
err = trader.Run(ctx)
|
err = trader.Run(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -35,5 +35,5 @@ exchangeStrategies:
|
||||||
buyandhold:
|
buyandhold:
|
||||||
symbol: "BTCUSDT"
|
symbol: "BTCUSDT"
|
||||||
interval: "1m"
|
interval: "1m"
|
||||||
baseQuantity: 0.1
|
baseQuantity: 0.01
|
||||||
minDropPercentage: -0.05
|
minDropPercentage: -0.02
|
||||||
|
|
|
@ -2,7 +2,6 @@ package pnl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
@ -10,8 +9,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type AverageCostCalculator struct {
|
type AverageCostCalculator struct {
|
||||||
Symbol string
|
|
||||||
StartTime time.Time
|
|
||||||
TradingFeeCurrency string
|
TradingFeeCurrency string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,9 +86,9 @@ func (c *AverageCostCalculator) Calculate(symbol string, trades []types.Trade, c
|
||||||
|
|
||||||
return &AverageCostPnlReport{
|
return &AverageCostPnlReport{
|
||||||
Symbol: symbol,
|
Symbol: symbol,
|
||||||
StartTime: c.StartTime,
|
|
||||||
CurrentPrice: currentPrice,
|
CurrentPrice: currentPrice,
|
||||||
NumTrades: len(trades),
|
NumTrades: len(trades),
|
||||||
|
StartTime: trades[0].Time,
|
||||||
|
|
||||||
BidVolume: bidVolume,
|
BidVolume: bidVolume,
|
||||||
AskVolume: askVolume,
|
AskVolume: askVolume,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user