|
@@ -101,9 +101,9 @@ func (s alpacaQQQ) Handle(market sentio.Market, proba float64) ([]sentio.Strateg
|
|
|
Action: sentio.OrderBuy,
|
|
|
Ratio: func() float64 {
|
|
|
if ok {
|
|
|
- return .6
|
|
|
+ return .4
|
|
|
} else {
|
|
|
- return .3
|
|
|
+ return .6
|
|
|
}
|
|
|
}(),
|
|
|
})
|
|
@@ -111,18 +111,37 @@ func (s alpacaQQQ) Handle(market sentio.Market, proba float64) ([]sentio.Strateg
|
|
|
}
|
|
|
|
|
|
if sentio.SHORT == side && proba < .9997 {
|
|
|
+ var (
|
|
|
+ sma []float64
|
|
|
+ lb sentio.Bar
|
|
|
+ )
|
|
|
+
|
|
|
+ // prevent extra orders if our position is cheaper
|
|
|
if ok && position != nil && position.GetCurrentPrice() > position.GetAvgPrice() {
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
+ if sma = market.SMA(s.PositionSymbols()[sentio.LONG], 15, 8, 1); sma == nil || len(sma) < 1 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ if lb, err = market.LatestBar(s.PositionSymbols()[sentio.LONG]); err != nil {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ // prevent SHORTing if current price is under SMA(8)
|
|
|
+ if lb.Close/sma[0] < 1.002 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
orders = append(orders, sentio.StrategyOrder{
|
|
|
Symbol: symbol,
|
|
|
Action: sentio.OrderBuy,
|
|
|
Ratio: func() float64 {
|
|
|
if ok {
|
|
|
- return .6
|
|
|
+ return .4
|
|
|
} else {
|
|
|
- return .3
|
|
|
+ return .6
|
|
|
}
|
|
|
}(),
|
|
|
})
|