Skip to content

Instantly share code, notes, and snippets.

@alg0trader
Last active January 16, 2021 03:59
Show Gist options
  • Save alg0trader/e3ed3711436d3981ac468e25808fd798 to your computer and use it in GitHub Desktop.
Save alg0trader/e3ed3711436d3981ac468e25808fd798 to your computer and use it in GitHub Desktop.
Stonks Discord Logo
import numpy as np
import pandas as pd
import yfinance as yf
import statsmodels.api as sm
import matplotlib.pyplot as plt
from matplotlib import patheffects
from datetime import datetime
# Input Parameters
stonk = 'LMFA'
start = datetime(2021, 1, 15, 9, 0)
end = datetime(2021, 1, 15, 16, 0)
# Functions
def get_data(symbol, start, end, interval='1m'):
stock_prices = yf.download( tickers = symbol,
interval = interval,
start = start,
end = end,
auto_adjust = False,
progress = False )
# convert list to pandas dataframe
return pd.DataFrame(stock_prices, columns=['Open', 'High', 'Low', 'Close', 'Volume'])
# Get data
stonk_data = get_data(stonk, start, end)
cycle, trend = sm.tsa.filters.hpfilter(stonk_data['Close'])
# Plot data
with plt.xkcd():
plt.rcParams['path.effects'] = [patheffects.withStroke(linewidth=0)]
plt.plot(stonk_data['Close'], linewidth=12)
plt.plot(trend, linewidth=12)
plt.axis('off')
plt.grid(linewidth=0.5)
plt.savefig('stonk_logo.png', transparent=True)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment