mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 23:05:15 +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()
|
position := orderExecutor.Position()
|
||||||
session.MarketDataStream.OnKLineClosed(func(kline types.KLine) {
|
session.MarketDataStream.OnKLineClosed(types.KLineWith(s.Symbol, types.Interval1m, func(kline types.KLine) {
|
||||||
if kline.Symbol != position.Symbol || kline.Interval != types.Interval1m {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
isPositionOpened := !position.IsClosed() && !position.IsDust(kline.Close)
|
isPositionOpened := !position.IsClosed() && !position.IsDust(kline.Close)
|
||||||
if isPositionOpened {
|
if isPositionOpened {
|
||||||
s.handleChange(context.Background(), position, kline.Close, s.orderExecutor)
|
s.handleChange(context.Background(), position, kline.Close, s.orderExecutor)
|
||||||
} else {
|
} else {
|
||||||
s.stopLossPrice = fixedpoint.Zero
|
s.stopLossPrice = fixedpoint.Zero
|
||||||
}
|
}
|
||||||
})
|
}))
|
||||||
|
|
||||||
if !IsBackTesting && enableMarketTradeStop {
|
if !IsBackTesting && enableMarketTradeStop {
|
||||||
session.MarketDataStream.OnMarketTrade(func(trade types.Trade) {
|
session.MarketDataStream.OnMarketTrade(func(trade types.Trade) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user