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).
AverageCostBySymbols("BTCUSDT", "BNBUSDT").Of("max", "binance")
AverageCostBySymbols("BTCUSDT", "BNBUSDT").
Of("max", "binance").When("@daily", "@hourly")
err = trader.Run(ctx)
if err != nil {

View File

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