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

Feat/candlesticks #289

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft

Feat/candlesticks #289

wants to merge 12 commits into from

Conversation

jonasvdd
Copy link
Member

@jonasvdd jonasvdd commented Jan 13, 2024

related: #288, #98

TODO:

  • do we need to lock tsdownsample version (as we now have a hard lock-in on tsdownsample's m4 implementation)?
  • maybe allow the users to configure the candlestick position? (middle of bucket, begin (as it is now), or end)
  • write docs (and focus on limitations)
  • create examples
  • write tests (few datapoints, large zoom-in); how does it behave with different aggregators?

Minimal example:

import pandas as pd; import numpy as np
import plotly.graph_objects as go
from plotly_resampler import FigureResampler
from plotly_resampler.aggregation import M4


# 1. Create dummy data
x = np.arange(2_000_000)
x_time = pd.date_range("2020-01-01", periods=len(x), freq="1min")
noisy_sin = (3 + np.sin(x / (len(x) / 55)) + np.random.randn(len(x)) / 10) * x / 1_000

# 2. Create a figure
fig = FigureResampler(default_n_shown_samples=1000, verbose=False)
fig.add_trace(
    go.Scattergl(name="Original", mode="lines", visible="legendonly"),
    hf_x=x_time,
    hf_y=noisy_sin,
)
fig.add_trace(
    go.Candlestick(name="OHLC"),
    hf_x=x_time,
    hf_y=noisy_sin,
    downsampler=M4(parallel=True),
    max_n_samples=400,
)
fig.update_layout(title="OHLC Downsampling", showlegend=True)
fig.update_xaxes(rangeslider_visible=False)
fig

Peek 2024-01-13 19-58

@jonasvdd jonasvdd requested a review from jvdd January 13, 2024 18:59
@codecov-commenter
Copy link

codecov-commenter commented Jan 13, 2024

Codecov Report

Attention: 33 lines in your changes are missing coverage. Please review.

Comparison is base (46e629f) 96.42% compared to head (5cdb8f4) 93.75%.
Report is 2 commits behind head on main.

Files Patch % Lines
...ler/figure_resampler/figure_resampler_interface.py 21.05% 30 Missing ⚠️
plotly_resampler/aggregation/aggregators.py 50.00% 3 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #289      +/-   ##
==========================================
- Coverage   96.42%   93.75%   -2.67%     
==========================================
  Files          14       14              
  Lines        1146     1185      +39     
==========================================
+ Hits         1105     1111       +6     
- Misses         41       74      +33     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

jonasvdd and others added 6 commits January 14, 2024 19:32
* ✨ fix for #275

* 🧹 review code

* ✨ new example

* 🔍 reviewing examples

* 🖍️ docs-fix for #275

* 🔍 review

---------

Co-authored-by: Jeroen Van Der Donckt <boebievdd@gmail.com>
@jonasvdd
Copy link
Member Author

@jvdd,
I suppose we should rebase this branch on main? (so we can fix the NanM4 issue in this PR as well?

@jonasvdd jonasvdd added enhancement New feature or request new feature A new feature (request) labels Mar 12, 2024
@jonasvdd jonasvdd self-assigned this Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request new feature A new feature (request)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants