|
@@ -92,16 +92,34 @@ func (s alpacaQQQ) Handle(market sentio.Market, proba float64) ([]sentio.Strateg
|
|
|
}
|
|
|
|
|
|
if sentio.LONG == side && proba > 1.00109 {
|
|
|
+ var (
|
|
|
+ dema []float64
|
|
|
+ lb *sentio.Bar
|
|
|
+ )
|
|
|
+
|
|
|
if ok && position != nil && position.GetCurrentPrice() > position.GetAvgPrice() {
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
+ if dema = market.SMA(s.PositionSymbols()[sentio.LONG], 15, 8, 1); dema == nil || len(dema) < 1 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ if lb, err = market.LatestBar(s.PositionSymbols()[sentio.LONG]); err != nil {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ // prevent SHORTing if current price is under DEMA(8)
|
|
|
+ if lb.Close/dema[0] < .999 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
orders = append(orders, sentio.StrategyOrder{
|
|
|
Symbol: symbol,
|
|
|
Action: sentio.OrderBuy,
|
|
|
Ratio: func() float64 {
|
|
|
if t.Hour() >= 16 {
|
|
|
- return .1
|
|
|
+ return .3
|
|
|
}
|
|
|
|
|
|
if ok {
|
|
@@ -143,7 +161,7 @@ func (s alpacaQQQ) Handle(market sentio.Market, proba float64) ([]sentio.Strateg
|
|
|
Action: sentio.OrderBuy,
|
|
|
Ratio: func() float64 {
|
|
|
if t.Hour() >= 16 {
|
|
|
- return .1
|
|
|
+ return .3
|
|
|
}
|
|
|
|
|
|
if ok {
|