domain specific functions for finance and aggregation
#4.620 aberto em 29 de mai. de 2024
Métricas do repositório
- Stars
- (13.403 stars)
- Métricas de merge de PR
- (Mesclagem média 5d 13h) (108 fundiu PRs em 30d)
Description
Is your feature request related to a problem?
Many users of QuestDB are in the finance industry. Within this domain, there are common operations that can be complicated to represent in standard SQL.
We should add functions to make these operations easier for our users, and start with the most common operations.
Such functions should support ARRAY types in future, where useful for performance improvements.
This is a tracking issue, and we welcome suggestions from users!
Describe the solution you'd like.
More domain-specific finance functions around trading and order books.
- l2price: level two order-book price
- vwap: volume-weighted average price
- twap: time-weighted average price
- avg: avg window function, can be used to calculate simple moving average
- vwma: volume-weighted moving average (window)
- Issue: https://github.com/questdb/questdb/issues/4727
- not looking for contributions, some internal work needed
- mid(bid,ask):
average(bid, ask) = bid+ask / 2 - spread(bid, ask):
ask-bid - wmid(bid_size, bid, ask, ask_size): weighted mid point:
wmid = (imbalance * ask_price) + (1 - imbalance) * bid_pricewhereimbalance = bid_size / (bid_size + ask_size)- Issue: https://github.com/questdb/questdb/issues/4800
- PR: https://github.com/questdb/questdb/pull/4801
- spread_bps(bid, ask):
spread(bid,ask)/mid(bid,ask) * 10,000 - format_price(decimal_form, tick_size): treasury price format, decimal to fraction, e.g.
format_price(100.5, 32)= 100-16 - get_price(fraction_form, tick_size): treasury price format, fraction to decimal, e.g.
format_price(100-16, 32)= 100.5
More aggregation functions:
- normalised_perf(column, base_value):
base_value x column[i] / column[0] - regr_slope(y, x): https://duckdb.org/docs/sql/aggregates.html#regr_slopey-x
- regr_intercept(y, x): https://duckdb.org/docs/sql/aggregates.html#regr_intercepty-x
Convenience functions:
- to_bbg(Ø): convert a RIC code to a Bloomberg symbol
- to_ric(Ø): convert a Bloomberg symbol to a RIC code
And similar. Names are flexible!
Aggregation functions should be linked in the finance section where relevant, with an associated finance example.
- GT Join
Describe alternatives you've considered.
No response
Full Name:
Nick Woolmer
Affiliation:
QuestDB
Additional context
No response