mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
fix distribution chart
This commit is contained in:
parent
54a5e41c4f
commit
261da73a9a
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"github.com/c9s/bbgo/pkg/bbgo/types"
|
||||
"math"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
@ -58,6 +59,7 @@ type StockManager struct {
|
|||
}
|
||||
|
||||
type Distribution struct {
|
||||
PriceLevels []int `json:"priceLevels"`
|
||||
Quantities map[int]float64 `json:"quantities"`
|
||||
Stocks map[int]StockSlice `json:"stocks"`
|
||||
}
|
||||
|
@ -78,6 +80,12 @@ func (m *StockManager) Distribution(level int) *Distribution {
|
|||
d.Quantities[priceLevel] += stock.Quantity
|
||||
}
|
||||
|
||||
for level := range d.Stocks {
|
||||
d.PriceLevels = append(d.PriceLevels, level)
|
||||
}
|
||||
|
||||
sort.Ints(d.PriceLevels)
|
||||
|
||||
return &d
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user