|
@@ -33,11 +33,11 @@ func (s alpacaQQQ) Interval() uint8 {
|
|
return 5
|
|
return 5
|
|
}
|
|
}
|
|
|
|
|
|
-func (s alpacaQQQ) Cooldown() time.Duration {
|
|
|
|
- return time.Minute * time.Duration(s.Interval()*6)
|
|
|
|
|
|
+func (s alpacaQQQ) Cooldown(periods uint8) time.Duration {
|
|
|
|
+ return time.Minute * time.Duration(s.Interval()*periods)
|
|
}
|
|
}
|
|
|
|
|
|
-func (s alpacaQQQ) Handle(market sentio.Market, proba float64) ([]sentio.StrategyOrder, error) {
|
|
|
|
|
|
+func (s alpacaQQQ) Handle(market sentio.Market, ts time.Time, proba float64) ([]sentio.StrategyOrder, error) {
|
|
var (
|
|
var (
|
|
portfolio sentio.Portfolio
|
|
portfolio sentio.Portfolio
|
|
orders []sentio.StrategyOrder
|
|
orders []sentio.StrategyOrder
|
|
@@ -105,6 +105,12 @@ func (s alpacaQQQ) Handle(market sentio.Market, proba float64) ([]sentio.Strateg
|
|
}}, nil
|
|
}}, nil
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Prevent BUYs for delayed probas
|
|
|
|
+ if ts.Add(time.Minute * time.Duration(int64(s.Interval()/2))).Before(now) {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Prevent BUYs on closing market
|
|
if now.Hour() == 15 && now.Minute() > 35 {
|
|
if now.Hour() == 15 && now.Minute() > 35 {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
@@ -112,7 +118,7 @@ func (s alpacaQQQ) Handle(market sentio.Market, proba float64) ([]sentio.Strateg
|
|
if sentio.LONG == side && proba > 1 {
|
|
if sentio.LONG == side && proba > 1 {
|
|
size := float64(0)
|
|
size := float64(0)
|
|
|
|
|
|
- if ok && position.GetAvgPrice() > position.GetCurrentPrice() {
|
|
|
|
|
|
+ if ok && position.GetAvgPrice()/position.GetCurrentPrice() > 1.002 {
|
|
// extra position with cheaper price
|
|
// extra position with cheaper price
|
|
size = .4
|
|
size = .4
|
|
} else if !ok && proba > 1.00065 {
|
|
} else if !ok && proba > 1.00065 {
|
|
@@ -134,7 +140,7 @@ func (s alpacaQQQ) Handle(market sentio.Market, proba float64) ([]sentio.Strateg
|
|
if sentio.SHORT == side && proba < 1 {
|
|
if sentio.SHORT == side && proba < 1 {
|
|
size := float64(0)
|
|
size := float64(0)
|
|
|
|
|
|
- if ok && position.GetAvgPrice() > position.GetCurrentPrice() {
|
|
|
|
|
|
+ if ok && position.GetAvgPrice()/position.GetCurrentPrice() > 1.002 {
|
|
// extra position with cheaper price
|
|
// extra position with cheaper price
|
|
size = .4
|
|
size = .4
|
|
} else if !ok && proba < .9992 {
|
|
} else if !ok && proba < .9992 {
|