Package: renkodf
renkodfTransform Tick Data into OHLCV Renko Dataframe!Installationpip install renkodfor just copyrenkodf.pyfile to your project!renkodf requirespandas,numpyandmplfinanceContentUsageAnimation/Realtime Renko ChartIs the Renko chart calculated correctly?UsageThere are two classes available:Renko(df, brick_size, add_columns)To create Renko OHLCV dataframe with existing Ticks data.RenkoWS(timestamp, price, brick_size, external_df, external_mode)To create real-time Renko charts, usually over aWebSocketconnection.Let's start with the first class, load a Pandas DataFrame containing Ticks Data, for example:importpandasaspddf_ticks=pd.read_parquet('examples/data/EURGBP_T1_cT.parquet')df_ticks.rename(columns={'bid':'close'},inplace=True)df_ticks.head(3)df_ticks.tail(3)askclosespreaddatetime2023-06-23 00:00:00.3350.859500.859450.000052023-06-23 00:00:00.5410.859510.859440.000072023-06-23 00:00:02.1060.859500.859440.00006askclosespreaddatetime2023-06-27 23:59:56.6120.859760.859690.000072023-06-27 23:59:57.1750.859750.859690.000062023-06-27 23:59:59.0530.859740.859690.00005Only two columns are required:close: Mandatory.datetime: If is not present, the index will be used.You can add other columns if you want, just put a list with their names in theadd_columnsparameter.After importing renkodf and settingbrick_size, just callrenko_df()with the chosen mode name.See all available modes inrenkodf_modes.ipynbfromrenkodfimportRenkor=Renko(df_ticks,brick_size=0.0003)df=r.renko_df('normal')# 'wicks' = defaultdf.head(3)df.tail(3)100.0%openhighlowclosevolumedatetime2023-06-23 01:21:58.3330.85950.85980.85950.85983458.02023-06-23 01:33:24.9960.85980.86010.85980.8601571.02023-06-23 03:18:30.3450.86010.86040.86010.86044993.0openhighlowclosevolumedatetime2023-06-27 17:29:15.1190.85950.85980.85950.85982889.02023-06-27 21:01:00.0710.85950.85950.85920.85927779.02023-06-27 21:31:48.5690.85950.85980.85950.8598359.0You can usempf.plot()orr.plot(), as in the example below.importmplfinanceasmpfmpf.plot(df,type='candle',volume=True,style="charles",title=f"renko: normal\nbrick size: 0.0003")mpf.show()# same as:# r.plot('normal')As described inrenkodf_modes.ipynb, we can have multiple dataframes of different modes from the same instance.df_wicks=r.renko_df('wicks')df_nongap=r.renko_df('nongap')fig=mpf.figure(style='charles',figsize=(12.5,9))fig.subplots_adjust(hspace=0.1,wspace=0.01)ax1=fig.add_subplot(2,2,1)ax2=fig.add_subplot(2,2,2)mpf.plot(df_wicks,type='candle',ax=ax1,axtitle='wicks',)mpf.plot(df_nongap,type='candle',ax=ax2,axtitle='nongap')mpf.show()Animation/Real-time Renko ChartFollowing the steps of the mplfinance documentation, it can be tricky to display animations properly in jupyter notebooks, therefore, to keep things simple, the animation examples are scripts.To run the animation examples, clone this repository, then into therenkodf/examplesfolder, run:python ws_animchart_demo.pypython ws_multichart_demo.pypython ws_externaldf_demo.pyNOTE:There are comments, in each of the above example files, talking about situations or recommendations to be applied in real cases.Is the Renko chart calculated correctly?I also asked myself the same question, how about we see for ourselves?We are going to do this based onSpotware's FX/CFD Trading PlatformcalledcTrader,usingIC Marketsas a Price Provider.Let's go!RESUME: Despite the possible occurrence of more/less bricks, the renko calculation used is practically the same, or very approximate.Non-Affiliation DisclaimerI'm not endorsed by, directly affiliated with, maintained, authorized, or sponsored by any company previously mentioned.All product and company names are the registered trademarks of their original owners.The use of any trade name or trademark is for identification and reference purposes only and does not imply any association with the trademark holder of their product brand.