Skip to content

Commit

Permalink
doc: add TODO about priceAtPercentile not matching postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
eseidel committed Feb 25, 2024
1 parent 323009a commit ff52f2a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/cli/lib/cache/market_prices.dart
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ class MarketPriceSnapshot extends PricesCache<TradeSymbol, MarketPrice> {
// Sort the prices in ascending order.
final pricesForSymbolSorted = pricesForSymbol.toList()..sort(compareTo);
// Make sure that 100th percentile doesn't go out of bounds.
// TODO(eseidel): This doesn't match postgres' percentile_disc.
// percentile_disc will round up to the next index if the percentile
// doesn't match an exact index.
final index = min(
pricesForSymbolSorted.length * percentile ~/ 100,
pricesForSymbolSorted.length - 1,
Expand Down

0 comments on commit ff52f2a

Please sign in to comment.