{"id":16020,"date":"2021-07-13T02:30:52","date_gmt":"2021-07-12T18:30:52","guid":{"rendered":"https:\/\/www.tejwin.com\/?post_type=insight&#038;p=16020"},"modified":"2023-08-10T10:36:39","modified_gmt":"2023-08-10T02:36:39","slug":"starting-using-tej-trial-database","status":"publish","type":"insight","link":"https:\/\/tejwin20260323.j.webweb.today\/en\/insight\/starting-using-tej-trial-database\/","title":{"rendered":"Starting Using TEJ Trial Database"},"content":{"rendered":"\n<p>The application and usage of TEJ API trial database<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized caption-align-center\"><img fetchpriority=\"high\" decoding=\"async\" src=\"https:\/\/tejwin20260323.j.webweb.today\/wp-content\/uploads\/image-245.png\" alt=\"\" class=\"wp-image-16022\" width=\"842\" height=\"561\" srcset=\"https:\/\/tejwin20260323.j.webweb.today\/wp-content\/uploads\/image-245.png 700w, https:\/\/tejwin20260323.j.webweb.today\/wp-content\/uploads\/image-245-300x200.png 300w, https:\/\/tejwin20260323.j.webweb.today\/wp-content\/uploads\/image-245-150x100.png 150w\" sizes=\"(max-width: 842px) 100vw, 842px\" \/><figcaption class=\"wp-element-caption\">Photo Creds:\u00a0<a href=\"https:\/\/unsplash.com\/\" target=\"_blank\" rel=\"noreferrer noopener\" class=\"ek-link\">Unsplash<\/a><\/figcaption><\/figure>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_81 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a10f9555cd2b\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"ez-toc-cssicon\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a10f9555cd2b\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/tejwin20260323.j.webweb.today\/en\/insight\/starting-using-tej-trial-database\/#Preface\" >Preface<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/tejwin20260323.j.webweb.today\/en\/insight\/starting-using-tej-trial-database\/#The_Editing_Environment_and_Modules_Required\" >The Editing Environment and Modules Required<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/tejwin20260323.j.webweb.today\/en\/insight\/starting-using-tej-trial-database\/#The_Highlights_of_the_Article\" >The Highlights of the Article<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/tejwin20260323.j.webweb.today\/en\/insight\/starting-using-tej-trial-database\/#Key_Application\" >Key Application<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/tejwin20260323.j.webweb.today\/en\/insight\/starting-using-tej-trial-database\/#Usage_of_Database\" >Usage of Database<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/tejwin20260323.j.webweb.today\/en\/insight\/starting-using-tej-trial-database\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/tejwin20260323.j.webweb.today\/en\/insight\/starting-using-tej-trial-database\/#Related_Link\" >Related Link<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"141e\"><span class=\"ez-toc-section\" id=\"Preface\"><\/span><strong>Preface<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p id=\"8d30\">With the increase of the calculation power of chips, Big Data has become more and more important, especially in the field of the financial markets. How to analyze a specific industry or company precisely? It always comes bias if we analyze by our intuition. Therefore, we could analyze based on numerous pieces of data to get more objective insight.<\/p>\n\n\n\n<p id=\"2c67\">TEJ built the free database which provided variable financial data in recent one year. It includes operation, trade, finance, fund, future, option and real estate. This database is high cost-performance ratio for beginners to start coding. Let\u2019s get started now!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"1fb5\"><span class=\"ez-toc-section\" id=\"The_Editing_Environment_and_Modules_Required\"><\/span><strong>The Editing Environment and Modules Required<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p id=\"1402\">We use Mac OS and Jupyter Notebook in this article<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import tejapi\nimport pandas as pd\nimport numpy as np<\/code><\/pre>\n\n\n\n<p><em>Note: Please install tejapi by command prompt(Windows)\/Terminal (Mac) and then type<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install tejapi<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"97bc\"><span class=\"ez-toc-section\" id=\"The_Highlights_of_the_Article\"><\/span><strong>The Highlights of the Article<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Apply for the key of database<\/li>\n\n\n\n<li>Get the data we need<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"05e9\"><span class=\"ez-toc-section\" id=\"Key_Application\"><\/span><strong>Key Application<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p id=\"e893\"><strong>Step 1.<\/strong>&nbsp;Click the&nbsp;<a href=\"https:\/\/api.tej.com.tw\/index.html\" rel=\"noreferrer noopener\" target=\"_blank\">TEJ API<\/a>&nbsp;link.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter caption-align-center\"><img decoding=\"async\" src=\"https:\/\/tejwin20260323.j.webweb.today\/wp-content\/uploads\/1_19juDf9m33K1l8k7-XB1GGA.png\" alt=\"\"\/><figcaption class=\"wp-element-caption\">TEJ API home page<\/figcaption><\/figure>\n\n\n\n<p id=\"6b6e\"><strong>Step 2.<\/strong>&nbsp;Click Apply for Trial.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/tejwin20260323.j.webweb.today\/wp-content\/uploads\/1_1whLQ6KNmKRQxAg3VqPGdrw.png\" alt=\"\"\/><\/figure>\n\n\n\n<p id=\"e9e7\"><strong>Step 3.&nbsp;<\/strong>Check the message and get the verification code.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/tejwin20260323.j.webweb.today\/wp-content\/uploads\/1Czk0Qy163lUnvmJ5RHGUyg.png\" alt=\"\"\/><\/figure>\n\n\n\n<p id=\"9495\"><strong>Step 4.&nbsp;<\/strong>Type the verification code<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/tejwin20260323.j.webweb.today\/wp-content\/uploads\/1_1qnMut5c6B6YksY_tU2Texw.png\" alt=\"\"\/><\/figure>\n\n\n\n<p id=\"ad89\"><strong>Step 5.&nbsp;<\/strong>Success<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/tejwin20260323.j.webweb.today\/wp-content\/uploads\/1_1eOhyEL6eWCvdF9OyRZMURw.png\" alt=\"\"\/><\/figure>\n\n\n\n<p id=\"3a86\"><strong>Step 6.&nbsp;<\/strong>Check the email<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/tejwin20260323.j.webweb.today\/wp-content\/uploads\/1_1FV5lE-oaT4TXsXqu5MtEYg.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"78cf\"><span class=\"ez-toc-section\" id=\"Usage_of_Database\"><\/span><strong>Usage of Database<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p id=\"048d\">We can see the&nbsp;<a href=\"https:\/\/api.tej.com.tw\/datatables.html?db=TRAIL&amp;t=%E8%A9%A6%E7%94%A8%E8%B3%87%E6%96%99%E5%BA%AB\" rel=\"noreferrer noopener\" target=\"_blank\">trial database<\/a>&nbsp;in the TEJ API list. There is abundant data on this page.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/tejwin20260323.j.webweb.today\/wp-content\/uploads\/1_1gRfmKX36ROnbDeCIqZbanA.png\" alt=\"\"\/><\/figure>\n\n\n\n<p id=\"fa37\">Let\u2019s try to get the daily price and volume of Evergreen Marine Corporation 2603. Click the<a href=\"https:\/\/api.tej.com.tw\/columns.html?idCode=TRAIL%2FTAPRCD\" rel=\"noreferrer noopener\" target=\"_blank\">&nbsp;<strong>Detailed description<\/strong><\/a>&nbsp;which is next to the listed unadjusted price.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/tejwin20260323.j.webweb.today\/wp-content\/uploads\/1_1jDDh4M5cPXpOPt3wcdmb1A.png\" alt=\"\"\/><\/figure>\n\n\n\n<p id=\"6b43\">Open the Jupyter Notebook.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tejapi.ApiConfig.api_key = \"your key\"<\/code><\/pre>\n\n\n\n<p id=\"5f95\">Replace \u2018 your key \u2019 with the key we just applied for.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>data = tejapi.get('TRAIL\/TAPRCD')<\/code><\/pre>\n\n\n\n<p id=\"455c\">Each database has its specific code. TRAIL\/TAPRCD is code of database containing daily stock price and volume. We use attribution of tejapi \u2018get\u2019, and assign data to the variable&nbsp;<code><em>data<\/em><\/code>.<\/p>\n\n\n\n<p id=\"20c1\">This method will download whole data. But we only need the data of 2603. Therefore, we have to filter the data by altering the column description to choose the data we need.<\/p>\n\n\n\n<p id=\"2dcc\"><strong>Filter<\/strong><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"f695\"><em>coid, ticker<br>mdate date, (gte : start date\u3001lte : the last day)<br>opts columns, (date\u3001close price\u3001volumn)<br>chinese_column_name, column names shown in Chinese<\/em><\/p>\n<\/blockquote>\n\n\n\n<pre class=\"wp-block-code\"><code>data = tejapi.get('TRAIL\/TAPRCD', \n                   coid='2603', \n                   mdate={'gte':'2020-01-01', 'lte':'2020-12-31'},\n                   opts={'columns':&#91;'mdate','close_d', 'volume']},\n                   chinese_column_name=True\n                  )<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/tejwin20260323.j.webweb.today\/wp-content\/uploads\/1Ut0SR3CDN-1AaEqDV_979g.png\" alt=\"\"\/><\/figure>\n\n\n\n<p id=\"7b55\">Do you find there is a difference between your table and this picture? Try to add this line of code.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tejapi.ApiConfig.ignoretz = True<\/code><\/pre>\n\n\n\n<p>Finally, replace the index with the date column.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>data.set_index('\u5e74\u6708\u65e5', inplace=True)<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/tejwin20260323.j.webweb.today\/wp-content\/uploads\/14VmP0dVo6nJ3lAcqPURTLg.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"e787\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span><strong>Conclusion<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p id=\"2d06\">Today, we display how to use the TEJ API trial database. There is still a lot of data waiting for us to dig. With this data, we can do more advanced analysis, such as formulating trading strategy, evaluating investment risks, etc. You can see other applications in the extended reading at the bottom of this article. If you want to use longer-term data or other professional financial data, it is recommended to use&nbsp;<a href=\"https:\/\/eshop.tej.com.tw\/E-Shop\/Edata_caseIntro\/2\" rel=\"noreferrer noopener\" target=\"_blank\"><strong>advanced schemes<\/strong><\/a>, which will be more perfect for formulating our strategy!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"0e12\"><span class=\"ez-toc-section\" id=\"Related_Link\"><\/span><strong>Related Link<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/api.tej.com.tw\/index.html\" rel=\"noreferrer noopener\" target=\"_blank\">TEJ API<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/eshop.tej.com.tw\/E-Shop\/Edata_intro\" target=\"_blank\" rel=\"noreferrer noopener\">TEJ E-Shop<\/a><a href=\"https:\/\/medium.com\/tag\/python?source=post_page-----223e0cb5c341---------------python-----------------\" target=\"_blank\" rel=\"noopener\"><\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>The application and usage of TEJ API trial database Preface With the increase of the calculation power of chips, Big Data has become more and more important, especially in the field of the financial markets. How to analyze a specific industry or company precisely? It always comes bias if we analyze by our intuition. Therefore, [&hellip;]<\/p>\n","protected":false},"featured_media":16023,"template":"","tags":[2371,3006],"insight-category":[690,50],"class_list":["post-16020","insight","type-insight","status-publish","has-post-thumbnail","hentry","tag-python","tag-tejapi-beginners-guide","insight-category-data-analysis","insight-category-fintech"],"acf":[],"_links":{"self":[{"href":"https:\/\/tejwin20260323.j.webweb.today\/en\/wp-json\/wp\/v2\/insight\/16020","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tejwin20260323.j.webweb.today\/en\/wp-json\/wp\/v2\/insight"}],"about":[{"href":"https:\/\/tejwin20260323.j.webweb.today\/en\/wp-json\/wp\/v2\/types\/insight"}],"version-history":[{"count":0,"href":"https:\/\/tejwin20260323.j.webweb.today\/en\/wp-json\/wp\/v2\/insight\/16020\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tejwin20260323.j.webweb.today\/en\/wp-json\/wp\/v2\/media\/16023"}],"wp:attachment":[{"href":"https:\/\/tejwin20260323.j.webweb.today\/en\/wp-json\/wp\/v2\/media?parent=16020"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tejwin20260323.j.webweb.today\/en\/wp-json\/wp\/v2\/tags?post=16020"},{"taxonomy":"insight-category","embeddable":true,"href":"https:\/\/tejwin20260323.j.webweb.today\/en\/wp-json\/wp\/v2\/insight-category?post=16020"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}