2
0
Quellcode durchsuchen

Market v2

- draft
Alexey Kim vor 3 Tagen
Ursprung
Commit
b5dbf91943
2 geänderte Dateien mit 6 neuen und 14 gelöschten Zeilen
  1. 2 10
      market.go
  2. 4 4
      strategy/alpaca/qqq15/strategy.go

+ 2 - 10
market.go

@@ -51,10 +51,6 @@ func (criteria OrderListCriteria) Values() map[string]string {
 		criteria.Limit = 500
 	}
 
-	if s := strings.TrimSpace(criteria.Status); s != "" {
-		values["status"] = s
-	}
-
 	if criteria.Symbols != nil && len(criteria.Symbols) > 0 {
 		values["symbols"] = strings.Join(criteria.Symbols, ",")
 	}
@@ -68,16 +64,12 @@ func (criteria OrderListCriteria) Values() map[string]string {
 		values["until"] = criteria.Until.In(time.UTC).Format(time.RFC3339)
 	}
 
-	if criteria.Nested {
-		values["nested"] = "true"
-	} else {
-		values["nested"] = "false"
-	}
-
 	if criteria.Side != nil {
 		values["side"] = *criteria.Side
 	}
 
+	values["status"] = strings.TrimSpace(criteria.Status)
+	values["nested"] = "true"
 	values["limit"] = fmt.Sprintf("%d", criteria.Limit)
 	values["after"] = criteria.After.In(time.UTC).Format(time.RFC3339)
 	values["direction"] = "asc"

+ 4 - 4
strategy/alpaca/qqq15/strategy.go

@@ -199,12 +199,12 @@ func (strategy qqq) AtrStopLoss(market sentio.Market, symbols ...string) (map[st
 		return nil, err
 	}
 
-	if bars == nil || len(bars) < ATR_PERIOD {
-		return nil, errors.New("AtrStopLoss: could not calculate stoploss for too short timeseries")
-	}
-
 	stoplosses = make(map[string]float64)
 	for s := range bars {
+		if bars == nil || len(bars[s]) < ATR_PERIOD {
+			return nil, errors.New("AtrStopLoss: could not calculate stoploss for too short timeseries")
+		}
+
 		h := make([]float64, len(bars[s]))
 		l := make([]float64, len(bars[s]))
 		c := make([]float64, len(bars[s]))