소스 검색

Strategies

- get rid of legacy strategies
Alexey Kim 1 개월 전
부모
커밋
f9d54b90c3
2개의 변경된 파일0개의 추가작업 그리고 315개의 파일을 삭제
  1. 0 179
      strategy/alpaca/qqq06f/strategy.go
  2. 0 136
      strategy/alpaca/qqq30/strategy.go

+ 0 - 179
strategy/alpaca/qqq06f/strategy.go

@@ -1,179 +0,0 @@
-package main
-
-import (
-	"git.beejay.kim/Gshopper/sentio"
-)
-
-var Strategy = alpacaQQQ{}
-
-type alpacaQQQ struct{}
-
-func (s alpacaQQQ) Name() string {
-	return "Alpaca: QQQ / SQQQ"
-}
-
-func (s alpacaQQQ) Model() string {
-	return "qqq06f"
-}
-
-func (s alpacaQQQ) MarketId() string {
-	return "alpaca"
-}
-
-func (s alpacaQQQ) PositionSymbols() map[sentio.Side]string {
-	return map[sentio.Side]string{
-		sentio.LONG:  "QQQ",
-		sentio.SHORT: "SQQQ",
-	}
-}
-
-func (s alpacaQQQ) Handle(market sentio.Market, proba float64) ([]sentio.StrategyOrder, error) {
-	if !market.IsMarketOpened() {
-		return nil, sentio.ErrMarketClosed
-	}
-
-	var (
-		portfolio sentio.Portfolio
-		orders    []sentio.StrategyOrder
-		ok        bool
-		err       error
-	)
-
-	if portfolio, err = market.Portfolio(); err != nil {
-		return nil, err
-	}
-
-	for side, symbol := range s.PositionSymbols() {
-		var (
-			position sentio.Position
-			t        = market.Time().Now()
-		)
-
-		if portfolio != nil {
-			position, ok = portfolio.Get(symbol)
-			ok = ok && position.GetSize() != 0
-		} else {
-			ok = false
-		}
-
-		// Close positions before market closed
-		if ok && t.Hour() == 19 && t.Minute() > 30 {
-			orders = append(orders, sentio.StrategyOrder{
-				Symbol: symbol,
-				Action: sentio.OrderSell,
-				Ratio:  1,
-			})
-			continue
-		}
-
-		if proba < 0 {
-			continue
-		}
-
-		// Close LONG position
-		if ok && sentio.LONG == side && proba < 1.00009 {
-			orders = append(orders, sentio.StrategyOrder{
-				Symbol: symbol,
-				Action: sentio.OrderSell,
-				Ratio:  1,
-			})
-		}
-
-		if ok && sentio.SHORT == side && proba > .9999 {
-			orders = append(orders, sentio.StrategyOrder{
-				Symbol: symbol,
-				Action: sentio.OrderSell,
-				Ratio:  1,
-			})
-		}
-
-		if t.Hour() == 19 && t.Minute() > 29 {
-			continue
-		}
-
-		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.DEMA(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 LONG positions if current price is greater 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 .3
-					}
-
-					if ok {
-						return .4
-					} else {
-						return .6
-					}
-				}(),
-			})
-			continue
-		}
-
-		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 t.Hour() >= 16 {
-						return .3
-					}
-
-					if ok {
-						return .4
-					} else {
-						return .6
-					}
-				}(),
-			})
-			continue
-		}
-	}
-
-	return orders, nil
-}

+ 0 - 136
strategy/alpaca/qqq30/strategy.go

@@ -1,136 +0,0 @@
-package main
-
-import (
-	"git.beejay.kim/Gshopper/sentio"
-)
-
-var Strategy = alpacaQQQ{}
-
-type alpacaQQQ struct{}
-
-func (s alpacaQQQ) Name() string {
-	return "Alpaca: QQQ / SQQQ"
-}
-
-func (s alpacaQQQ) Model() string {
-	return "qqq001"
-}
-
-func (s alpacaQQQ) MarketId() string {
-	return "alpaca"
-}
-
-func (s alpacaQQQ) PositionSymbols() map[sentio.Side]string {
-	return map[sentio.Side]string{
-		sentio.LONG:  "QQQ",
-		sentio.SHORT: "SQQQ",
-	}
-}
-
-func (s alpacaQQQ) Handle(market sentio.Market, proba float64) ([]sentio.StrategyOrder, error) {
-	if !market.IsMarketOpened() {
-		return nil, sentio.ErrMarketClosed
-	}
-
-	var (
-		portfolio sentio.Portfolio
-		orders    []sentio.StrategyOrder
-		ok        bool
-		err       error
-	)
-
-	if portfolio, err = market.Portfolio(); err != nil {
-		return nil, err
-	}
-
-	for side, symbol := range s.PositionSymbols() {
-		var (
-			position sentio.Position
-			t        = market.Time().Now()
-		)
-
-		if portfolio != nil {
-			position, ok = portfolio.Get(symbol)
-			ok = ok && position.GetSize() != 0
-		} else {
-			ok = false
-		}
-
-		// Close positions before market closed
-		if ok && t.Hour() >= 19 && t.Minute() >= 30 {
-			orders = append(orders, sentio.StrategyOrder{
-				Symbol: symbol,
-				Action: sentio.OrderSell,
-				Ratio:  1,
-			})
-			continue
-		}
-
-		if proba < 0 {
-			continue
-		}
-
-		// Close LONG position
-		if ok && sentio.LONG == side && proba < 1 {
-			orders = append(orders, sentio.StrategyOrder{
-				Symbol: symbol,
-				Action: sentio.OrderSell,
-				Ratio:  1,
-			})
-			continue
-		}
-
-		if ok && sentio.SHORT == side && proba > 1 {
-			orders = append(orders, sentio.StrategyOrder{
-				Symbol: symbol,
-				Action: sentio.OrderSell,
-				Ratio:  1,
-			})
-			continue
-		}
-
-		if t.Hour() == 19 && t.Minute() >= 30 {
-			continue
-		}
-
-		if sentio.LONG == side && proba > 1.001 {
-			if ok && position != nil && position.GetCurrentPrice() > position.GetAvgPrice() {
-				continue
-			}
-
-			orders = append(orders, sentio.StrategyOrder{
-				Symbol: symbol,
-				Action: sentio.OrderBuy,
-				Ratio: func() float64 {
-					if ok {
-						return .3
-					} else {
-						return .6
-					}
-				}(),
-			})
-			continue
-		}
-
-		if sentio.SHORT == side && proba < .9998 {
-			if ok && position != nil && position.GetCurrentPrice() > position.GetAvgPrice() {
-				continue
-			}
-
-			orders = append(orders, sentio.StrategyOrder{
-				Symbol: symbol,
-				Action: sentio.OrderBuy,
-				Ratio: func() float64 {
-					if ok {
-						return .3
-					} else {
-						return .8
-					}
-				}(),
-			})
-			continue
-		}
-	}
-
-	return orders, nil
-}