In some cases, users should see a brief overview of the orderbook. For instance, user A should see the following representation of both the queues in the orderbook:
In the suggested changes, I have added a MarketView method that delivers the expected info in the map[string]decimal.Decimal in which keys are prices and the values are quantities.
Why strings as the keys? I used built-in string type rather than decimal.Decimal since the latter creates two objects for very same numbers:
a := decimal.NewFromFloat(1)
b := decimal.NewFromFloat(1)
fmt.Printf("%v and %v are equal? %v\n", a, b, a == b)
// 1 and 1 are equal? false
In some cases, users should see a brief overview of the orderbook. For instance, user A should see the following representation of both the queues in the orderbook:
In the suggested changes, I have added a MarketView method that delivers the expected info in the
map[string]decimal.Decimal
in which keys are prices and the values are quantities.Why strings as the keys? I used built-in string type rather than decimal.Decimal since the latter creates two objects for very same numbers: