clean up the legacy context struct

This commit is contained in:
c9s 2020-10-20 12:24:30 +08:00
parent 752fdf5c80
commit 3b3df77ec3
2 changed files with 2 additions and 21 deletions

View File

@ -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()

View File

@ -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
}