From 3b3df77ec3e8ea9648e2da5580756b6efedd6494 Mon Sep 17 00:00:00 2001 From: c9s Date: Tue, 20 Oct 2020 12:24:30 +0800 Subject: [PATCH] clean up the legacy context struct --- pkg/bbgo/cache.go | 3 +-- pkg/bbgo/context.go | 20 +------------------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/pkg/bbgo/cache.go b/pkg/bbgo/cache.go index cc6267c2a..f700d012c 100644 --- a/pkg/bbgo/cache.go +++ b/pkg/bbgo/cache.go @@ -10,7 +10,6 @@ import ( "github.com/pkg/errors" ) - type DataFetcher func() (interface{}, error) // WithCache let you use the cache with the given cache key, variable reference and your data fetcher, @@ -19,7 +18,7 @@ type DataFetcher func() (interface{}, error) // fetcher is the closure that will fetch your remote data or some slow operation. func WithCache(key string, obj interface{}, fetcher DataFetcher) error { cacheDir := CacheDir() - cacheFile := path.Join(cacheDir, key+ ".json") + cacheFile := path.Join(cacheDir, key+".json") if _, err := os.Stat(cacheFile); os.IsNotExist(err) { data, err := fetcher() diff --git a/pkg/bbgo/context.go b/pkg/bbgo/context.go index bddf2ca15..2613c0bc9 100644 --- a/pkg/bbgo/context.go +++ b/pkg/bbgo/context.go @@ -2,28 +2,10 @@ package bbgo import ( "sync" - - "github.com/c9s/bbgo/pkg/accounting" - "github.com/c9s/bbgo/pkg/accounting/pnl" - "github.com/c9s/bbgo/pkg/types" ) +// deprecated: legacy context struct type Context struct { sync.Mutex - - Symbol string - - // Market is the market configuration of a symbol - Market types.Market - - AverageBidPrice float64 - CurrentPrice float64 - - Balances map[string]types.Balance - ProfitAndLossCalculator *pnl.AverageCostCalculator - StockManager *accounting.StockDistribution } -func (c *Context) SetCurrentPrice(price float64) { - c.CurrentPrice = price -}