mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
add futures exchange check in the markets cache
This commit is contained in:
parent
245905a25a
commit
08a264d4eb
|
@ -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) {
|
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 ex.QueryMarkets(ctx)
|
||||||
})
|
})
|
||||||
return markets, err
|
return markets, err
|
||||||
|
|
|
@ -4,6 +4,7 @@ import "github.com/c9s/bbgo/pkg/fixedpoint"
|
||||||
|
|
||||||
type FuturesExchange interface {
|
type FuturesExchange interface {
|
||||||
UseFutures()
|
UseFutures()
|
||||||
|
GetFuturesSettings() FuturesSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
type FuturesSettings struct {
|
type FuturesSettings struct {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user