grid2: fix InstanceID for autoRange

This commit is contained in:
c9s 2022-12-26 01:40:59 +08:00
parent 8af7d6f457
commit 2d2d194bda
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
2 changed files with 13 additions and 1 deletions

View File

@ -179,7 +179,15 @@ func (s *Strategy) Subscribe(session *bbgo.ExchangeSession) {
// InstanceID returns the instance identifier from the current grid configuration parameters
func (s *Strategy) InstanceID() string {
return fmt.Sprintf("%s-%s-%d-%d-%d", ID, s.Symbol, s.GridNum, s.UpperPrice.Int(), s.LowerPrice.Int())
id := fmt.Sprintf("%s-%s-size-%d", ID, s.Symbol, s.GridNum)
if s.AutoRange != nil {
id += "-autoRange-" + s.AutoRange.String()
} else {
id += "-" + s.UpperPrice.String() + "-" + s.LowerPrice.String()
}
return id
}
func (s *Strategy) checkSpread() error {

View File

@ -20,6 +20,10 @@ type SimpleDuration struct {
Duration Duration
}
func (d *SimpleDuration) String() string {
return fmt.Sprintf("%d%s", d.Num, d.Unit)
}
func (d *SimpleDuration) Interval() Interval {
switch d.Unit {