mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 06:53:52 +00:00
feature/profitTracker: add AddTrade()
This commit is contained in:
parent
d5e194ca80
commit
57cdbb1d77
|
@ -34,17 +34,17 @@ func (p *ProfitTracker) Init(market types.Market) {
|
|||
}
|
||||
|
||||
func (p *ProfitTracker) Bind(tradeCollector *bbgo.TradeCollector, session *bbgo.ExchangeSession) {
|
||||
// TODO: Register kline close callback
|
||||
tradeCollector.OnProfit(func(trade types.Trade, profit *types.Profit) {
|
||||
p.AddProfit(*profit)
|
||||
})
|
||||
|
||||
tradeCollector.OnTrade(func(trade types.Trade, profit fixedpoint.Value, netProfit fixedpoint.Value) {
|
||||
|
||||
p.AddTrade(trade)
|
||||
})
|
||||
|
||||
// Rotate profitStats slice
|
||||
session.MarketDataStream.OnKLineClosed(types.KLineWith(p.market.Symbol, p.Interval, func(kline types.KLine) {
|
||||
|
||||
p.Rotate()
|
||||
}))
|
||||
}
|
||||
|
||||
|
@ -61,3 +61,7 @@ func (p *ProfitTracker) Rotate() {
|
|||
func (p *ProfitTracker) AddProfit(profit types.Profit) {
|
||||
(*p.currentProfitStats).AddProfit(profit)
|
||||
}
|
||||
|
||||
func (p *ProfitTracker) AddTrade(trade types.Trade) {
|
||||
(*p.currentProfitStats).AddTrade(trade)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user