mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +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:
|
||||
//
|
||||
// > 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 {
|
||||
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) {
|
||||
closePrice := kline.Close
|
||||
openPrice := kline.Open
|
||||
if position.IsClosed() || position.IsDust(closePrice) {
|
||||
if position.IsClosed() || position.IsDust(closePrice) || position.IsClosing() {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ func (s *HigherHighLowerLowStop) Subscribe(session *ExchangeSession) {
|
|||
// determine whether this stop should be activated
|
||||
func (s *HigherHighLowerLowStop) updateActivated(position *types.Position, closePrice fixedpoint.Value) {
|
||||
// deactivate when no position
|
||||
if position.IsClosed() || position.IsDust(closePrice) {
|
||||
if position.IsClosed() || position.IsDust(closePrice) || position.IsClosing() {
|
||||
|
||||
s.activated = false
|
||||
return
|
||||
|
|
|
@ -30,11 +30,10 @@ func (s *LowerShadowTakeProfit) Bind(session *ExchangeSession, orderExecutor *Ge
|
|||
stdIndicatorSet := session.StandardIndicatorSet(s.Symbol)
|
||||
ewma := stdIndicatorSet.EWMA(s.IntervalWindow)
|
||||
|
||||
|
||||
position := orderExecutor.Position()
|
||||
session.MarketDataStream.OnKLineClosed(types.KLineWith(s.Symbol, s.Interval, func(kline types.KLine) {
|
||||
closePrice := kline.Close
|
||||
if position.IsClosed() || position.IsDust(closePrice) {
|
||||
if position.IsClosed() || position.IsDust(closePrice) || position.IsClosing() {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ func (s *RoiStopLoss) Bind(session *ExchangeSession, orderExecutor *GeneralOrder
|
|||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ func (s *RoiTakeProfit) Bind(session *ExchangeSession, orderExecutor *GeneralOrd
|
|||
position := orderExecutor.Position()
|
||||
session.MarketDataStream.OnKLineClosed(types.KLineWith(s.Symbol, types.Interval1m, func(kline types.KLine) {
|
||||
closePrice := kline.Close
|
||||
if position.IsClosed() || position.IsDust(closePrice) {
|
||||
if position.IsClosed() || position.IsDust(closePrice) || position.IsClosing() {
|
||||
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 {
|
||||
if position.IsClosed() || position.IsDust(price) {
|
||||
if position.IsClosed() || position.IsDust(price) || position.IsClosing() {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user