From f86fc8c1649fcb78606ddcd7cff04d1a7c7c1826 Mon Sep 17 00:00:00 2001 From: c9s Date: Sat, 14 Dec 2024 15:47:18 +0800 Subject: [PATCH] session: initialize a empty price solver --- pkg/bbgo/session.go | 1 + pkg/pricesolver/simple.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/pkg/bbgo/session.go b/pkg/bbgo/session.go index 89a6bca5d0..341846aebd 100644 --- a/pkg/bbgo/session.go +++ b/pkg/bbgo/session.go @@ -192,6 +192,7 @@ func NewExchangeSession(name string, exchange types.Exchange) *ExchangeSession { usedSymbols: make(map[string]struct{}), initializedSymbols: make(map[string]struct{}), logger: log.WithField("session", name), + priceSolver: pricesolver.NewSimplePriceResolver(nil), } session.OrderExecutor = &ExchangeOrderExecutor{ diff --git a/pkg/pricesolver/simple.go b/pkg/pricesolver/simple.go index aef040309c..7602f25ed0 100644 --- a/pkg/pricesolver/simple.go +++ b/pkg/pricesolver/simple.go @@ -30,6 +30,10 @@ type SimplePriceSolver struct { } func NewSimplePriceResolver(markets types.MarketMap) *SimplePriceSolver { + if markets == nil { + markets = make(types.MarketMap) + } + return &SimplePriceSolver{ markets: markets, symbolPrices: make(map[string]fixedpoint.Value),