Skip to content

Instantly share code, notes, and snippets.

@Kazanskyi
Created June 7, 2022 19:50
Show Gist options
  • Save Kazanskyi/a82fdbac439711efd16a719a34c7471e to your computer and use it in GitHub Desktop.
Save Kazanskyi/a82fdbac439711efd16a719a34c7471e to your computer and use it in GitHub Desktop.
import pandas as pd
import numpy as np
import tiingo_data as tii
from datetime import date
print("Please enter the company's symbol: ")
symbol = input()
#Get all companies sector, industry, location, etc
metadata = tii.fetch_metadata()
#Hitorical Prices Open, Close, Low, High, Volume for historical data
stock_dataset = tii.fetch_stock(symbol, todays_date, historical_dates_range)
# Getting stock market cap, PE Ratio, PB Ratio
fundamentals = tii.fetch_fundamentals(symbol, todays_date, historical_dates_range)
# Financial KPIs
statements = tii.fetch_statements(symbol, todays_date, historical_dates_range)
# Get stock sector and industry
stock_metadata = metadata[metadata.ticker == symbol.lower()][["sector","industry"]].copy()
# Combining all stock's data
big_dataset = tii.combine_tables(stock_dataset, statements, fundamentals, stock_metadata, historical_dates_range)
big_dataset.sort_values(by = 'date', axis = 0, ascending = False, inplace = True)
big_dataset["Debt-to-Equity_Ratio"] = big_dataset["totalAssets"]/big_dataset["totalLiabilities"]
big_dataset["DividendsYield"] = big_dataset["payDiv"]/big_dataset["marketCap"]
big_dataset["PayoutRatio"] = big_dataset["payDiv"]/big_dataset["grossProfit"]
big_dataset["Acc_Rec_Pay_Ration"] = big_dataset["acctRec"]/big_dataset["acctPay"]
big_dataset["Earnings_per_stock"] = big_dataset["epsDil"]/big_dataset["close"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment