2
0
Alexey Kim 1 долоо хоног өмнө
parent
commit
92f7a9a036

+ 5 - 2
strategy/alpaca/qqq15/strategy.go

@@ -11,7 +11,7 @@ const (
 	ATR_MULTIPLIER         = 1.5
 	ATR_PERIOD             = 14
 	ATR_HHV                = 10
-	ATR_STOPLOSS_THRESHOLD = 1
+	ATR_STOPLOSS_THRESHOLD = .998
 
 	EXTRA_POSITION_THRESHOLD = 1.002
 )
@@ -87,7 +87,6 @@ func (s alpacaQQQ) Handle(market sentio.Market, ts time.Time, proba float64) ([]
 		fmt.Printf("Quotes: %s [BID: %f] [ASK: %s]\n", symbol, quote.BidPrice, quote.AskPrice)
 
 		if bars, err = market.HistoricalBars(symbol, time.Minute, nil); err == nil && len(bars) > 0 {
-			fmt.Printf("HistoricalBars: %s", bars[len(bars)-1].Datetime.Format(time.RFC3339))
 			h := make([]float64, len(bars))
 			l := make([]float64, len(bars))
 			c := make([]float64, len(bars))
@@ -162,6 +161,10 @@ func (s alpacaQQQ) Handle(market sentio.Market, ts time.Time, proba float64) ([]
 			continue
 		}
 
+		if quote.BidPrice/stoploss < ATR_STOPLOSS_THRESHOLD {
+			continue
+		}
+
 		if sentio.LONG == side && proba > 1 {
 			size := float64(0)
 

+ 5 - 1
strategy/alpaca/qqq15_nodelay/strategy.go

@@ -11,7 +11,7 @@ const (
 	ATR_MULTIPLIER         = 1.5
 	ATR_PERIOD             = 14
 	ATR_HHV                = 10
-	ATR_STOPLOSS_THRESHOLD = 1
+	ATR_STOPLOSS_THRESHOLD = .998
 
 	EXTRA_POSITION_THRESHOLD = 1.002
 )
@@ -156,6 +156,10 @@ func (s alpacaQQQ) Handle(market sentio.Market, ts time.Time, proba float64) ([]
 			continue
 		}
 
+		if quote.BidPrice/stoploss < ATR_STOPLOSS_THRESHOLD {
+			continue
+		}
+
 		if sentio.LONG == side && proba > 1 {
 			size := float64(0)