mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 00:05:15 +00:00
FIX: deactivate exit when position in closing
This commit is contained in:
parent
4bf93b3bfa
commit
a4ccad9463
|
@ -15,7 +15,6 @@ import (
|
||||||
// To query the historical quote volume, use the following query:
|
// To query the historical quote volume, use the following query:
|
||||||
//
|
//
|
||||||
// > SELECT start_time, `interval`, quote_volume, open, close FROM binance_klines WHERE symbol = 'ETHUSDT' AND `interval` = '5m' ORDER BY quote_volume DESC LIMIT 20;
|
// > SELECT start_time, `interval`, quote_volume, open, close FROM binance_klines WHERE symbol = 'ETHUSDT' AND `interval` = '5m' ORDER BY quote_volume DESC LIMIT 20;
|
||||||
//
|
|
||||||
type CumulatedVolumeTakeProfit struct {
|
type CumulatedVolumeTakeProfit struct {
|
||||||
Symbol string `json:"symbol"`
|
Symbol string `json:"symbol"`
|
||||||
|
|
||||||
|
@ -39,7 +38,7 @@ func (s *CumulatedVolumeTakeProfit) Bind(session *ExchangeSession, orderExecutor
|
||||||
session.MarketDataStream.OnKLineClosed(types.KLineWith(s.Symbol, s.Interval, func(kline types.KLine) {
|
session.MarketDataStream.OnKLineClosed(types.KLineWith(s.Symbol, s.Interval, func(kline types.KLine) {
|
||||||
closePrice := kline.Close
|
closePrice := kline.Close
|
||||||
openPrice := kline.Open
|
openPrice := kline.Open
|
||||||
if position.IsClosed() || position.IsDust(closePrice) {
|
if position.IsClosed() || position.IsDust(closePrice) || position.IsClosing() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ func (s *HigherHighLowerLowStop) Subscribe(session *ExchangeSession) {
|
||||||
// determine whether this stop should be activated
|
// determine whether this stop should be activated
|
||||||
func (s *HigherHighLowerLowStop) updateActivated(position *types.Position, closePrice fixedpoint.Value) {
|
func (s *HigherHighLowerLowStop) updateActivated(position *types.Position, closePrice fixedpoint.Value) {
|
||||||
// deactivate when no position
|
// deactivate when no position
|
||||||
if position.IsClosed() || position.IsDust(closePrice) {
|
if position.IsClosed() || position.IsDust(closePrice) || position.IsClosing() {
|
||||||
|
|
||||||
s.activated = false
|
s.activated = false
|
||||||
return
|
return
|
||||||
|
|
|
@ -30,11 +30,10 @@ func (s *LowerShadowTakeProfit) Bind(session *ExchangeSession, orderExecutor *Ge
|
||||||
stdIndicatorSet := session.StandardIndicatorSet(s.Symbol)
|
stdIndicatorSet := session.StandardIndicatorSet(s.Symbol)
|
||||||
ewma := stdIndicatorSet.EWMA(s.IntervalWindow)
|
ewma := stdIndicatorSet.EWMA(s.IntervalWindow)
|
||||||
|
|
||||||
|
|
||||||
position := orderExecutor.Position()
|
position := orderExecutor.Position()
|
||||||
session.MarketDataStream.OnKLineClosed(types.KLineWith(s.Symbol, s.Interval, func(kline types.KLine) {
|
session.MarketDataStream.OnKLineClosed(types.KLineWith(s.Symbol, s.Interval, func(kline types.KLine) {
|
||||||
closePrice := kline.Close
|
closePrice := kline.Close
|
||||||
if position.IsClosed() || position.IsDust(closePrice) {
|
if position.IsClosed() || position.IsDust(closePrice) || position.IsClosing() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ func (s *RoiStopLoss) Bind(session *ExchangeSession, orderExecutor *GeneralOrder
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *RoiStopLoss) checkStopPrice(closePrice fixedpoint.Value, position *types.Position) {
|
func (s *RoiStopLoss) checkStopPrice(closePrice fixedpoint.Value, position *types.Position) {
|
||||||
if position.IsClosed() || position.IsDust(closePrice) {
|
if position.IsClosed() || position.IsDust(closePrice) || position.IsClosing() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ func (s *RoiTakeProfit) Bind(session *ExchangeSession, orderExecutor *GeneralOrd
|
||||||
position := orderExecutor.Position()
|
position := orderExecutor.Position()
|
||||||
session.MarketDataStream.OnKLineClosed(types.KLineWith(s.Symbol, types.Interval1m, func(kline types.KLine) {
|
session.MarketDataStream.OnKLineClosed(types.KLineWith(s.Symbol, types.Interval1m, func(kline types.KLine) {
|
||||||
closePrice := kline.Close
|
closePrice := kline.Close
|
||||||
if position.IsClosed() || position.IsDust(closePrice) {
|
if position.IsClosed() || position.IsDust(closePrice) || position.IsClosing() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ func (s *TrailingStop2) getRatio(price fixedpoint.Value, position *types.Positio
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TrailingStop2) checkStopPrice(price fixedpoint.Value, position *types.Position) error {
|
func (s *TrailingStop2) checkStopPrice(price fixedpoint.Value, position *types.Position) error {
|
||||||
if position.IsClosed() || position.IsDust(price) {
|
if position.IsClosed() || position.IsDust(price) || position.IsClosing() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user