2
0
Pārlūkot izejas kodu

QQQ07f

- trade TQQQ for LONG positions
- enhance proba
Alexey Kim 1 mēnesi atpakaļ
vecāks
revīzija
47d6323ee1
3 mainītis faili ar 18 papildinājumiem un 6 dzēšanām
  1. 2 0
      side.go
  2. 5 0
      side_test.go
  3. 11 6
      strategy/alpaca/qqq07f/strategy.go

+ 2 - 0
side.go

@@ -10,11 +10,13 @@ type Side int
 const (
 	LONG Side = iota
 	SHORT
+	BASE
 )
 
 var sides = map[Side]string{
 	LONG:  "LONG",
 	SHORT: "SHORT",
+	BASE:  "BASE",
 }
 
 func (s Side) String() string {

+ 5 - 0
side_test.go

@@ -33,6 +33,11 @@ func TestSideFromString(t *testing.T) {
 			want:    -1,
 			wantErr: true,
 		},
+		{
+			arg:     "base",
+			want:    BASE,
+			wantErr: false,
+		},
 	}
 
 	for _, tt := range tests {

+ 11 - 6
strategy/alpaca/qqq07f/strategy.go

@@ -9,7 +9,7 @@ var Strategy = alpacaQQQ{}
 type alpacaQQQ struct{}
 
 func (s alpacaQQQ) Name() string {
-	return "Alpaca: QQQ / SQQQ"
+	return "Alpaca: QQQ [TQQQ : SQQQ]"
 }
 
 func (s alpacaQQQ) Model() string {
@@ -22,7 +22,8 @@ func (s alpacaQQQ) MarketId() string {
 
 func (s alpacaQQQ) PositionSymbols() map[sentio.Side]string {
 	return map[sentio.Side]string{
-		sentio.LONG:  "QQQ",
+		sentio.BASE:  "QQQ",
+		sentio.LONG:  "TQQQ",
 		sentio.SHORT: "SQQQ",
 	}
 }
@@ -44,6 +45,10 @@ func (s alpacaQQQ) Handle(market sentio.Market, proba float64) ([]sentio.Strateg
 	}
 
 	for side, symbol := range s.PositionSymbols() {
+		if sentio.BASE == side {
+			continue
+		}
+
 		var (
 			position sentio.Position
 			t        = market.Time().Now()
@@ -91,7 +96,7 @@ func (s alpacaQQQ) Handle(market sentio.Market, proba float64) ([]sentio.Strateg
 			continue
 		}
 
-		if sentio.LONG == side && proba > 1.00109 {
+		if sentio.LONG == side && proba > 1.00119 {
 			if ok && position != nil && position.GetCurrentPrice() > position.GetAvgPrice() {
 				continue
 			}
@@ -100,7 +105,7 @@ func (s alpacaQQQ) Handle(market sentio.Market, proba float64) ([]sentio.Strateg
 				Symbol: symbol,
 				Action: sentio.OrderBuy,
 				Ratio: func() float64 {
-					if t.Hour() >= 16 {
+					if t.Hour() >= 18 {
 						return .3
 					}
 
@@ -114,7 +119,7 @@ func (s alpacaQQQ) Handle(market sentio.Market, proba float64) ([]sentio.Strateg
 			continue
 		}
 
-		if sentio.SHORT == side && proba < .9998 {
+		if sentio.SHORT == side && proba < .99955 {
 			// prevent extra orders if our position is cheaper
 			if ok && position != nil && position.GetCurrentPrice() > position.GetAvgPrice() {
 				continue
@@ -124,7 +129,7 @@ func (s alpacaQQQ) Handle(market sentio.Market, proba float64) ([]sentio.Strateg
 				Symbol: symbol,
 				Action: sentio.OrderBuy,
 				Ratio: func() float64 {
-					if t.Hour() >= 16 {
+					if t.Hour() >= 18 {
 						return .3
 					}