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

Good First Issue >> Renko #152

Closed
Winthan opened this issue Oct 20, 2020 · 16 comments
Closed

Good First Issue >> Renko #152

Winthan opened this issue Oct 20, 2020 · 16 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@Winthan
Copy link

Winthan commented Oct 20, 2020

Which version are you running? The lastest version is Github. Pip is for major releases.

import pandas_ta as ta
print(ta.version)

Upgrade.

$ pip install -U git+https://github.com/twopirllc/pandas-ta

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Thanks for using Pandas TA!

@Winthan Winthan added the enhancement New feature or request label Oct 20, 2020
@twopirllc twopirllc changed the title can you add renko too? Add Renko Oct 20, 2020
@twopirllc twopirllc added the good first issue Good for newcomers label Oct 20, 2020
@twopirllc
Copy link
Owner

Hello @Winthan,

Added to the end of the list.

Regards,
KJ

@twopirllc twopirllc changed the title Add Renko Good First Issue >> Renko Nov 16, 2020
@codesutras
Copy link
Contributor

@twopirllc Any update on that?
I have Renko class ready with me and facing some issues with strategy implementation on that. Let me know if you would like me to look into it. If yes, I need to understand few things from you. Since the issues are majorely with indexing.

@twopirllc
Copy link
Owner

Hi @codesutras,

That would be great if you could look at it. From my initial review and investigation into Renko development yielded the same issue with indexing since it's index is not equivalent to the underlying ohlcv index. The Renko method/function would need to create a new DataFrame with it's own index, essentially a one way transformation.

Thanks,
KJ

@codesutras
Copy link
Contributor

codesutras commented May 9, 2021

You are correct. As of now I've been using renko dataframe and then using ta indicator on top of it. And handling the indexing at that. So, we've just have to apply the same logic if chart type renko in strategy class. Can we connect sometime today to discuss on this. So, that you can discuss the current strategy class code and you can guide me where do I have to keep this renko class. 🙂.

Since, from my end all the things are available. We've just need to see that where I have to integrate my codes.

@twopirllc
Copy link
Owner

@codesutras,

As of now I've been using renko dataframe and then using ta indicator on top of it. And handling the indexing at that.

Nice. What is name of the returned column when you call renko(ohlcv)? It would be easier for ta.strategy() if it were named close or renko_close so ta.strategy() doesn't have to do more than it already does under the hood. Also due to Renko's non-uniform indexing, it's possible that vwap may not return a logical interpretation and might need to be excluded from execution.

Can we connect sometime today to discuss on this. So, that you can discuss the current strategy class code and you can guide me where do I have to keep this renko class.

Sure. But it's night time here and tomorrow is Mother's Day, so my time may be limited. Though there is no rush.

Since, from my end all the things are available. We've just need to see that where I have to integrate my codes

Excellent. If you want to share via my email, that is fine as well.

Thanks,
KJ

@codesutras
Copy link
Contributor

codesutras commented May 9, 2021

Hey,

so columns in Renko will be the same, eg: open, close, low, high. And Renko doesn't use volume. As it's an only price chart :) and of course, Renko can only be used with price-based indicators. Not with indicators like VWAP (which uses volumne). That's the practical aspect.

My renko class returns a dataframe. Which can be further used to apply indicators. And yeah, I'm doing reindexing before applying indicators.

<class 'pandas.core.frame.DataFrame'> RangeIndex: 706 entries, 0 to 705 Data columns (total 6 columns): Column Non-Null Count Dtype 0 date 706 non-null datetime64[ns] 1 open 706 non-null float64 2 high 706 non-null float64 3 low 706 non-null float64 4 close 706 non-null float64 5 uptrend 706 non-null bool dtypes: bool(1), datetime64[ns](1), float64(4)

In the case of strategy, I'm getting attached exceptions.
exception.txt

I'd dropped you a mail already. Let's connect when we both are available to discuss it further and plan it out. No rush from my end too.

Thanks,

@mobilepro
Copy link

Hi @codesutras
Any luck with using Renko with pandas-ta?

@AGG2017
Copy link

AGG2017 commented Sep 13, 2021

