Skip to main content

Package to fetch a large quantity of data from tejapi.

Project description

使用 Tool API 獲取數據

安裝套件

pip install tej-tool-api

匯入套件

import os
os.environ['TEJAPI_KEY'] = "YOURAPIKEY"

import TejToolAPI

get_history_data - 獲取歷史資料

list_of_Stocks = ['2330','2303','2454', '2882', '2881']
# 撈取歷史資料
data = TejToolAPI.get_history_data(
ticker=list_of_Stocks,
columns= ['稅前淨利成長率', '單月營收成長率'], 
transfer_to_chinese=False
)

目前資料庫僅支援台灣市場。
Tool API 可獲取 PIT 資料庫的所有欄位,共計超過 600 個指標,具體指標內容參考欄位清單
財務數據是根據發布日(announcement date)來mapping,非發布日的財務數據會使用當下可獲得最新的資料為準進行填值。ex: 2330 在 2010-02-01 時所能獲得最新的財務資料為 2009Q3 的財務資料,則 2010-01-01 會以 2009Q3 的資料進行填補。惟公司2009Q4自結財報早於 2010-02-01 發布時,且 include_self_acc = 'Y',這時 2010-02-01 的財務數據使用自結財務數據。

參數:

Parameters Is Required Data Type Descriptions
ticker Required list 股票代碼,ex: ['2330', '2881', '2882']
columns Required list 欄位代碼,可參考欄位清單
start Optional date/str 起始日,ex: '2008-01-01' (預設值為 '2013-01-01'),目前版本尚未支援timezone的設定
end Optional date/str 結束日,ex: '2008-01-01' (預設值為今日 datetime.now()),目前版本尚未支援timezone的設定
transfer_to_chinese Optional boolean 欄位轉換成中文,若 transfer_to_chinese=True,則欄位顯示為中文名稱,transfer_to_chinese=False,則欄位顯示為英文名稱。(預設為 False)
fin_type Optional list 會計科目類型 -> 單季:Q、累計:A、移動四季:TTM,ex: 撈取單季和累積,fin_type=['Q','A']。(預設為 ['Q','A','TTM'])
include_self_acc Optional string 財務是否包含公司自結損益,include_self_acc='Y',表示財務資料包含自結損益,否則僅有財簽資料 (預設為 'N')
npartitions Optional int 代表取得資料時已n家公司為一組單位,ex: 取得100家資料時設定 npartitions = 50 ,則會分成 ceil(100/50) = 2 次 分別抓取後再合併

get_internal_code

內部欄位編碼與中英文簡稱轉換功能

TejToolAPI.get_internal_code(['稅前淨利成長率', 'Gross_Profit_Loss_from_Operations'])
output: ['r404', 'gm', 'a3295']

參數:

Parameters Is Required Data Type Descriptions
columns Required list 欄位(可以輸入"欄位代號"、"中文名稱"或"英文欄位"),可參考欄位清單

search_columns

若想從內部編碼反向取得 columns 所對應之中英文欄位則可利用 search_columns 這個function

TejToolAPI.search_columns(['r404'])
columns chn_column_names eng_column_names table_names TABLE_NAMES API_TABLE CHN_NAMES
r404 稅前淨利成長率 Pre_Tax_Income_Growth_Rate fin_self_acc fin_self_acc TWN/AFESTM1 財務-自結數
r404 稅前淨利成長率 Pre_Tax_Income_Growth_Rate fin_board_select fin_board_select TWN/AFESTMD 財務-董事決議數

參數:

Parameters Is Required Data Type Descriptions
columns Required list 欄位代碼,可參考欄位清單

search_table

TejToolAPI.search_table(['r404'])
COLUMNS TABLE_NAMES
r404 fin_self_acc
r404 fin_auditor

參數:

Parameters Is Required Data Type Descriptions
columns Required list 欄位代碼,可參考欄位清單

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tej_tool_api-1.3.1rc4.tar.gz (93.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tej_tool_api-1.3.1rc4-py3-none-any.whl (95.0 kB view details)

Uploaded Python 3

File details

Details for the file tej_tool_api-1.3.1rc4.tar.gz.

File metadata

  • Download URL: tej_tool_api-1.3.1rc4.tar.gz
  • Upload date:
  • Size: 93.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for tej_tool_api-1.3.1rc4.tar.gz
Algorithm Hash digest
SHA256 eaeb703a88075fc0273940b03cc6959e6a122a8064625029e3fef5387f2f8579
MD5 4fdd17096b0cc76e9438460984300684
BLAKE2b-256 b7d947fb983b7f3a89c1fa2d6622da3bb941021ad6e56c0c4e2d5092d557952d

See more details on using hashes here.

File details

Details for the file tej_tool_api-1.3.1rc4-py3-none-any.whl.

File metadata

File hashes

Hashes for tej_tool_api-1.3.1rc4-py3-none-any.whl
Algorithm Hash digest
SHA256 fb2ff50d1c0e2b016e752e4a4bcba85969c53c63f79e6a1d03d7eca1c060151d
MD5 1b6a4215e9ab07d4f17ed56c574a07fd
BLAKE2b-256 869203bc418e12b79fdd8793289d9e1ce765f657550f956669db60e3779126ed

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page