xbalance: add checkOnStart option

This commit is contained in:
c9s 2021-05-18 08:32:00 +08:00
parent d722b76564
commit e23932f99c

View File

@ -120,6 +120,8 @@ type Strategy struct {
MaxDailyNumberOfTransfer int `json:"maxDailyNumberOfTransfer"` MaxDailyNumberOfTransfer int `json:"maxDailyNumberOfTransfer"`
MaxDailyAmountOfTransfer fixedpoint.Value `json:"maxDailyAmountOfTransfer"` MaxDailyAmountOfTransfer fixedpoint.Value `json:"maxDailyAmountOfTransfer"`
CheckOnStart bool `json:"checkOnStart"`
Asset string `json:"asset"` Asset string `json:"asset"`
// Low is the low balance level for triggering transfer // Low is the low balance level for triggering transfer
@ -331,7 +333,9 @@ func (s *Strategy) CrossRun(ctx context.Context, _ bbgo.OrderExecutionRouter, se
s.SaveState() s.SaveState()
}) })
s.checkBalance(ctx, sessions) if s.CheckOnStart {
s.checkBalance(ctx, sessions)
}
go func() { go func() {
ticker := time.NewTimer(durationJitter(s.Interval.Duration(), 1000)) ticker := time.NewTimer(durationJitter(s.Interval.Duration(), 1000))