tej-tool-api


Nametej-tool-api JSON
Version 1.2.2 PyPI version JSON
download
home_pageNone
SummaryPackage to fetch a large quantity of data from tejapi.
upload_time2024-11-01 07:54:14
maintainertej api Development Team
docs_urlNone
authortej
requires_python>=3.8
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## 使用 Tool API 獲取數據(股價、財務、月營收、集保和股票屬性)
### 安裝套件
```python
pip install tej-tool-api
```

### 匯入套件
```python
import os
os.environ['TEJAPI_KEY'] = "YOURAPIKEY"

import TejToolAPI
```
### get_history_data - 獲取歷史資料<br>

```python
list_of_Stocks = ['2330','2303','2454', '2882', '2881']
# 撈取歷史資料
data = TejToolAPI.get_history_data(
ticker=list_of_Stocks,
columns= ['稅前淨利成長率', '單月營收成長率%'], 
transfer_to_chinese=False
)
```
目前資料庫僅支援台灣市場。<br>
Tool API 可獲取 PIT 資料庫的所有欄位,共計超過 600 個指標,具體指標內容參考[TEJAPI_量化投資資料庫](http://10.10.10.66/datatables.html?db=TWN&t=%E5%8F%B0%E7%81%A3%E8%B3%87%E6%96%99%E5%BA%AB#G%E9%87%8F%E5%8C%96%E6%8A%95%E8%B3%87) 。<br>
財務數據是根據發布日(announcement date)來mapping,非發布日的財務數據會使用當下可獲得最新的資料為準進行填值。ex: 2330 在 2010-02-01 時所能獲得最新的財務資料為 2009Q3 的財務資料,則 2010-01-01 會以 2009Q3 的資料進行填補。惟公司2009Q4自結財報早於 2010-02-01 發布時,且 include_self_acc = 'Y',這時 2010-02-01 的財務數據使用自結財務數據。<br>
<br>

**參數:**


| Parameters | Is Required | Data Type | Descriptions |
|------------|-------------|-----------|--------------|
| ticker     | Required    | list      | 股票代碼,ex: ['2330', '2881', '2882'] |
| columns    | Required    | list      | 欄位代碼,可參考[TEJAPI_量化投資資料庫](http://10.10.10.66/datatables.html?db=TWN&t=%E5%8F%B0%E7%81%A3%E8%B3%87%E6%96%99%E5%BA%AB#G%E9%87%8F%E5%8C%96%E6%8A%95%E8%B3%87) |
| 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       | 多核心執行,可以指定執行所要使用的核心數量,ex: npartitions=6,代表使用6個核心來運行程式 (預設為當前 CPU 可使用之核心數) |


### get_internal_code  <br>
內部欄位編碼與中英文簡稱轉換功能

```python
TejToolAPI.get_internal_code(['稅前淨利成長率', 'Gross_Profit_Loss_from_Operations'])

```
```html
output: ['r404', 'gm']
```
<br>

**參數:**

| Parameters | Is Required | Data Type | Descriptions |
|------------|-------------|-----------|--------------|
| columns    | Required    | list      | 欄位代碼,可參考[TEJAPI_量化投資資料庫](http://10.10.10.66/datatables.html?db=TWN&t=%E5%8F%B0%E7%81%A3%E8%B3%87%E6%96%99%E5%BA%AB#G%E9%87%8F%E5%8C%96%E6%8A%95%E8%B3%87) |


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

```python
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 | 財務-董事決議數 |

<br>

**參數:**



| Parameters | Is Required | Data Type | Descriptions |
|------------|-------------|-----------|--------------|
| columns    | Required    | list      | 欄位代碼,可參考[TEJAPI_量化投資資料庫](http://10.10.10.66/datatables.html?db=TWN&t=%E5%8F%B0%E7%81%A3%E8%B3%87%E6%96%99%E5%BA%AB#G%E9%87%8F%E5%8C%96%E6%8A%95%E8%B3%87) |

### search_table <br>
```python
TejToolAPI.search_table(['r404'])
```

| COLUMNS | TABLE_NAMES | 
|---------|-----------------|
| r404    | fin_self_acc    |
| r404    | fin_auditor    |

<br>

**參數:**



| Parameters | Is Required | Data Type | Descriptions |
|------------|-------------|-----------|--------------|
| columns    | Required    | list      | 欄位代碼,可參考[TEJAPI_量化投資資料庫](http://10.10.10.66/datatables.html?db=TWN&t=%E5%8F%B0%E7%81%A3%E8%B3%87%E6%96%99%E5%BA%AB#G%E9%87%8F%E5%8C%96%E6%8A%95%E8%B3%87) |



            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "tej-tool-api",
    "maintainer": "tej api Development Team",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "tej@tej.com.tw",
    "keywords": null,
    "author": "tej",
    "author_email": "tej@tej.com.tw",
    "download_url": "https://files.pythonhosted.org/packages/75/96/ee02b1dd6b25ef06ad873296aef379224a391be22f7de694a1b06c7bdd34/tej_tool_api-1.2.2.tar.gz",
    "platform": null,
    "description": "## \u4f7f\u7528 Tool API \u7372\u53d6\u6578\u64da(\u80a1\u50f9\u3001\u8ca1\u52d9\u3001\u6708\u71df\u6536\u3001\u96c6\u4fdd\u548c\u80a1\u7968\u5c6c\u6027)\n### \u5b89\u88dd\u5957\u4ef6\n```python\npip install tej-tool-api\n```\n\n### \u532f\u5165\u5957\u4ef6\n```python\nimport os\nos.environ['TEJAPI_KEY'] = \"YOURAPIKEY\"\n\nimport TejToolAPI\n```\n### get_history_data - \u7372\u53d6\u6b77\u53f2\u8cc7\u6599<br>\n\n```python\nlist_of_Stocks = ['2330','2303','2454', '2882', '2881']\n# \u6488\u53d6\u6b77\u53f2\u8cc7\u6599\ndata = TejToolAPI.get_history_data(\nticker=list_of_Stocks,\ncolumns= ['\u7a05\u524d\u6de8\u5229\u6210\u9577\u7387', '\u55ae\u6708\u71df\u6536\u6210\u9577\u7387\uff05'], \ntransfer_to_chinese=False\n)\n```\n\u76ee\u524d\u8cc7\u6599\u5eab\u50c5\u652f\u63f4\u53f0\u7063\u5e02\u5834\u3002<br>\nTool API \u53ef\u7372\u53d6 PIT \u8cc7\u6599\u5eab\u7684\u6240\u6709\u6b04\u4f4d\uff0c\u5171\u8a08\u8d85\u904e 600 \u500b\u6307\u6a19\uff0c\u5177\u9ad4\u6307\u6a19\u5167\u5bb9\u53c3\u8003[TEJAPI_\u91cf\u5316\u6295\u8cc7\u8cc7\u6599\u5eab](http://10.10.10.66/datatables.html?db=TWN&t=%E5%8F%B0%E7%81%A3%E8%B3%87%E6%96%99%E5%BA%AB#G%E9%87%8F%E5%8C%96%E6%8A%95%E8%B3%87) \u3002<br>\n\u8ca1\u52d9\u6578\u64da\u662f\u6839\u64da\u767c\u5e03\u65e5\uff08announcement date\uff09\u4f86mapping\uff0c\u975e\u767c\u5e03\u65e5\u7684\u8ca1\u52d9\u6578\u64da\u6703\u4f7f\u7528\u7576\u4e0b\u53ef\u7372\u5f97\u6700\u65b0\u7684\u8cc7\u6599\u70ba\u6e96\u9032\u884c\u586b\u503c\u3002ex: 2330 \u5728 2010-02-01 \u6642\u6240\u80fd\u7372\u5f97\u6700\u65b0\u7684\u8ca1\u52d9\u8cc7\u6599\u70ba 2009Q3 \u7684\u8ca1\u52d9\u8cc7\u6599\uff0c\u5247 2010-01-01 \u6703\u4ee5 2009Q3 \u7684\u8cc7\u6599\u9032\u884c\u586b\u88dc\u3002\u60df\u516c\u53f82009Q4\u81ea\u7d50\u8ca1\u5831\u65e9\u65bc 2010-02-01 \u767c\u5e03\u6642\uff0c\u4e14 include_self_acc = 'Y'\uff0c\u9019\u6642 2010-02-01 \u7684\u8ca1\u52d9\u6578\u64da\u4f7f\u7528\u81ea\u7d50\u8ca1\u52d9\u6578\u64da\u3002<br>\n<br>\n\n**\u53c3\u6578:**\n\n\n| Parameters | Is Required | Data Type | Descriptions |\n|------------|-------------|-----------|--------------|\n| ticker     | Required    | list      | \u80a1\u7968\u4ee3\u78bc\uff0cex: ['2330', '2881', '2882'] |\n| columns    | Required    | list      | \u6b04\u4f4d\u4ee3\u78bc\uff0c\u53ef\u53c3\u8003[TEJAPI_\u91cf\u5316\u6295\u8cc7\u8cc7\u6599\u5eab](http://10.10.10.66/datatables.html?db=TWN&t=%E5%8F%B0%E7%81%A3%E8%B3%87%E6%96%99%E5%BA%AB#G%E9%87%8F%E5%8C%96%E6%8A%95%E8%B3%87) |\n| start      | Optional    | date/str  | \u8d77\u59cb\u65e5\uff0cex: '2008-01-01' (\u9810\u8a2d\u503c\u70ba '2013-01-01')\uff0c\u76ee\u524d\u7248\u672c\u5c1a\u672a\u652f\u63f4timezone\u7684\u8a2d\u5b9a |\n| end        | Optional    | date/str  | \u7d50\u675f\u65e5\uff0cex: '2008-01-01' (\u9810\u8a2d\u503c\u70ba\u4eca\u65e5 datetime.now())\uff0c\u76ee\u524d\u7248\u672c\u5c1a\u672a\u652f\u63f4timezone\u7684\u8a2d\u5b9a|\n| transfer_to_chinese | Optional | boolean | \u6b04\u4f4d\u8f49\u63db\u6210\u4e2d\u6587\uff0c\u82e5 transfer_to_chinese=True\uff0c\u5247\u6b04\u4f4d\u986f\u793a\u70ba\u4e2d\u6587\u540d\u7a31\uff0ctransfer_to_chinese=False\uff0c\u5247\u6b04\u4f4d\u986f\u793a\u70ba\u82f1\u6587\u540d\u7a31\u3002(\u9810\u8a2d\u70ba False)|\n| fin_type   | Optional    | list      | \u6703\u8a08\u79d1\u76ee\u985e\u578b -> \u55ae\u5b63:Q\u3001\u7d2f\u8a08:A\u3001\u79fb\u52d5\u56db\u5b63:TTM\uff0cex: \u6488\u53d6\u55ae\u5b63\u548c\u7d2f\u7a4d\uff0cfin_type=['Q','A']\u3002(\u9810\u8a2d\u70ba ['Q','A','TTM']) |\n| include_self_acc | Optional | string | \u8ca1\u52d9\u662f\u5426\u5305\u542b\u516c\u53f8\u81ea\u7d50\u640d\u76ca\uff0cinclude_self_acc='Y'\uff0c\u8868\u793a\u8ca1\u52d9\u8cc7\u6599\u5305\u542b\u81ea\u7d50\u640d\u76ca\uff0c\u5426\u5247\u50c5\u6709\u8ca1\u7c3d\u8cc7\u6599 (\u9810\u8a2d\u70ba 'N') |\n| npartitions | Optional    | int       | \u591a\u6838\u5fc3\u57f7\u884c\uff0c\u53ef\u4ee5\u6307\u5b9a\u57f7\u884c\u6240\u8981\u4f7f\u7528\u7684\u6838\u5fc3\u6578\u91cf\uff0cex: npartitions=6\uff0c\u4ee3\u8868\u4f7f\u75286\u500b\u6838\u5fc3\u4f86\u904b\u884c\u7a0b\u5f0f (\u9810\u8a2d\u70ba\u7576\u524d CPU \u53ef\u4f7f\u7528\u4e4b\u6838\u5fc3\u6578) |\n\n\n### get_internal_code  <br>\n\u5167\u90e8\u6b04\u4f4d\u7de8\u78bc\u8207\u4e2d\u82f1\u6587\u7c21\u7a31\u8f49\u63db\u529f\u80fd\n\n```python\nTejToolAPI.get_internal_code(['\u7a05\u524d\u6de8\u5229\u6210\u9577\u7387', 'Gross_Profit_Loss_from_Operations'])\n\n```\n```html\noutput: ['r404', 'gm']\n```\n<br>\n\n**\u53c3\u6578:**\n\n| Parameters | Is Required | Data Type | Descriptions |\n|------------|-------------|-----------|--------------|\n| columns    | Required    | list      | \u6b04\u4f4d\u4ee3\u78bc\uff0c\u53ef\u53c3\u8003[TEJAPI_\u91cf\u5316\u6295\u8cc7\u8cc7\u6599\u5eab](http://10.10.10.66/datatables.html?db=TWN&t=%E5%8F%B0%E7%81%A3%E8%B3%87%E6%96%99%E5%BA%AB#G%E9%87%8F%E5%8C%96%E6%8A%95%E8%B3%87) |\n\n\n### search_columns <br>\n\u82e5\u60f3\u5f9e\u5167\u90e8\u7de8\u78bc\u53cd\u5411\u53d6\u5f97 columns \u6240\u5c0d\u61c9\u4e4b\u4e2d\u82f1\u6587\u6b04\u4f4d\u5247\u53ef\u5229\u7528 search_columns \u9019\u500bfunction <br>\n\n```python\nTejToolAPI.search_columns(['r404'])\n```\n\n\n| columns | chn_column_names | eng_column_names | table_names | TABLE_NAMES | API_TABLE | CHN_NAMES |\n|---------|-----------------|------------------|-------------|--------------|-----------|-----------|\n| r404    | \u7a05\u524d\u6de8\u5229\u6210\u9577\u7387    | Pre_Tax_Income_Growth_Rate | fin_self_acc | fin_self_acc | TWN/AFESTM1 | \u8ca1\u52d9-\u81ea\u7d50\u6578 |\n| r404    | \u7a05\u524d\u6de8\u5229\u6210\u9577\u7387    | Pre_Tax_Income_Growth_Rate | fin_board_select | fin_board_select | TWN/AFESTMD | \u8ca1\u52d9-\u8463\u4e8b\u6c7a\u8b70\u6578 |\n\n<br>\n\n**\u53c3\u6578:**\n\n\n\n| Parameters | Is Required | Data Type | Descriptions |\n|------------|-------------|-----------|--------------|\n| columns    | Required    | list      | \u6b04\u4f4d\u4ee3\u78bc\uff0c\u53ef\u53c3\u8003[TEJAPI_\u91cf\u5316\u6295\u8cc7\u8cc7\u6599\u5eab](http://10.10.10.66/datatables.html?db=TWN&t=%E5%8F%B0%E7%81%A3%E8%B3%87%E6%96%99%E5%BA%AB#G%E9%87%8F%E5%8C%96%E6%8A%95%E8%B3%87) |\n\n### search_table <br>\n```python\nTejToolAPI.search_table(['r404'])\n```\n\n| COLUMNS | TABLE_NAMES | \n|---------|-----------------|\n| r404    | fin_self_acc    |\n| r404    | fin_auditor    |\n\n<br>\n\n**\u53c3\u6578:**\n\n\n\n| Parameters | Is Required | Data Type | Descriptions |\n|------------|-------------|-----------|--------------|\n| columns    | Required    | list      | \u6b04\u4f4d\u4ee3\u78bc\uff0c\u53ef\u53c3\u8003[TEJAPI_\u91cf\u5316\u6295\u8cc7\u8cc7\u6599\u5eab](http://10.10.10.66/datatables.html?db=TWN&t=%E5%8F%B0%E7%81%A3%E8%B3%87%E6%96%99%E5%BA%AB#G%E9%87%8F%E5%8C%96%E6%8A%95%E8%B3%87) |\n\n\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Package to fetch a large quantity of data from tejapi.",
    "version": "1.2.2",
    "project_urls": {
        "homepage": "https://api.tej.com.tw",
        "repository": "https://github.com/tejtw/TEJ_TOOL_API"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cb6177bc0cfe0f8d133a8f541d0235ad7ff88382f2a62cb14167578ab601573b",
                "md5": "37616b1294a2c25b9210013be2a6cb20",
                "sha256": "aee1174b49a7cbd438573b8321d933907acf4038e72e6a260c1286b6b40c73e8"
            },
            "downloads": -1,
            "filename": "tej_tool_api-1.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "37616b1294a2c25b9210013be2a6cb20",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 78129,
            "upload_time": "2024-11-01T07:54:12",
            "upload_time_iso_8601": "2024-11-01T07:54:12.373585Z",
            "url": "https://files.pythonhosted.org/packages/cb/61/77bc0cfe0f8d133a8f541d0235ad7ff88382f2a62cb14167578ab601573b/tej_tool_api-1.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7596ee02b1dd6b25ef06ad873296aef379224a391be22f7de694a1b06c7bdd34",
                "md5": "4e97efb9e809332e36a489ae891af92b",
                "sha256": "41c8a7aabf44fc700fe041ecf96575de0be9e051be4e039204d99d563dd3e3f4"
            },
            "downloads": -1,
            "filename": "tej_tool_api-1.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "4e97efb9e809332e36a489ae891af92b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 77066,
            "upload_time": "2024-11-01T07:54:14",
            "upload_time_iso_8601": "2024-11-01T07:54:14.229359Z",
            "url": "https://files.pythonhosted.org/packages/75/96/ee02b1dd6b25ef06ad873296aef379224a391be22f7de694a1b06c7bdd34/tej_tool_api-1.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-01 07:54:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tejtw",
    "github_project": "TEJ_TOOL_API",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "tej-tool-api"
}
        
tej
Elapsed time: 0.49656s