Python-based project to deliver CAPM portfolio analytics and high-frequency trading analytics using based on equity time-series data (price/returns).
This project uses the Capital Asset Pricing Model and high-frequency trading analytics to gain insight into an equity portfolio. It allows a user to select a set of equities (by ticker), and plots a range of standard portfolio metrics (volatility, VaR, Expected Shortfall, Sharpe Ratio, etc), and high-frequency trading analytics (SMA, EMA, VWAP, TWAP).
The requirements file can be installed using the below commands in a terminal:
Conda: conda install --file requirements.txt
Pip: pip install -r requirements.txt
- Portfolio R-Squared
- Portfolio Beta
- Portfolio Volatility
- Portfolio Alpha (calculated from the returns regression)
- Portfolio Alpha (based on risk-free rate)
- Portfolio Sharpe Ratio
- Portfolio Tracking Error
- Analytical VaR (Normal Distribution)
- Analytical VaR (t-Distribution)
- Expected Shortfall (Normal Distribution)
- Expected Shortfall (t-Distribution)
- Historical VaR
Using the equities: AAPL, GOOGL, BLK, and IBM (with respective portfolio wieghts of: 0.15, 0.6, 0.2, and 0.05), and the S&P 500 (^GSPC) as the benchmark, in the date range: 2019-06-20 to 2019-11-08, we obtain the below portfolio analytics.
- Portfolio R-Squared = 0.5713749319708816
- Portfolio Beta = 1.6823252286102592
- Portfolio Volatility = 0.001774262341931516
- Portfolio Alpha (calculated from the returns regression) = 0.043032257203536886
- Portfolio Alpha (based on risk-free rate) = 0.0052482979658219735
- Portfolio Sharpe Ratio = 3.354557106775981
- Portfolio Tracking Error = 0.030298260899050793
- Analytical VaR (Normal Distribution) = 7.390523472420238% at -1.0% of daily returns
- Analytical VaR (t-Distribution) = 49.62040090212909% at -1.0% of daily returns
- Expected Shortfall (Normal Distribution) at 5.0% level = 3.592204573450777
- Expected Shortfall (t-Distribution) at 5.0% level = 7.077446307947621
- Historical VaR = 4.0% at -1.0% of daily returns
Daily Return vs Time (Portfolio and Benchmark)
Analytical VaR (Normal Distribution)
Analytical VaR (t Distribution)
- The project uses the Alpha Advantage package to obtain price data. Due to the limited number of server requests this API allows, we currently save the data into Excel files, which are then read in by the main program, Portfolio-Analytics.py for processing. The Alpha Advantage model only allows us to obtain the prices and volume for each equity for the last 100 days
- Portfolio breakdown by sector
- Portfolio breakdown by country
- Portfolio breakdown by region
- Returns attribution by equity
- Additional high-frequency trading analytics
- Portfolio Optimizer
- Seaborn plots
- Inclusion of other asset classes
- Plot Expected Shortfall as an overlay on VaR plots
- Front-end UI (web-based or Android/iOS)