-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
add ohlc chart to TraceFactory #259
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
Conversation
- add ohlc chart as 2 TraceFactory methods so `TraceFactory.create_ohlc_increasing()` returns a trace of the increasing data and `TraceFactory.create_ohlc_decreasing()` returns a trace of the decreasing data. In these charts increasing and decreasing periods are typically represented by different colours (default green & red). - pull flatten method out of `_Quiver` so other charts can call it
Updates to ohlc -make tests -make default for kwargs so the default colours are red/green (typical for this chart)
@chriddyp @theengineear @aneda @etpinard Hi guys, ohlc chart is ready for review/feedback |
@cldougl your tests are failing (likely) due to the same things affecting @aneda . Once she's merged into master, you should be able to just merge master into this branch and be good to go. Else you can (a) cherry pick the changes or (b) merge her branch as-is and then merge master later before you merge into master. so many options :) reviewing now! |
|
||
class TestOHLC(TestCase): | ||
|
||
def test_unequal_o_h_l_c_length(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐄 As is well put, a foolish consistency is the hobgoblin of little minds. It'd be fine to call this:
test_unequal_ohlc_length
😸
@cldougl imo, having two separate calls for ohlc charts seems like a lot. I'm happy to keep them separate in tools, but maybe just create a single way to make an Just a thought, happy to be dissuaded. |
Also, unless it's really common to use
... etc etc (try doing |
def validate(x, y, u, v, | ||
scale=.1, density=1, | ||
arrow_scale=.3, **kwargs): | ||
def validate_shared(x, y, u, v, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐄 Just a suggestion. Would this be clearer as two functions?
def validate_positive_scalars(**kwargs):
"""
Validates that all values given in key/val pairs are positive.
Accepts kwargs to improve Exception messages.
:raises: (PlotlyError) If any value is < 0 or raises.
"""
for key, val in kwargs.items():
try:
if val <= 0:
raise PlotlyError('{} must be > 0, got {}'.format(key, val)
except TypeError:
raise PlotlyError('{} must be a number, got {}'.format(key, val)
def validate_arrays(**kwargs):
""""
Validates a set of named arrays.
Accepts kwargs to improve Exception messages.
:raises: (PlotlyError) On failure.
""""
# do your checks here...
I think that after the refactorings, this validate
method has gotten much simpler than the docstring suggests?
Again, just a 🐄
@cldougl yowza! this is super clean! nice job. a couple of comments above and I'm going to hold off on dancing not literally of course until tests pass. |
- combine create_ohlc_increase and create_ohlc_decrease into create_ohlc - rename variables to open, high, low, close - 2 pep 8 fixes - check messages with assertRaisesRegexp
- remove create_ohlc_increase and create_ohlc_decrease - update validate_ methods so that they can be used with multiple traces when applicable
- check that direction is ‘increasing’ or ‘decreasing’
@theengineear @chriddyp tests are passing now, can I get another review of this |
@@ -1670,6 +1722,130 @@ def create_streamline(x, y, u, v, | |||
mode='lines', **kwargs) | |||
return streamline | |||
|
|||
@staticmethod | |||
def create_ohlc(open, high, low, close, direction, **kwargs): | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐄 I don't believe we typically leave a space between a function's call signature and the docstring.
@cldougl i'll review tonight or tomorrow |
only non-blocking comments from me! the interface for creating these looks good! 💃 from me, but you should also wait for a green light from @chriddyp |
@theengineear @chriddyp sounds good! Thanks!! |
- add candlestick chart and tests - TF.create_candlestick uses fill and grouped legends to create the candlestick outline and the shaded body - (also oops forgot some :rtypes: in ohlc docs)
@chriddyp @theengineear @aneda @etpinard @jackparmer candlestick charts are ready for review too (they're pretty similar to the ohlc charts but with a shaded middle) |
Yep, that sounds good |
@theengineear re the Factories subclassing dict: the idea was to make it similar to |
Yup. Yeah, we'd only want to subclass |
done :) |
\o/ |
- subclass from `object` - separated `create_ohlc()` into `_make_increasing()` and `make_decreasing()` so the user can pass kwargs to the ‘increasing’ and ‘decreasing’ traces by defining `direction` as increasing or decreasing. This keeps it consistent with `create_candlestick` - make `_make_increasing` and `_make_decreasing` static methods for ohlc and candlestick - set `hovermode` to closest for ohlc
add examples (still need average line and subplots examples)
- remove candlestick width=4 (leave as default 2) - change ohlc default to 1 - add bar gap to candlestick layout
so that you can pass in `dates=df.index` and nothing will fail with the `datetimeindex isn’t a bool`
Finance fixes
- set ohlc width to 1 - remove duplicate names in tests
💃 when tests pass |
- update version number - add end line to tools.py
add finance charts to FigureFactory
💥 nice! |
TraceFactory.create_ohlc_increasing()
returns a trace of theincreasing data and
TraceFactory.create_ohlc_decreasing()
returns atrace of the decreasing data. In these charts increasing and decreasing
periods are typically represented by different colours (default green &
red).
_Quiver
so other charts can call it