import os # Importing packages import pandas as pd import yfinance as yf from yahooquery import Screener # Setting the working directory path = 'C:/Directory' os.chdir(path) # Defining the “Screener” object s = Screener() # Retrieving information on 250 cryptocurrencies data = s.get_screeners('all_cryptocurrencies_us', count=250) # Storing information needed (Name and tickers stored in quotes) info = data['all_cryptocurrencies_us']['quotes'] # Retrieving the tickers from “info” tickers = [d['symbol'] for d in info] full_name = [d['shortName'] for d in info] # Retrieving historical data on “tickers” data = yf.download(tickers, start="2017-09-10") # Getting the Adjusted close prices time_series = data['Adj Close'] # Converting the results to panda Data frame df1 = pd.DataFrame(time_series) df1.reset_index(inplace=True) df1['Date'] = df1['Date'].dt.tz_localize(None) # Print the results to excel df1.to_excel('Crypto_price.xlsx', sheet_name='Prices') # Getting market cap market_cap = [d['marketCap'] for d in info] # Tickers, Full name, and Market cap to data frame df = pd.DataFrame({"Tickers": tickers, "Full name": full_name, "Market cap": market_cap})