Last active
September 29, 2021 15:10
-
-
Save WillianFuks/55a047c3392b02bfa24083e7c2349a1c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import pandas_datareader as pdr | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import pandas as pd | |
btc_data = pdr.get_data_yahoo(['BTC-USD'], | |
start=datetime.datetime(2018, 1, 1), | |
end=datetime.datetime(2020, 12, 3))['Close'] | |
btc_data = btc_data.reset_index().drop_duplicates(subset='Date', keep='last').set_index('Date').sort_index() | |
btc_data = btc_data.resample('D').fillna('nearest') | |
X_data = pdr.get_data_yahoo(['TWTR', 'GOOGL', 'AAPL', 'MSFT', 'AMZN', 'FB', 'GOLD'], | |
start=datetime.datetime(2018, 1, 1), | |
end=datetime.datetime(2020, 12, 2))['Close'] | |
X_data = X_data.reset_index().drop_duplicates(subset='Date', keep='last').set_index('Date').sort_index() | |
X_data = X_data.resample('D').fillna('nearest') | |
data = pd.concat([btc_data, X_data], axis=1) | |
data.dropna(inplace=True) | |
data = data.resample('W-Wed').last() # Weekly is easier to process. We select Wednesday to 2020-10-21 is available. | |
data = data.astype(np.float32) | |
np.log(data).plot(figsize=(15, 12)) | |
plt.axvline('2020-10-14', 0, np.max(data['BTC-USD']), lw=2, ls='--', c='red', label='PayPal Impact') | |
plt.legend(loc='upper left') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment