diff --git a/pkg/bbgo/cache.go b/pkg/bbgo/cache.go index 8a4ca3fcf..09dad0d4e 100644 --- a/pkg/bbgo/cache.go +++ b/pkg/bbgo/cache.go @@ -62,7 +62,15 @@ func WithCache(key string, obj interface{}, fetcher DataFetcher) error { } func LoadExchangeMarketsWithCache(ctx context.Context, ex types.Exchange) (markets types.MarketMap, err error) { - err = WithCache(fmt.Sprintf("%s-markets", ex.Name()), &markets, func() (interface{}, error) { + key := fmt.Sprintf("%s-markets", ex.Name()) + if futureExchange, implemented := ex.(types.FuturesExchange) ; implemented { + settings := futureExchange.GetFuturesSettings() + if settings.IsFutures { + key = fmt.Sprintf("%s-futures-markets", ex.Name()) + } + } + + err = WithCache(key, &markets, func() (interface{}, error) { return ex.QueryMarkets(ctx) }) return markets, err diff --git a/pkg/types/margin.go b/pkg/types/margin.go index 82bf54a5c..09e30d97e 100644 --- a/pkg/types/margin.go +++ b/pkg/types/margin.go @@ -4,6 +4,7 @@ import "github.com/c9s/bbgo/pkg/fixedpoint" type FuturesExchange interface { UseFutures() + GetFuturesSettings() FuturesSettings } type FuturesSettings struct {