mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 06:53:52 +00:00
pull out fillStrategyNotifiability
This commit is contained in:
parent
ccc381143d
commit
7905ba09d4
|
@ -133,19 +133,7 @@ func (trader *Trader) Run(ctx context.Context) error {
|
|||
// get the struct element
|
||||
rs = rs.Elem()
|
||||
|
||||
field := rs.FieldByName("Notifiability")
|
||||
if field.IsValid() {
|
||||
log.Infof("found Notifiability in strategy %T, configuring...", strategy)
|
||||
if !field.CanSet() {
|
||||
log.Panicf("strategy %T field Notifiability can not be set", strategy)
|
||||
}
|
||||
|
||||
if field.Type() == reflect.PtrTo(reflect.TypeOf(trader.Notifiability)) {
|
||||
field.Set(reflect.ValueOf(&trader.Notifiability))
|
||||
} else {
|
||||
field.Set(reflect.ValueOf(trader.Notifiability))
|
||||
}
|
||||
}
|
||||
trader.fillStrategyNotifiability(strategy, rs)
|
||||
}
|
||||
|
||||
err := strategy.Run(ctx, orderExecutor, session)
|
||||
|
@ -170,6 +158,24 @@ func (trader *Trader) Run(ctx context.Context) error {
|
|||
return trader.environment.Connect(ctx)
|
||||
}
|
||||
|
||||
func (trader *Trader) fillStrategyNotifiability(strategy SingleExchangeStrategy, rs reflect.Value) {
|
||||
field := rs.FieldByName("Notifiability")
|
||||
if !field.IsValid() {
|
||||
return
|
||||
}
|
||||
|
||||
log.Infof("found Notifiability in strategy %T, configuring...", strategy)
|
||||
if !field.CanSet() {
|
||||
log.Panicf("strategy %T field Notifiability can not be set", strategy)
|
||||
}
|
||||
|
||||
if field.Type() == reflect.PtrTo(reflect.TypeOf(trader.Notifiability)) {
|
||||
field.Set(reflect.ValueOf(&trader.Notifiability))
|
||||
} else {
|
||||
field.Set(reflect.ValueOf(trader.Notifiability))
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
func (trader *OrderExecutor) RunStrategyWithHotReload(ctx context.Context, strategy SingleExchangeStrategy, configFile string) (chan struct{}, error) {
|
||||
var done = make(chan struct{})
|
||||
|
|
Loading…
Reference in New Issue
Block a user