Quality converting to Renko needs much more work. I'm trying to keep the date/time index and to offset in advance by given delta (1sec) all extra bricks from gaps or fast moving bars. I also try to keep the volume like in TradingView by dividing the bar volume to number of result bricks and this is the brick volume. Then all volume indicators will work. I also add columns with real open and close prices from the original bars to all generated bricks from this bar in order to have real backtesting results with analyzing bricks but trading with the real open/close price for this brick. Fixed size and ATR brick size is only good for intraday and short term analysis. I also use log scale (by a given percentage of price increase/decrease). This way the brick size is smaller for old periods where the price of the stocks was times less than now. Otherwise the backtesting shows unbelievable wrong results. And so on details that matter.

@twopirllc
Copy link
Owner

@AGG2017,

Quality converting to Renko needs much more work.

I agree.

Do you have some code to share or would you like to contribute? 😎

Kind Regards,
KJ

@AGG2017
Copy link

AGG2017 commented Sep 20, 2021

Unfortunately, I don't plan to implement this as part of pandas_ta because the result will be not compatible to the index of the rest of the indicators. It doesn't fit at all for this library. I'm trying to do it as part of my version of backtesting.py library where I have internal function to get ochlv data from a database with options to convert them to Renko or Heikin Ashi. Then with the resulting new index all other indicators will be attached properly to the Renko dataframe. When I keep the original open and close price available for each brick, the backtesting can be real. When I'm ready, I can provide the portion related to Renko converting even though it is clear enough how to do it with the notes I already mentioned here. My Python knowledge are not profound and I just want the code to be properly working, not perfectly written.

@mobilepro
Copy link

I managed to make it work with a work around using another library to build Renko bricks(dataframes) and use it with pandas-ta.

I used stocktrends (https://github.com/ChillarAnand/stocktrends) to build Renko data frames

@AGG2017
Copy link

AGG2017 commented Sep 20, 2021

Stocktrends is done somehow to do the job. I started with it but found there is no atr support, no percentage log support, no volume, the date in the index for all extra bricks are the same, very low speed for large data frames or small brick sizes due to the concatenation of two data frames for each new bar and initially I had to add data frame caching to speed up the repeating analysis, no functions to evaluate the quality of selected brick size, no corresponding original trading prices for each brick that makes impossible the real backtesting, etc. The best way is to be completely rewritten.

@twopirllc
Copy link
Owner

@AGG2017,

Unfortunately, I don't plan to implement this as part of pandas_ta because the result will be not compatible to the index of the rest of the indicators.

Right because Renko is time invariant.

It doesn't fit at all for this library. I'm trying to do it as part of my version of backtesting.py library where I have internal function to get ochlv data from a database with options to convert them to Renko or Heikin Ashi.

How do you like backtesting.py? I use vectorbt.

My Python knowledge are not profound and I just want the code to be properly working, not perfectly written.

Fair enough.

@twopirllc
Copy link
Owner

@mobilepro Thanks for sharing a link

@AGG2017
Copy link

AGG2017 commented Sep 20, 2021

@twopirllc,

How do you like backtesting.py? I use vectorbt.

Thanks for the information. I will take a look. I tested several backtesting frameworks but didn't find exactly what I needed. So, I started from the simpler one that was easy for me to understand and I tried to redo and to simplify the core logic to be able precisely to backtest several stocks and at the same time to trade several other options in complex strategies. I also needed to be able to use many standard indicators from all great TA libraries like yours and at the same time to be able to add easily my own indicators. I feel happy that I understand in details the one I write and I can modify at any moment whatever is needed to be modified. That's priceless.

@twopirllc
Copy link
Owner

@AGG2017,

Thanks for the information. I will take a look. I tested several backtesting frameworks but didn't find exactly what I needed. So, I started from the simpler one that was easy for me to understand and I tried to redo and to simplify the core logic to be able precisely to backtest several stocks and at the same time to trade several other options in complex strategies. I also needed to be able to use many standard indicators from all great TA libraries like yours and at the same time to be able to add easily my own indicators.

No worries. Makes sense.

You may be interested in trying the Custom directory so you can incorporate your own indicators and have them hook into Pandas TA. Let me know if you do and if it works for you.

I feel happy that I understand in details the one I write and I can modify at any moment whatever is needed to be modified. That's priceless.

That's for sure!

KJ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

5 participants