- Using Python, fetched historical stock data for any 5 stocks from the Nifty 50 index using the
yfinance
library. Used a time range of the last 6 months. - Performs the following analyses on the data:
- Calculates the daily percentage change for each stock.
- Plots the closing prices and daily percentage changes for the 5 stocks.
- Calculates the moving average (20-day) for each stock and plot it against the stock's closing price.
- Developed a simple moving average crossover strategy for one of the 5 stocks. The strategy involves a short-term moving average (e.g., 50-day) and a long-term moving average (e.g., 200-day).
- Back-tested this strategy on the historical data to identify buy and sell signals.
- Calculated the returns generated by the strategy compared to a simple buy-and-hold approach.
- Calculated the maximum drawdown for each stock over the 6-month period.
- For the stocks selected in module 2, implemented a stop-loss mechanism. Assumed a stop loss of 5%. Re-ran the strategy with the stop-loss and compared the performance to the original strategy.