balances can accept delta pushes for FAST

This commit is contained in:
Bel LaPointe
2023-10-25 06:41:04 -06:00
parent bece66b5b3
commit de4a8e9723
2 changed files with 17 additions and 4 deletions

View File

@@ -9,6 +9,20 @@ type Balances map[string]Balance
type Balance map[Currency]float64
func (balances Balances) Push(d Delta) {
if _, ok := balances[d.Name]; !ok {
balances[d.Name] = make(Balance)
}
balances[d.Name].Push(d)
}
func (balance Balance) Push(d Delta) {
if _, ok := balance[d.Currency]; !ok {
balance[d.Currency] = 0
}
balance[d.Currency] += d.Value
}
func (balances Balances) Debug() string {
result := []string{}
for k, v := range balances {