mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 16:55:15 +00:00
Validate config
This commit is contained in:
parent
41d4001872
commit
2999e41ef0
|
@ -2,6 +2,7 @@ package kline
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
@ -67,6 +68,32 @@ func (s *Strategy) ID() string {
|
||||||
return ID
|
return ID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Strategy) Validate() error {
|
||||||
|
if s.Interval == 0 {
|
||||||
|
return fmt.Errorf("interval shoud not be 0")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(s.TargetWeights) == 0 {
|
||||||
|
return fmt.Errorf("targetWeights should not be empty")
|
||||||
|
}
|
||||||
|
|
||||||
|
for currency, weight := range s.TargetWeights {
|
||||||
|
if weight.Float64() < 0 {
|
||||||
|
return fmt.Errorf("%s weight: %f should not less than 0", currency, weight.Float64())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if s.Threshold < 0 {
|
||||||
|
return fmt.Errorf("threshold should not less than 0")
|
||||||
|
}
|
||||||
|
|
||||||
|
if s.MaxAmount < 0 {
|
||||||
|
return fmt.Errorf("maxAmount shoud not less than 0")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Strategy) Subscribe(session *bbgo.ExchangeSession) {}
|
func (s *Strategy) Subscribe(session *bbgo.ExchangeSession) {}
|
||||||
|
|
||||||
func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, session *bbgo.ExchangeSession) error {
|
func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, session *bbgo.ExchangeSession) error {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user