xfunding: check binance type and return error

This commit is contained in:
c9s 2023-03-26 01:16:54 +08:00
parent 23746678b4
commit 22d339cb41
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -52,6 +52,8 @@ type MovingAverageConfig struct {
var log = logrus.WithField("strategy", ID) var log = logrus.WithField("strategy", ID)
var errNotBinanceExchange = errors.New("not binance exchange, currently only support binance exchange")
func init() { func init() {
// Register the pointer of the strategy struct, // Register the pointer of the strategy struct,
// so that bbgo knows what struct to be used to unmarshal the configs (YAML or JSON) // so that bbgo knows what struct to be used to unmarshal the configs (YAML or JSON)
@ -277,9 +279,14 @@ func (s *Strategy) CrossRun(ctx context.Context, orderExecutionRouter bbgo.Order
log.Infof("loaded spot position: %s", s.SpotPosition.String()) log.Infof("loaded spot position: %s", s.SpotPosition.String())
log.Infof("loaded futures position: %s", s.FuturesPosition.String()) log.Infof("loaded futures position: %s", s.FuturesPosition.String())
binanceFutures := s.futuresSession.Exchange.(*binance.Exchange) binanceFutures, ok := s.futuresSession.Exchange.(*binance.Exchange)
binanceSpot := s.spotSession.Exchange.(*binance.Exchange) if !ok {
_ = binanceSpot return errNotBinanceExchange
}
binanceSpot, ok := s.spotSession.Exchange.(*binance.Exchange)
if !ok {
return errNotBinanceExchange
}
s.spotOrderExecutor = s.allocateOrderExecutor(ctx, s.spotSession, instanceID, s.SpotPosition) s.spotOrderExecutor = s.allocateOrderExecutor(ctx, s.spotSession, instanceID, s.SpotPosition)
s.spotOrderExecutor.TradeCollector().OnTrade(func(trade types.Trade, profit fixedpoint.Value, netProfit fixedpoint.Value) { s.spotOrderExecutor.TradeCollector().OnTrade(func(trade types.Trade, profit fixedpoint.Value, netProfit fixedpoint.Value) {