append new postions as first item to slice

This commit is contained in:
Florian Schlegel
2017-11-22 12:27:57 +01:00
parent 97738f26f3
commit 9fe1cc99cd
+5 -1
View File
@@ -310,7 +310,11 @@ func (order *Order) SetPositionQuantity(itemID string, quantity float64, crossPr
if price != -1 {
newPos.Price = price
}
order.Positions = append(order.Positions, newPos)
// append new psoitions as first item
tmpPositions := []*Position{}
tmpPositions = append(tmpPositions, newPos)
tmpPositions = append(tmpPositions, order.Positions...)
order.Positions = tmpPositions
return order.Upsert()
}
return nil