-
Notifications
You must be signed in to change notification settings - Fork 660
Script additions for 'ema' plotting #563
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
…a has the same data-types as mav
simple protocol for unit testsI forgot to mention. I was wondering if someone may help me by suggesting a concise protocol for running unit tests on this repository (for example, run |
@andrewrgarcia
The I have found the above to be the simplest way to develop the package. I make my changes to the code, and then typically run my initial tests in a copy of one of the tutorial notebooks (or write a separate script to test). If other people are working on the same machine as you, and using mplfinance, and you don't want to disturb them with your development version, just do the above inside a python virtual environment. But if you are alone on the machine I personally find it simplest to just install the dev version for the whole machine. You can always re-install the production version later. Once you have done the above, in addition to whatever development and tests you want to run in scripts or notebooks, you can also run mplfinance's battery of regression tests by, again, |
Andrew- The code looks great so far. Of course you will have to add calls to I believe the way The mildly tricky part will be to get both mav and ema appropriately into the Thank you so much for contributing. All the best. --Daniel |
@DanielGoldfarb Thank you Dr. Goldfarb. I found your explanation quite practical and it works very well! I suggest you add your explanation as a subsection to the Coding Standards section in the |
Those were my thoughts exactly. Thanks. And congrats on finishing your PhD this year. |
@DanielGoldfarb Thank you for pointing me to those resources. That's a good point; as |
@DanielGoldfarb Thanks so much. |
@DanielGoldfarb I just made the changes to make the new |
@andrewrgarcia - Thanks for writing the test. Looks good. I will be running a few tests myself to feel sure on my end. Meanwhile, it appears that perhaps you used a tool to "standardize" the code. As noted in the mplfinance coding standards section of the contributing page "If you work on a pre-existing code file, please try to more-or-less emulate the style that already exists in that file." I am definitely open to discussing whether we should make all mplfinance code compliant with a particular style (PEP 8). If we decide to make such a change, my experience has shown that its best to merge such changes (which in theory should have zero effect on functionality) as their own separate Pull Request. Meanwhile, please reverse the style changes so that this PR contains only changes directly related to adding functionality for the Exponential Moving Average. If you don't have the time, or if for any other reason you can't revese only the style changes, then please let me know and I will take care of it within this PR. Thanks. Much appreciated. And thanks again for your interest in, and contributions to, mplfinance. |
@DanielGoldfarb that was my mistake; it appears my VS Code editor was using a "Format on Save" option which was formatting the whole code. I just reverted that commit and made only the necessary changes to the exponential mav as suggested. On this new commit, I am also doing my best to comply with PEP 8 formatting as you can see on the new tests/test_ema.py file. Thank you so much for your feedback and all your patience; it's helped me a lot. Let me know what you think of the new changes. |
@andrewrgarcia -- Thanks! One other thing I was thinking but forgot to mention. In (As a side but related note, I have also tried to minimize the number of other packages mplfinance is dependent upon. Obviously it must depend on matplotlib and on pandas, followed by the dependences of those two packages. But beyond that I've strived not to include any additional dependencies). All data used by examples and tests should be placed in the That said, while it may keep things consistent for If you want to use the binance data, I would suggest writing a separate little script to go to the binance api, and then save the data in a csv file (using pandas |
@DanielGoldfarb got it. No problem, I will modify test_ema.py so that it calls one of the files already present in the |
One other thing I just realize you perhaps did not realize about the tests: Take a look, for example, at file The first time ever that you run a test, you have to eye-ball that plot an make sure it looks good. After that you copy the image into the Then the test itself is to recreate the plot image in the |
@DanielGoldfarb I replaced the former example with one that makes a call to the .csv file for the historical price data of GOOG in |
@andrewrgarcia
Let me know you see any issues with my changes. If not, then I will go ahead and merge the code. |
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.
Changes are good.
@DanielGoldfarb The cycling for the simulaneous sma and ema use-case makes sense. On that same note, I also think the new Thank you as well, these are useful additions to the library. |
Relates to Issue #506
What was done
Added a new
_plot_ema()
function to theplotting.py
file similar to_plot_mav
where the main difference is in line 1176 of the requested script.Also added an
ema
key to the_valid_plot_kwargs()
function inplotting.py
which also uses the_mav_validator
because ema should have the same datatype as mav.