This article is beneficial for generating metrics to evaluate and select trading strategies. The parameters encompass a range from profit to losses, risks involved, graphical representation, and more.
By executing the provided code, you can obtain key information on various metrics such as:
- Cumulative returns
- CAGR (Compound Annual Growth Rate)
- Sharpe Ratio
- Max Drawdown
- Skewness and Kurtosis
- Max consecutive wins and losses
- Gain/Pain Ratio
- Best and worst day
- Expected Shortfall
- Strategy monthly returns
The detailed analysis in the attachment focuses on Nifty performance from September 2007 to September 2023. Please refer to the attachment for an in-depth exploration of all the parameters.
#Python code
# importing necessary libraries #
import yfinance as yf
import warnings
warnings.filterwarnings("ignore")
import quantstats as qs
# Download data from yfinance and caculating returns #
df1 = yf.download('^NSEI', '2000-01-01', '2023-09-30')
df = df1[['Adj Close']]
returns = df['Adj Close'].pct_change().dropna()
# using quantstas to get the full analysis of the returns #
qs.reports.full(
returns,
mode = 'full'
)
Output of the above code