Stocks

Quantiacs provides data for companies listed on the NYSE and NASDAQ. Here we will discuss:

General information about tickers

The informations about the available stocks in the last 5 years can be obtained specifying the lookback period in calendar days multiplied by the number of years:

import qnt.data as qndata 

assets = qndata.stocks.load_list(tail= 365*5)

or defining the starting point in time:

assets = qndata.stocks.load_list(min_date="2015-01-01")

The information on each asset can be inspected with:

assets[0]
{'name': 'ALPHA PRO TECH LTD',
 'sector': 'Health Technology',
 'symbol': 'APT',
 'exchange': 'AMEX',
 'industry': 'Medical Specialties',
 'id': 'AMEX:APT',
 'cik': '884269',
 'FIGI': 'BBG000C1H7Y2'}

You can find a complete list here.

Market data

Market data can be downloaded using the following call:

import qnt.data as qndata
data = qndata.stocks.load_data(tail = 5*365, dims = ("time", "field", "asset"))

price_open = data.sel(field="open")
price_close = data.sel(field="close")
price_high = data.sel(field="high")
price_low = data.sel(field="low")
volume_day = data.sel(field="vol")
is_liquid = data.sel(field="is_liquid")
Data field Description
open open is the daily open price, i.e. the price at which a security trades when the exchange opens.
close Daily close price.
high Daily high price.
low Daily low price.
vol Daily number of traded shares.
divs Dividends from shares.
split It indicates a stock split. Split = 2.0 means that on this day there was a split of shares 2 to 1: the number of shares doubled, and their price halved.
split_cumprod The product of split values from the very beginning. It can be used for restoring original prices.
is_liquid This option determines whether this stock is liquid enough for trading. A stock is liquid if it is part of the top 500 stocks in terms of traded dollar volume over the last full calendar month.

Table 1. Available market data.

Stocks and data fields can be selected by the user specifying the companies to trade in the assets_names variable.

First, generate a list of all previously downloaded assets:

assets_names = [i["id"] for i in assets]

Then, after inspection, set the company names manually:

assets_names=['NASDAQ:AAPL', 'NASDAQ:GOOGL']

data = qndata.stocks.load_data(tail= 365*5, assets=assets_names)

price_open = data.sel(field="open")   
price_open.to_pandas().tail()
asset NASDAQ:AAPL NASDAQ:GOOGL
time
2020-08-13 12816.160 1508.21
2020-08-14 12860.820 1513.61
2020-08-17 12999.000 1515.97
2020-08-18 12807.480 1526.12
2020-08-19 12990.124 1552.49

Fundamental data

Fundamental data can be retrieved by using instant or periodic indicators.

Instant indicators.

Instant indicators reflect the current state of the company.

Data name Description
assets Total Assets
assets_curr Current Assets
equity Common equity
liabilities Total liabilities
liabilities_curr Current liabilities
debt_lt Long term debt
debt_st Short term debt
goodwill Goodwill
inventory Total inventory
investment_short_term Short-term investments
invested_capital Invested capital
shares Total shares outstanding. If reports do not contain such information we can use issued shares.
ppent Property plant and equipment net
cash_equivalent Cash equivalents are investment securities that are meant for short-term investing; they have high credit quality and are highly liquid.

Table 2. Instant indicators.

Periodic indicators.

Periodic indicators correspond to a certain period. For periodic indicators, you can receive information with the quarter, annual frequency, or ‘last twelve-month’ value.

Data name Description
sales_revenue_ltm / sales_revenue_af / sales_revenue_qf Revenue from sales
total_revenue_ltm / total_revenue_af / total_revenue_qf Total revenue
cashflow_op_ltm / cashflow_op_af / cashflow_op_qf Cashflow from operating activities
cogs_ltm / cogs_af / cogs_qf Cost of goods sold
divs_ltm / divs_af / divs_qf Dividends
eps_ltm / eps_af / eps_qf Earnings per share
income_ltm / income_af / income_qf / Income
interest_expense_ltm / interest_expense_af / interest_expense_qf Interest expenses
operating_expense_ltm / operating_expense_af / operating_expense_qf Operating expenses
operating_income_ltm / operating_income_af / operating_income_qf Operating income
rd_expense_ltm / rd_expense_af / rd_expense_qf Research and development expenses
sales_ps_ltm / sales_ps_af / sales_ps_qf Sales per share
sga_expense_ltm / sga_expense_af / sga_expense_qf Selling, general & administrative expenses

Table 3. Periodical indicators.

We use the fundamental data from the company’s reports stored in the EDGAR database. One can find information manually, by entering the company ticker on the U.S. Securities and Exchange Commission website. The reports consist of facts that are represented mainly in XBRL format. Available facts labels can be found here.