Skip to content
Why every portfolio should have Bitcoin? A detailed analysis.
Content
- Importing necessary python libraries and loading the data.
- Initial data discovery for checking how the data is stored in resources.
- Trend graphs of the tables given to understand better the density, quality and limits of the raw data.
- Data cleaning and preperation for making the tables more useful during calculations.
- Calculations for performance and volatility comparisons.
- Performance of Bitcoin compared to the S&P 500 and gold price in montly graphs.
- Performance of Bitcoin vs (negative) CPI change to understand inflation affect.
- Volatility of Bitcoin compared to the S&P 500 in daily basis when stock market was open.
- Volumes of Bitcoin compared to the S&P 500
- Advantage comparison
- Conclusion
At the end of every section, there's a short conclution about the outcomes.
Importing Libraries and Loading the Data
import pandas as pd
import numpy as np
import plotly.graph_objects as go
from datetime import datetime
bitcoin = pd.read_csv('./data/bitcoin-usd.csv', parse_dates=['date'])
sp500 = pd.read_csv('./data/sp500.csv', parse_dates=['date'])
monthly_data = pd.read_csv('./data/monthly_data.csv', parse_dates=['date'])
Initial Data Discovery
bitcoin.head()
sp500.head()
monthly_data
Insights of the section:
- Both Bitcoin and S&P 500 have data in daily basis.
- As S&P 500 is aligned with the only open days of the stock market, Bitcoin has weekend data additionally.
Trend Graphs for Data Discovery
fig_bitcoin = go.Figure(data=[go.Candlestick(x=bitcoin['date'],
open=bitcoin['open'],
high=bitcoin['high'],
low=bitcoin['low'],
close=bitcoin['close'])])
fig_bitcoin.update_layout(
title='Bitcoin daily price over time',
yaxis_title='USD')
fig_bitcoin.show()
fig_sp500 = go.Figure(data=[go.Candlestick(x=sp500['date'],
open=sp500['open'],
high=sp500['high'],
low=sp500['low'],
close=sp500['close'])])
fig_sp500.update_layout(
title='S&P 500 stocks daily price over time',
yaxis_title='USD')
fig_sp500.show()
fig_gold = go.Figure([go.Scatter(x=monthly_data["date"], y=monthly_data["gold_usd"])])
fig_gold.update_layout(
title='Monthly gold price over time',
yaxis_title='USD')
fig_gold.show()
fig_cpi = go.Figure([go.Scatter(x=monthly_data["date"], y=monthly_data["cpi_us"])])
fig_cpi.update_layout(
title='The inflation index for the US over time',
yaxis_title='CPI')
fig_cpi.show()
Insights of the section:
- Bitcoin seems to be more risky but much more profitable over the past years.
- S&P 500 seem to have a constantly rising trend in general over time (except the year 2020 with pandemic).
- Gold price doesn't seem profitable for the last 2 years against CPI where it was increasing, most of the time.