mirror of
https://github.com/c9s/bbgo.git
synced 2024-09-20 08:11:08 +00:00
clean up the legacy context struct
This commit is contained in:
parent
752fdf5c80
commit
3b3df77ec3
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user