diff --git a/client/core/core.go b/client/core/core.go index 63dc55e23f..4712b36139 100644 --- a/client/core/core.go +++ b/client/core/core.go @@ -5766,23 +5766,23 @@ type MultiTradeResult struct { // MultiTrade is used to place multiple standing limit orders on the same // side of the same market simultaneously. func (c *Core) MultiTrade(pw []byte, form *MultiTradeForm) []*MultiTradeResult { - results := make([]*MultiTradeResult, len(form.Placements)) + results := make([]*MultiTradeResult, 0, len(form.Placements)) reqs, err := c.prepareMultiTradeRequests(pw, form) if err != nil { - for i := range results { - results[i] = &MultiTradeResult{Error: err} + for range form.Placements { + results = append(results, &MultiTradeResult{Error: err}) } return results } - for i, req := range reqs { + for _, req := range reqs { var corder *Order corder, err = c.sendTradeRequest(req) if err != nil { - results[i] = &MultiTradeResult{Error: err} + results = append(results, &MultiTradeResult{Error: err}) continue } - results[i] = &MultiTradeResult{Order: corder} + results = append(results, &MultiTradeResult{Order: corder}) } return results