add multiple spec support

This commit is contained in:
c9s 2020-10-23 00:21:03 +08:00
parent 9c751f377a
commit 6b0f2b80d7
2 changed files with 8 additions and 5 deletions

View File

@ -83,7 +83,8 @@ var runCmd = &cobra.Command{
} }
trader.ReportPnL(notifier). trader.ReportPnL(notifier).
AverageCostBySymbols("BTCUSDT", "BNBUSDT").Of("max", "binance") AverageCostBySymbols("BTCUSDT", "BNBUSDT").
Of("max", "binance").When("@daily", "@hourly")
err = trader.Run(ctx) err = trader.Run(ctx)
if err != nil { if err != nil {

View File

@ -81,11 +81,13 @@ func (reporter *AverageCostPnLReporter) Of(sessions ...string) *AverageCostPnLRe
return reporter return reporter
} }
func (reporter *AverageCostPnLReporter) When(spec string) *AverageCostPnLReporter { func (reporter *AverageCostPnLReporter) When(specs ...string) *AverageCostPnLReporter {
for _,spec := range specs {
_, err := reporter.cron.AddJob(spec, reporter) _, err := reporter.cron.AddJob(spec, reporter)
if err != nil { if err != nil {
panic(err) panic(err)
} }
}
return reporter return reporter
} }