check symbol for the position update

This commit is contained in:
c9s 2021-01-20 17:37:23 +08:00
parent 48dd697ce3
commit 8a08c406c3
2 changed files with 5 additions and 1 deletions

View File

@ -217,6 +217,8 @@ func (environ *Environment) Init(ctx context.Context) (err error) {
}
session.positions[symbol] = position
position.BindStream(session.Stream)
session.Trades[symbol] = trades
session.lastPrices[symbol] = 0.0

View File

@ -14,7 +14,9 @@ type Position struct {
func (p *Position) BindStream(stream types.Stream) {
stream.OnTradeUpdate(func(trade types.Trade) {
p.AddTrade(trade)
if p.Symbol == trade.Symbol {
p.AddTrade(trade)
}
})
}