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

Get renko values #63

Closed
haybb opened this issue Mar 22, 2020 · 6 comments
Closed

Get renko values #63

haybb opened this issue Mar 22, 2020 · 6 comments
Assignees
Labels
enhancement New feature or request released code merged into repo AND released to Pypi

Comments

@haybb
Copy link
Contributor

haybb commented Mar 22, 2020

Hi, how can I get renko values that are calculated for plot ?
And also moving average values associated ?

@haybb haybb added the question Further information is requested label Mar 22, 2020
@DanielGoldfarb
Copy link
Collaborator

Presently there is no way. We can look into possibly having mpf.plot() return values that it calculates.

@haybb
Copy link
Contributor Author

haybb commented Mar 22, 2020

I'd like to. This feature would be awesome.
I could contribute but I don't know how to do this at all...

@DanielGoldfarb
Copy link
Collaborator

I'd like to. This feature would be awesome.
I could contribute but I don't know how to do this at all...

I will be happy to guide you in making this enhancement. Give me a day or two to finish up my current enhancement, and I will provide some design/coding guidance to get you started.

In the meantime, you may want to familiarize youself with the code here starting with plotting.py, and mpf.plot(). You can email any questions about the code to me at dgoldfarb.github@gmail.com (or post them here). Thank you.

@haybb
Copy link
Contributor Author

haybb commented Mar 23, 2020

Ok thank you

@DanielGoldfarb
Copy link
Collaborator

@WHug0 - I hope you are doing well, and had a chance to familiarize yourself with the code. I will outline here changes needed for this request. I assume you know basic GitHub workflow (fork, clone, code, commit, push, pull-request) but if not let me know I will review it with you.

Regarding returning renko values, moving averages, and anything else mpf.plot() might calculate, I don't think we should return these things as the return value of the function, because mpf.plot() already has an option to return the Figure and Axes, and we should not confuse things by having the return value of mpf.plot() sometimes be plotting objects and sometimes be data.

I propose that you create a new kwarg, return_calculated_values, and the user wanting the calculated data would pass a variable containing an empty dict as the value for that kwarg, and mpf.plot() will fill that empty dict with the calculated values. Thus, for example:

 retdata = {}
 mpf.plot(df, type='renko', mav=(10,20), return_calculated_values=retdata)

The kwarg should be added to _valid_plot_kwargs() with a default value of None, and its validator should check to make sure the user passes only an empty dict.

All of the possible calculated values are available in this general vicinity of the code. These include brick_values, new_dates, mavprices, and only for the case of type=renko the variable volumes may contact calculated values (but not for other plot types). In an appropriate place near that part of the code, you can write code to insert the calculated values into the dict. Here is some pseudo code to give you an idea:

if config['return_calculated_values'] is not None:
    retdict = config['return_calculated_values']
    if ptype == 'renko':
        retdict['renko_bricks'] = brick_values
        retdict['renko_dates']  = new_dates
        if config['volume']:
            retdict[renko_volumes'] = volumes
    if mavgs is not None:
        for mav in mavgs:
             format a string like 'mav10' for a 10 period mav, etc.
             retdict['mav25'] = mavprices

That's the basic idea. Let me know if you have any questions, or if you want me to look at the code before you submit a pull request (after is fine too).

All the best. --Daniel

@haybb
Copy link
Contributor Author

haybb commented Mar 25, 2020

Hello Daniel,
Thank a lot for all of this explanations
I've understand what I have to do
It will be done within the next few days
Hugo

@DanielGoldfarb DanielGoldfarb added enhancement New feature or request in progress and removed question Further information is requested labels Mar 25, 2020
@DanielGoldfarb DanielGoldfarb added merged / awaiting release to pypi code merged into repo, but not yet released to Pypi and removed in progress labels Mar 27, 2020
@DanielGoldfarb DanielGoldfarb added released code merged into repo AND released to Pypi and removed merged / awaiting release to pypi code merged into repo, but not yet released to Pypi labels May 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released code merged into repo AND released to Pypi
Projects
None yet
Development

No branches or pull requests

2 participants