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 yfinance as yf | |
import datetime as dt | |
from pandas_datareader import data as pdr | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import matplotlib.ticker as mticker | |
yf.pdr_override() | |
sma = 50 | |
limit = 30 |
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 numpy as np | |
import warnings | |
from pandas_datareader import data as pdr | |
import yfinance as yf | |
import datetime as dt | |
from yahoo_fin import stock_info as si | |
import pandas as pd | |
pd.set_option('display.max_rows', None) | |
warnings.filterwarnings("ignore") | |
yf.pdr_override() |
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
def get_top_abs_correlations(df): | |
au_corr = df.corr().abs().unstack() | |
labels_to_drop = get_redundant_pairs(df) | |
au_corr = au_corr.drop(labels=labels_to_drop).sort_values(ascending=False) | |
return au_corr | |
print("\nTop Absolute Correlations") | |
print(get_top_abs_correlations(stocks_returns)) |
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
def get_redundant_pairs(df): | |
pairs_to_drop = set() | |
cols = df.columns | |
for i in range(0, df.shape[1]): | |
for j in range(0, i+1): | |
pairs_to_drop.add((cols[i], cols[j])) | |
return pairs_to_drop | |
def get_top_abs_correlations(df): | |
au_corr = df.corr().abs().unstack() |
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
dataset = pdr.get_data_yahoo(tickers, start, end)['Adj Close'] | |
stocks_returns = np.log(dataset/dataset.shift(1)) | |
print('\nCorrelation Matrix') | |
corr_matrix = stocks_returns.corr() | |
print (corr_matrix) |
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 numpy as np | |
import warnings | |
from pandas_datareader import data as pdr | |
import yfinance as yf | |
import datetime as dt | |
from yahoo_fin import stock_info as si | |
import pandas as pd | |
pd.set_option('display.max_rows', None) | |
warnings.filterwarnings("ignore") | |
yf.pdr_override() |
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
# Importing necessary libraries | |
import time | |
import pandas as pd | |
from selenium import webdriver | |
from selenium.webdriver.chrome.options import Options | |
from selenium.webdriver.chrome.service import Service | |
from webdriver_manager.chrome import ChromeDriverManager | |
from selenium.webdriver.common.by import By | |
from pandas_datareader import data as pdr | |
import yfinance as yf |
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 pandas as pd | |
import numpy as np | |
from bs4 import BeautifulSoup as soup | |
from urllib.request import Request, urlopen | |
pd.set_option('display.max_colwidth', 25) | |
# Input | |
symbol = input('Enter a ticker: ') | |
print ('Getting data for ' + symbol + '...\n') |
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
def get_fundamentals(): | |
try: | |
# Find fundamentals table | |
fundamentals = pd.read_html(str(html), attrs = {'class': 'snapshot-table2'})[0] | |
# Clean up fundamentals dataframe | |
fundamentals.columns = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11'] | |
colOne = [] | |
colLength = len(fundamentals) | |
for k in np.arange(0, colLength, 2): |
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 pandas as pd | |
import numpy as np | |
from bs4 import BeautifulSoup as soup | |
from urllib.request import Request, urlopen | |
pd.set_option('display.max_colwidth', 25) | |
# Input | |
symbol = input('Enter a ticker: ') | |
print ('Getting data for ' + symbol + '...\n') |
NewerOlder