mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 06:53:52 +00:00
bbgo/exit_protective_stop_loss: use types.KLineWith
This commit is contained in:
parent
2f575488c2
commit
d4f74822ad
|
@ -123,18 +123,14 @@ func (s *ProtectiveStopLoss) Bind(session *ExchangeSession, orderExecutor *Gener
|
|||
})
|
||||
|
||||
position := orderExecutor.Position()
|
||||
session.MarketDataStream.OnKLineClosed(func(kline types.KLine) {
|
||||
if kline.Symbol != position.Symbol || kline.Interval != types.Interval1m {
|
||||
return
|
||||
}
|
||||
|
||||
session.MarketDataStream.OnKLineClosed(types.KLineWith(s.Symbol, types.Interval1m, func(kline types.KLine) {
|
||||
isPositionOpened := !position.IsClosed() && !position.IsDust(kline.Close)
|
||||
if isPositionOpened {
|
||||
s.handleChange(context.Background(), position, kline.Close, s.orderExecutor)
|
||||
} else {
|
||||
s.stopLossPrice = fixedpoint.Zero
|
||||
}
|
||||
})
|
||||
}))
|
||||
|
||||
if !IsBackTesting && enableMarketTradeStop {
|
||||
session.MarketDataStream.OnMarketTrade(func(trade types.Trade) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user