grid2: pull out aggregateTradesQuantity func

This commit is contained in:
c9s 2022-12-06 15:40:57 +08:00
parent b4e403d632
commit 0cf43ffb11

View File

@ -222,11 +222,16 @@ func collectTradeFee(trades []types.Trade) map[string]fixedpoint.Value {
return fees
}
func (s *Strategy) verifyOrderTrades(o types.Order, trades []types.Trade) bool {
func aggregateTradesQuantity(trades []types.Trade) fixedpoint.Value {
tq := fixedpoint.Zero
for _, t := range trades {
tq = tq.Add(t.Quantity)
}
return tq
}
func (s *Strategy) verifyOrderTrades(o types.Order, trades []types.Trade) bool {
tq := aggregateTradesQuantity(trades)
if tq.Compare(o.Quantity) != 0 {
s.logger.Warnf("order trades missing. expected: %f actual: %f",