Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create OHLC aggregate and accompanying accessors #496

Merged
merged 2 commits into from
Aug 16, 2022
Merged

Create OHLC aggregate and accompanying accessors #496

merged 2 commits into from
Aug 16, 2022

Conversation

rtwalker
Copy link
Contributor

@rtwalker rtwalker commented Aug 15, 2022

Begins to address #445.

Introduces OHLC aggregate called as toolkit_experimental.ohlc(timestamp, price).

The following accessors are provided for use with the OpenHighLowClose aggregate:

  • open, high, low, close

along with the timestamp-returning versions:

  • open_at, high_at, low_at, close_at

Additionally, there is a new toolkit_experimental.rollup() aggregate that takes OpenHighLowClose aggregates as input.

In the event that multiple rows contain the highest or lowest value, only the earliest occurrence is retained. Similarly, should multiple rows contain the opening or closing timestamp, this implementation only updates the open/close points with a new value when the new timestamp is strictly earlier/later than current timestamp.

Additional work on #445 remains to address handling volume (and possibly creating technical indicators).

Copy link
Contributor

@WireBaron WireBaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't really have any feedback aside what came up at all hands this morning.

extension/src/ohlc.rs Outdated Show resolved Hide resolved
extension/src/ohlc.rs Outdated Show resolved Hide resolved
@rtwalker
Copy link
Contributor Author

Added tests for extreme values in both the timestamp and price columns. Also required OpenHighLowClose::new() to take a TSPoint and got rid of default values.

Copy link
Contributor

@WireBaron WireBaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@rtwalker
Copy link
Contributor Author

bors r+

@bors
Copy link
Contributor

bors bot commented Aug 16, 2022

@bors bors bot merged commit d897639 into main Aug 16, 2022
@bors bors bot deleted the rw/ohlc branch August 16, 2022 20:16
bors bot added a commit that referenced this pull request Nov 7, 2022
596: Introduce Candlestick Aggregate r=rtwalker a=rtwalker

Use new Candlestick struct to handle volume data.

Introduces aggregate:
 * `toolkit_experimental.candlestick_agg(ts, price, volume)`

and function:
 * `toolkit_experimental.candlestick(ts, open, high, low, close, volume)`

Both new aggregates support the following accessors (in addition to being re-aggregated via `rollup`):
 * `open`
 * `high`
 * `low`
 * `close`
 * `open_time`
 * `high_time`
 * `low_time`
 * `close_time`
 * `volume`
 * `vwap` (Volume Weighted Average Price) 

VWAP calculated from the candlestick function uses typical price = (high + low + close) / 3

The original `toolkit_experimental.ohlc(ts, price)` aggregate should still work the same, but will be superseded by this new functionality. 

Closes #496 

Co-authored-by: Ryan Walker <rwalker@timescale.com>
Co-authored-by: Eric Gillespie <epg@timescale.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants