6. Uniformly defined financial history tables

DataTable is qteasy’s unified built-in storage table definition. It includes:

6.1. The most important data table

  • trade_calendar — Trading calendar for all exchanges (trading day, exchange code/name). Core to qteasy: many features fail or slow without it. Used to determine trading days and download date ranges — fill this table first.

  • stock_basic — Stock basics table with code, name, listing/delisting dates, industry, region, etc. Foundation for stock daily K-line and financial tables; prioritize filling this table.

  • index_basic — Index basics table with code, name, publish/delisting dates, etc. Foundation for index daily K-line and constituent tables; prioritize filling this table.

  • fund_basic — Fund basics table with code, name, type, size, etc. Foundation for fund daily K-line and NAV tables; prioritize filling this table.

Besides key tables, DataSource defines many more covering basics, daily K-line, financials, dividends, earnings reports, macro data, etc.:

  • Market data tables — OHLCV K-line data for stocks, funds, and indices at various frequencies

  • Basics tables — Basic information for stocks, funds, indices, futures, options, etc.

  • Indicator tables — Technical, fundamental, macro, and other indicators

  • Financial statement tables — Balance sheet, income statement, cash flow, etc.

  • Earnings report tables — Listed-company earnings reports: express reports, earnings guidance, forecasts, etc.

  • Dividend & block-trade tables — Dividend data, block trades, shareholder transactions, etc.

  • Reference tables — Macro, industry, exchange, and other reference data

Table schema is available via DataSource.get_table_info():

>>> from qteasy import DataSource
>>> ds = DataSource()
>>> ds.get_table_info('trade_calendar')

6.2. Table definitions

Each table in qteasy has these basic attributes:

  • Table use: Purpose of the table; available operations differ by use. Examples: basics = basics, finance = financials, report = earnings reports, reference = reference data, etc.

  • Asset type: Asset class covered — E stock, IDX index, FD fund, FT futures, OPT options, etc.

  • Frequency: Stored data frequency — mins minute, d daily, w weekly, m monthly, q quarterly, y yearly, none not frequency-specific

  • Sharding: Some tables are sharded due to size; related attributes include shard count and shard key columns

  • Table SCHEMA: Defines all columns and data types

Table SCHEMA defines all columns and types; field meanings:

  • columns – column names

  • dtypes – column data types: varchar for strings, int for integers, float for floats, date for dates, text for text

  • remarks – column remarks

  • is_prime_key – whether the column is part of the primary key; Y = yes, N = no

6.3. Trading calendar table definition:

Using the trading calendar as an example, its attributes and SCHEMA are:

Trading calendar: trade_calendar

Table use: basics, asset type: none, frequency: none

columns

dtypes

remarks

is_prime_key

0

cal_date

date

Date: format YYYYMMDD

Y

1

exchange

varchar(9)

Exchanges: SSE Shanghai, SZSE Shenzhen, CFFEX, SHFE, CZCE, DCE, INE

Y

2

is_open

tinyint

Is trading day: yes = 1, no = 0

N

3

pretrade_date

date

Previous trading day

N