The goal of this project is to utilize APIs to pull ticker data from stocks, bonds, and cryptocurrencies to analyze their performance over the last thousand trading days. After pulling the data from the APIs, it would then be cleaned up using pandas to only keep track of the close
prices and then stored them in a database using SQL. From there the data can then be pulled to analyze the returns over the past thousand trading days.
- Used for our own comparative analytics within and across asset classes
- Analysis notebook and corresponding dashboard can be used as a tool for any future analysis, as someone can pass in their own tickers related to each asset class
Data extraction, cleaning, storage:
- Draft Project Proposal and Excel Dashboard Roadmap
- Import libraries and dependencies
- Utilize API calls to create data frames for all tickers within each asset class
Alpaca API
Binance API
- Clean the dataframes
- Remove Timestamp from Index
- Drop all columns except close price for each ticker
- Utilize SQL to write the cleaned data frames into postgres as tables to easily be retrieved later in the dashboard file
Transformation:
- Plot 50-day and 200-day rolling averages of close price with dropdown selector for all tickers
- Found daily and cumulative returns to accurately compare data by transforming the close prices
- Plot rolling standard deviation of all tickers
- Plot correlation of returns within same asset classes
- Return values to determine interdependence
- Plot on heatmap using Seaborn
Dashboard:
- Utilize SQL to read in stored close price data frames from postgres
- Copy/Paste transformations above
- Define functions to return desired visualizations
- Energy =
XLE
- Financial Services =
XLF
- Real Estate =
XLRE
- Technology =
XLK
- Consumer Staples =
XLP
- Basic Materials =
XLB
- Industrial =
XLI
- Healthcare =
XLV
- Utilities =
XLU
- Consumer Discretionary =
XLY
- Communication Services =
XLC
- iShares 3-7 Year Treasury Bond ETF -
IEI
- iShares 7-10 Year Treasury Bond ETF -
IEF
- iShares 10-20 Year Treasury Bond ETF -
TLH
- iShares 20+ Year Treasury Bond ETF -
TLT
- Bitcoin -
BTC
- Ethereum -
ETH
- Binance Coin -
BNB
- Cardano -
ADA
- Ripple -
XRP
- Since we were limited to free APIs we were capped with a call of no more than 1000 rows of data per ticker. This lead to an issue we encountered while comparing data from cryptocurrencies which trade 7 days/week and stock/bonds which trade 5 days/week. As a result we only have 638 rows shared among all three asset classes: Crypto, Bonds, and Stocks. However, this is still a large enough dataset to use in our analysis.
- Git Branching
- Multi-Level index on Stocks and Bonds
- Could use better formatting for the visualiziation of our daily returns. With more time we would create a bar chart to show the variance of each ticker rather than a line graph.
- Another enhancement we would like to implement would be to exchange our fixed ticker data with an input function to easily input any ticker of interest
- The following dependencies are required: pyvizenv, sql, postgres
- Download the
sector-performance-analysis
repo - Create a new postgres database called
sector_analysis_performance
- set postgres password to
password
- Restart and run all cells on main.ipynb
- Restart and run all cells on dashboard.ipynb
- Interact with dashboard to interpret analyses of tickers by asset class
- Navigate to the following snippet in the
main.ipynb
file
- Set desired start and end dates
- Replace stock_tickers with any single stock ticker or list of stock tickers
Restart and Run
all cells- Navigate to dashboard
Restart and Run
all cells
- Note This will only work if the crypto of interest is listed on Binance
- Navigate to the following snippet in the
main.ipynb
file
- Replace
BTCUSDT
with desired crypto ticker and specify corresponding ticker for dataframe Restart and Run
all cells- Navigate to dashboard
Restart and Run
all cells