Can you guess what is it in the video, if not the galaxy cluster?
REVEAL DETAILS
This plot was created using daily returns of SP500 from 1st Jan, 1990 to 9th August, 2019. Comforting to see that 95% of points lie between the +/- 2% (the blue vertical lines in the plot). Although, 5th Aug 2019 was tough on the portfolio.
Hover over the points to see the details
Some more plots just for fun.
The points between the blue vertical lines cover 90% of the days
Data: Yahoo Finance, Adjusted Close
Last Updated: 10 August, 2019
SHOW CODE
# imports
import pandas as pd
from pandas_datareader import data
import altair as alt
def get_data(ticker, start, end):
""" Download data and add daily returns """
df = data.get_data_yahoo(ticker, start, end)
df['returns'] = df['Adj Close'].pct_change()
return df
def make_altair_plot(data, title, q=[.05, .95], width=800, height=600):
""" Generates daily return scatter plot"""
data = data.reset_index()[['Date', 'returns']]
returns_chart = alt.Chart(data, width=100).mark_circle(size=8).encode(
x=alt.X('returns:Q', title='Daily Returns (%)',
axis=alt.Axis(format='%'),
scale=alt.Scale(domain=[-0.10, 0.10])),
y=alt.Y('jitter:Q', title=None, axis=None),
tooltip=[alt.Tooltip('Date:T'),
alt.Tooltip('returns:Q', title='Return', format='%')],
color=alt.Color('returns:Q',
scale=alt.Scale(scheme='blueorange'),
title='Returns'),
).transform_calculate(
jitter='sqrt(-2*log(random()))*cos(2*PI*random())'
).properties(
width=width, height=height,
title=title
).interactive()
# Get data and Plot
df = get_data('SPY', '1990-01-01', '2019-02-01')
make_altair_plot(df, 'S&P500 Returns between 1990-2019')