mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 00:05:15 +00:00
cache: refactor moving from bbgo to pkg/cache
This commit is contained in:
parent
734221028b
commit
91d2312c5c
|
@ -30,6 +30,7 @@ package backtest
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/c9s/bbgo/pkg/cache"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
@ -68,7 +69,7 @@ type Exchange struct {
|
|||
func NewExchange(sourceName types.ExchangeName, sourceExchange types.Exchange, srv *service.BacktestService, config *bbgo.Backtest) (*Exchange, error) {
|
||||
ex := sourceExchange
|
||||
|
||||
markets, err := bbgo.LoadExchangeMarketsWithCache(context.Background(), ex)
|
||||
markets, err := cache.LoadExchangeMarketsWithCache(context.Background(), ex)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package bbgo
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/c9s/bbgo/pkg/cache"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -295,7 +296,7 @@ func (session *ExchangeSession) Init(ctx context.Context, environ *Environment)
|
|||
if util.SetEnvVarBool("DISABLE_MARKETS_CACHE", &disableMarketsCache); disableMarketsCache {
|
||||
markets, err = session.Exchange.QueryMarkets(ctx)
|
||||
} else {
|
||||
markets, err = LoadExchangeMarketsWithCache(ctx, session.Exchange)
|
||||
markets, err = cache.LoadExchangeMarketsWithCache(ctx, session.Exchange)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
2
pkg/bbgo/cache.go → pkg/cache/cache.go
vendored
2
pkg/bbgo/cache.go → pkg/cache/cache.go
vendored
|
@ -1,4 +1,4 @@
|
|||
package bbgo
|
||||
package cache
|
||||
|
||||
import (
|
||||
"context"
|
2
pkg/bbgo/home.go → pkg/cache/home.go
vendored
2
pkg/bbgo/home.go → pkg/cache/home.go
vendored
|
@ -1,4 +1,4 @@
|
|||
package bbgo
|
||||
package cache
|
||||
|
||||
import (
|
||||
"os"
|
|
@ -3,6 +3,7 @@ package service
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/c9s/bbgo/pkg/cache"
|
||||
"time"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
@ -25,9 +26,7 @@ type SyncService struct {
|
|||
func (s *SyncService) SyncSessionSymbols(ctx context.Context, exchange types.Exchange, startTime time.Time, symbols ...string) error {
|
||||
for _, symbol := range symbols {
|
||||
log.Infof("syncing %s %s trades...", exchange.Name(), symbol)
|
||||
// TODO: bbgo import cycle error
|
||||
//markets, err := bbgo.LoadExchangeMarketsWithCache(ctx, exchange)
|
||||
markets, err := exchange.QueryMarkets(ctx)
|
||||
markets, err := cache.LoadExchangeMarketsWithCache(ctx, exchange)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user