-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Update of finance.py to (O,H,L,C) instead of (O,C,H,L) #1783
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
In the financial world, a bar-chart is commonly called an OHLC-chart or "Open-High-Low-Close chart". Also see http://en.wikipedia.org/wiki/Open-high-low-close_chart or simply google around. To my surprise this library uses a sequence of OCHL instead of OHLC. Although it changes the API, I found it important to comply with financial industry standards. This makes it easier to implement this library in existing financial software and thus more likely to be used in the future.
@@ -365,12 +365,12 @@ def candlestick(ax, quotes, width=0.2, colorup='k', colordown='r', | |||
return lines, patches | |||
|
|||
|
|||
def plot_day_summary2(ax, opens, closes, highs, lows, ticksize=4, | |||
def plot_day_summary2(ax, opens, highs, lows, closes ticksize=4, |
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.
This line is the biggest problem - we have no way of detecting if the use is using the old interface or the new one. This kind of change is very hard for a user to track down, and is probably something that a user wouldn't even notice had changed. I don't dispute your assertion about the expected order, but it is because of this line that I am 👎 for this change.
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.
Could we do
def plot_day_summary2(ax, opens, closes, highs, lows, **kwargs):
plot_day_summary3(ax, opens, highs, lows, closes, **kwargs)
and rename the function with the new call order plot_day_summary2
-> plot_day_summary3
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.
Or, better yet, add plot_day_summary_ochl
as an alias for plot_day_summary2
and then add plot_day_summary_ohlc
? Then the intention is right in the name of the function, rather than just with a numerical suffix.
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.
@mdboom - nice suggestion - I'd be in favour of that.
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.
@pelson - You are absolutely right in that it must be clear to end-users which interface they are using. In fact, it shouldn' t be that hard to check which one they are using. You could simply check whether the fourth provided list (highs in the old ochl-interface, lows in the new ohlc-interface) is always larger or equal to the fifth list (lows in the old ochl-interface, closes in the new ohlc-interface). If this argument is true, they are using the old interface and we could raise an error. If this argument is false then they are using the new interface and all is good.
@mdboom - Indeed also a very good suggestion. I would be enthousiastic about this, although I still think that the ochl-flavour should eventually be removed to avoid confusion and simplify the interface by reducing the amount of functions.
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 prefer @mdboom's suggestion here. I am very in favour of verbose method names.
I would be enthousiastic about this, although I still think that the ochl-flavour should eventually be removed to avoid confusion and simplify the interface by reducing the amount of functions.
I agree here, but I'd prefer to see at least a deprecation warning before this is removed. That way our users are warned about a potential future alteration that requires a change to their code.
Added deprecation warning to `plot_day_summary2` and returned call signature to what it was. Added alias `plot_day_summary_ochl` with same call signature as `plot_day_summary2`. renamed the modified function to `plot_day_summary_ohlc`. The first two functions simply call the third with the arguments re-ordered.
re-based this patch and implemented the renaming discussed here. Is there a good way to get my branch (https://github.com/tacaswell/matplotlib/tree/ochl_to_ohlc) into this PR, or should I open a new one? There is no test coverage of |
Its best if you open a new PR. Thanks @tacaswell. |
Closing in lieu of #1920. |
Added deprecation warning to `plot_day_summary2` and returned call signature to what it was. Added alias `plot_day_summary_ochl` with same call signature as `plot_day_summary2`. renamed the modified function to `plot_day_summary_ohlc`. The first two functions simply call the third with the arguments re-ordered.
In the financial world, a bar-chart is commonly called an OHLC-chart or "Open-High-Low-Close chart". Also see http://en.wikipedia.org/wiki/Open-high-low-close_chart or simply google around.
To my surprise this library uses a sequence of OCHL instead of OHLC. Although it changes the API, I found it important to comply with financial industry standards. This makes it easier to implement this library in existing financial software and thus more likely for the library to be used in the future.