Bladeren bron

Market v2

- draft
Alexey Kim 6 dagen geleden
bovenliggende
commit
b5dbf91943
2 gewijzigde bestanden met toevoegingen van 6 en 14 verwijderingen
  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]))