Creating a trading system from scratch

How many lines of code you are comfortable with


  • Total voters
    61

VJAY

Well-Known Member
@vinit_7801
Pyfolio only works with python 3.5 not with later versions.
You need a hack to do it.
And pyfolio requires a returns dataframe - daily returns instead of our present dataframe
Please help to hack and also modify /add return dataframe :)
 

VJAY

Well-Known Member
Actually this error due to I checked otherthan nifty 50 only now in system...we checked it in backtests only before :).
so something error have in system from start :)
 

UberMachine

Well-Known Member
Please help to hack and also modify /add return dataframe :)
@vinit_7801
The hack
Python:
import pandas
pandas.core.common.is_list_like = pd.api.types.is_list_like
import pyfolio
If this passes without error, then we can use pyfolio
To use pyfolio try
Python:
# Pyfolio takes daily returns as input
pyfolio.create_returns_tear_sheet(orders['total_profit']/CAPITAL)
Convert your daily profit and loss to returns percentage and it would work
 
@vinit_7801
The hack
Python:
import pandas
pandas.core.common.is_list_like = pd.api.types.is_list_like
import pyfolio
If this passes without error, then we can use pyfolio
To use pyfolio try
Python:
# Pyfolio takes daily returns as input
pyfolio.create_returns_tear_sheet(orders['total_profit']/CAPITAL)
Convert your daily profit and loss to returns percentage and it would work
Its giving me this error
 

Attachments

ncube

Well-Known Member
Dear ncube/UB,
I think we need to get one result file for this code to work.....Please help in this regard....

View attachment 28948
Yes, I am not able to find the post where I saw that backtest portfolio daily result is plotted. To plot such a chart it requires the data to be stored as a series. So most likely it is already available in the code shared by @UberMachine. If not one need to store the strategy daily result in the format:

1538370545750.png


Then it can be used in the pyfolio as follows:

pf.create_full_tear_sheet(port['sstrategy'])
 

Similar threads