From 329aa39d2669956132386dccce6c10378343df6b Mon Sep 17 00:00:00 2001 From: c9s Date: Tue, 11 Aug 2020 10:27:41 +0800 Subject: [PATCH] add total quantity field --- bbgo/stock.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bbgo/stock.go b/bbgo/stock.go index 07e7b5e73..c4acc283e 100644 --- a/bbgo/stock.go +++ b/bbgo/stock.go @@ -60,6 +60,7 @@ type StockManager struct { type Distribution struct { PriceLevels []int `json:"priceLevels"` + TotalQuantity float64 `json:"totalQuantity"` Quantities map[int]float64 `json:"quantities"` Stocks map[int]StockSlice `json:"stocks"` } @@ -76,6 +77,7 @@ func (m *StockManager) Distribution(level int) *Distribution { div := math.Pow10(digits) priceLevel := int(math.Floor(stock.Price / div) * div) + d.TotalQuantity += stock.Quantity d.Stocks[priceLevel] = append(d.Stocks[priceLevel], stock) d.Quantities[priceLevel] += stock.Quantity }