mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
core: enable trade store's trade pruning in NewTradeCollector
This commit is contained in:
parent
97c39921bd
commit
685f332495
|
@ -34,12 +34,15 @@ type TradeCollector struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTradeCollector(symbol string, position *types.Position, orderStore *OrderStore) *TradeCollector {
|
func NewTradeCollector(symbol string, position *types.Position, orderStore *OrderStore) *TradeCollector {
|
||||||
|
tradeStore := NewTradeStore()
|
||||||
|
tradeStore.EnablePrune = true
|
||||||
|
|
||||||
return &TradeCollector{
|
return &TradeCollector{
|
||||||
Symbol: symbol,
|
Symbol: symbol,
|
||||||
orderSig: sigchan.New(1),
|
orderSig: sigchan.New(1),
|
||||||
|
|
||||||
tradeC: make(chan types.Trade, 100),
|
tradeC: make(chan types.Trade, 100),
|
||||||
tradeStore: NewTradeStore(),
|
tradeStore: tradeStore,
|
||||||
doneTrades: make(map[types.TradeKey]struct{}),
|
doneTrades: make(map[types.TradeKey]struct{}),
|
||||||
position: position,
|
position: position,
|
||||||
orderStore: orderStore,
|
orderStore: orderStore,
|
||||||
|
@ -88,7 +91,9 @@ func (c *TradeCollector) Emit() {
|
||||||
c.orderSig.Emit()
|
c.orderSig.Emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *TradeCollector) Recover(ctx context.Context, ex types.ExchangeTradeHistoryService, symbol string, from time.Time) error {
|
func (c *TradeCollector) Recover(
|
||||||
|
ctx context.Context, ex types.ExchangeTradeHistoryService, symbol string, from time.Time,
|
||||||
|
) error {
|
||||||
logrus.Debugf("recovering %s trades...", symbol)
|
logrus.Debugf("recovering %s trades...", symbol)
|
||||||
|
|
||||||
trades, err := ex.QueryTrades(ctx, symbol, &types.TradeQueryOptions{
|
trades, err := ex.QueryTrades(ctx, symbol, &types.TradeQueryOptions{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user