Quant Finance with Python and Pandas | 50 Concepts you NEED to Know in 9 Minutes | [Getting Started]
Summary
Highlights
This section introduces computational finance, covering data science techniques, risk and return modeling, and data visualization. It highlights the use of Python libraries like NumPy, Pandas, and Matplotlib for financial analysis. The video will use yFinance to fetch stock data for ETFs like SPY, focusing on adjusted closing prices for accurate total return calculations.
The video explains how to handle data using Pandas Series (single-dimensional) and DataFrames (two-dimensional). It demonstrates cleaning data by dropping NA values, converting the index to a monthly format, and plotting prices. The core of this section focuses on calculating returns, explaining both single-period and multi-period (compound/geometric) returns, emphasizing why simple addition of returns is incorrect due to 'variance drag'.
This part details converting price series to return series using the `percent_change` method and the subsequent `drop_na` for cleanup. It covers calculating compound returns by adding one to single-period returns, using `.prod()`, and then subtracting one. It also introduces basic DataFrame methods like `.head()`, `.tail()`, `.size`, `.shape`, `.index`, and `.columns` for data inspection and indexing.
The video proceeds to discuss risk measurement, specifically volatility using standard deviation (`.std()`). It then explains how to annualize both returns and volatility. Annualized return calculation is demonstrated by raising compound growth to the `periods_per_year` over the `number_of_periods`. Annualized volatility is simpler, achieved by multiplying volatility by the square root of `periods_per_year`. The raw Sharpe ratio, a risk-adjusted return measure, is also introduced.
This section covers creating a wealth index by adding one to all returns and then using `cumprod()` to calculate the cumulative product, representing the growth of one dollar. It also explains how to handle the initial data point not starting at one. Finally, the video delves into calculating and plotting drawdowns—the return from a previous peak to the current price—using the wealth index and `cummax()` to find previous peaks. It concludes with calculating the maximum drawdown and representing it graphically.