{"id":2771,"date":"2021-06-01T00:52:42","date_gmt":"2021-06-01T00:52:42","guid":{"rendered":"https:\/\/www.tejwin.com\/en\/insights\/when-tej-api-meets-line-notify\/"},"modified":"2021-06-01T00:52:42","modified_gmt":"2021-06-01T00:52:42","slug":"when-tej-api-meets-line-notify","status":"publish","type":"insight","link":"https:\/\/www.tejwin.com\/en\/insights\/when-tej-api-meets-line-notify\/","title":{"rendered":"When TEJ API meets Line Notify"},"content":{"rendered":"<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"wp-image-15964\" height=\"493\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/image-242.png\" style=\"width:839px;height:560px\" width=\"739\"\/><\/figure>\n<p class=\"wp-block-paragraph\">Sending the important data information to your phone through Line Notify<\/p>\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\" id=\"536d\">After building our own database through TEJ API and understanding how to use Window Task Scheduler to update the database regularly a few weeks ago. Today we are going to teach you how to make it more convenient.\u00a0<strong>That is through the<\/strong>\u00a0<strong>Line Notify to automatically import the data we want into our Line!<\/strong><\/p>\n<\/blockquote>\n<h2 class=\"wp-block-heading\" id=\"6677\"><strong>Highlights of this article <\/strong><\/h2>\n<ul class=\"wp-block-list\">\n<li><strong>Line Notify Intro<\/strong><\/li>\n<li><strong>Line Notify Apply<\/strong><\/li>\n<li><strong>Line Notify + TEJ API<\/strong><\/li>\n<\/ul>\n<h2 class=\"wp-block-heading\" id=\"e201\"><strong>Links related to this article<\/strong><\/h2>\n<ul class=\"wp-block-list\">\n<li><strong>1\ufe0f\u20e3 API Official Website:\u00a0<\/strong><a href=\"https:\/\/api.tej.com.tw\/\" rel=\"noreferrer noopener\" target=\"_blank\"><strong>TEJ API Official Website<\/strong><\/a><\/li>\n<li><strong>2\ufe0f\u20e3 The Product Package:\u00a0<\/strong><a href=\"https:\/\/eshop.tej.com.tw\/E-Shop\/Edata_caseIntro\/1\" rel=\"noreferrer noopener\" target=\"_blank\"><strong>TEJ E SHOP<\/strong><\/a><\/li>\n<li><strong>3\ufe0f\u20e3 Source Code:\u00a0<\/strong><a href=\"https:\/\/github.com\/tejtw\/TEJAPI_Python_Medium_Application\" rel=\"noreferrer noopener\" target=\"_blank\"><strong>TEJ GITHUB<\/strong><\/a><\/li>\n<\/ul>\n<h2 class=\"wp-block-heading\" id=\"805c\"><strong>Line Notify Intro<\/strong><\/h2>\n<p class=\"wp-block-paragraph\" id=\"e609\"><strong>Line Notify is also an API.<\/strong>\u00a0Like TEJ API that allows users to interact with the TEJ database with Python,\u00a0<strong>Line Notify allows Python to interact with Line.<\/strong>\u00a0Therefore, the application can be widely used, from the web crawler to find the price of the thing you want to the financial data when the conditions are met.\u00a0<strong>It just purely depends on what kind of data or information that the users need.<\/strong><\/p>\n<h2 class=\"wp-block-heading\" id=\"9c1a\"><strong>Line Notify Apply<\/strong><\/h2>\n<p class=\"wp-block-paragraph\" id=\"452b\">We can apply the API KEY through\u00a0<a href=\"https:\/\/notify-bot.line.me\/zh_TW\/\" rel=\"noreferrer noopener\" target=\"_blank\"><strong>Line Notify Official Website<\/strong><\/a><strong>.\u00a0<\/strong>After logging in, you can see a button called Login Service and click it. You will see the following fields and fill in the information and you will see similar to the following picture. Among these fields, the<strong>\u00a0service URL<\/strong>\u00a0and<strong>\u00a0Callback URL<\/strong>\u00a0are both\u00a0<a href=\"http:\/\/127.0.0.1\/\" rel=\"noreferrer noopener\" target=\"_blank\">http:\/\/127.0.0.1<\/a>, and the remaining fields are your own information.<\/p>\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/1_1SrIxVksu_mdYxVie-WdwXg.png\"\/><\/figure>\n<p class=\"wp-block-paragraph\" id=\"0646\">After filling all the fields and sending out the application, a verification letter will be sent to your email. Then you will see the webpage in the picture below:<\/p>\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/1_1l8ccFwlstJoNC_BFLmrxKQ.png\"\/><\/figure>\n<p class=\"wp-block-paragraph\" id=\"6dcd\">Now Line has given us a Client ID. Then you can find a button called \u201cPersonal Page\u201d through the red box on the upper right, then find the \u201cIssuance Token\u201d at the bottom of the page. After clicking the button, Then you will see the webpage in the picture below:<\/p>\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/1nnr5wNtGDEcdngsEyCNskg.png\"\/><\/figure>\n<p class=\"wp-block-paragraph\" id=\"3cfd\">This webpage will ask users about the chat room where users want to receive notifications. In addition to yourself, you need to use groups if you want to send information to multiple people!<\/p>\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/1iOX0P4csMdCMbPEaHFQfDA.png\"\/><\/figure>\n<p class=\"wp-block-paragraph\" id=\"bb55\">After confirming the chat room you want to send, click release, you can get our\u00a0<strong>Token (similar to API KEY)<\/strong>, as shown in the figure:<\/p>\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/1DnmZ5biDpZSrUPHYG1_Tag.png\"\/><\/figure>\n<p class=\"wp-block-paragraph\" id=\"f647\"><strong>Now let\u2019s coding~~<\/strong><\/p>\n<h2 class=\"wp-block-heading\" id=\"615a\"><strong>Line Notify + TEJ API<\/strong><\/h2>\n<h3 class=\"wp-block-heading\" id=\"8168\"><strong>Import Packages<\/strong><\/h3>\n<p class=\"wp-block-paragraph\" id=\"9a5d\">Let\u2019s first import the packages which will be used in our code.<\/p>\n<pre class=\"wp-block-code\"><code>import tejapi \nimport pandas as pd\nimport numpy as np\nimport datetime\nimport matplotlib.pyplot as plt\ntejapi.ApiConfig.api_key = \"your key\"\ntejapi.ApiConfig.ignoretz = True<\/code><\/pre>\n<h3 class=\"wp-block-heading\" id=\"3d83\"><strong>Getting and organizing the data through the TEJ API<\/strong><\/h3>\n<p class=\"wp-block-paragraph\" id=\"7771\">Then get the data we want from the TEJ API.\u00a0<strong>Here we use 2330 and 2303 as examples.<\/strong>\u00a0You can replace the symbols you want!<\/p>\n<pre class=\"wp-block-code\"><code>ticks = ['2330', '2303', '1101']\nDailyPrice= tejapi.get('TWN\/EWPRCD',coid=ticks,\n                        opts={'columns':['coid', 'mdate', 'open_d',  'high_d','low_d', 'close_d']},\n                        mdate={'gte':'2020-05-01','lte':'2021-05-25'}, paginate=True, )\nDailyPrice= DailyPrice.set_index('mdate')\n<\/code><\/pre>\n<p class=\"wp-block-paragraph\">After collecting the data, we do some simple calculations, such as\u00a0<strong>the 5-day moving average, monthly moving average, and the rate of daily return.<\/strong>\u00a0Because TEJ will update the latest data at 2:30 pm after the closing of each day,<strong>\u00a0don\u2019t worry about you will use the wrong data after this time!<\/strong><\/p>\n<pre class=\"wp-block-code\"><code>MovingAvg_5D = {}\nMovingAvg_20D = {}\nDailyRt = {}\nfor ticker in ticks:\n    MovingAvg_5D[ticker] = DailyPrice[DailyPrice['coid']==ticker]['close_d'].rolling(5).mean()\n    MovingAvg_20D[ticker] = DailyPrice[DailyPrice['coid']==ticker]['close_d'].rolling(20).mean()\n    DailyRt[ticker] = DailyPrice[DailyPrice['coid']==ticker]['close_d'].pct_change()*100<\/code><\/pre>\n<h3 class=\"wp-block-heading\" id=\"9496\"><strong>Connecting to the Line Notify<\/strong><\/h3>\n<p class=\"wp-block-paragraph\" id=\"2ad7\">Next is to connect to our Line Notify. We first set the Token we got above and write a function for Line Notify. The internal parameters of the function do not need to be changed. The main purpose of the function is to send the information we want to our mobile phones through Line Notify.<\/p>\n<pre class=\"wp-block-code\"><code>token = \"your token\"\ndef LineNotify(params, token):\n    \n    headers = {\n        \"Authorization\": \"Bearer \" + token,\n        \"Content-Type\": \"application\/x-www-form-urlencoded\"\n        }\n    r = requests.post(\"https:\/\/notify-api.line.me\/api\/notify\", headers=headers, params=params)\n    print(r.status_code)<\/code><\/pre>\n<p class=\"wp-block-paragraph\">The next step is to find the data we want from the indicators and set the conditions. Here we use\u00a0<strong>if the five-day moving average or monthly moving average goes up as the signal<\/strong>. In addition to returning the current moving average price, we reply with the latest close price and the daily rate of return together.<\/p>\n<pre class=\"wp-block-code\"><code>import requests\nparams = []\nfor ticker in ticks:\n    \n    if MovingAvg_20D[ticker][-1] &gt; MovingAvg_20D[ticker][-2] and MovingAvg_5D[ticker][-1] &gt; MovingAvg_5D[ticker][-2]:\n\n        params.append('\\n' + ticker + ':\\n' \n                      + \"\u4e94\u65e5\u5747\u7dda\u5f80\u4e0a\u70ba: \" + str(round(MovingAvg_5D[ticker][-1],2)) + '\\n' \n                      + \"\u6708\u5747\u7dda\u5f80\u4e0a\u70ba: \" + str(round(MovingAvg_20D[ticker][-1],2)) + '\\n' \n                      + \"\u65e5\u5831\u916c\u7387\u70ba: \" + str(round(DailyRt[ticker][-1],2)) + '%' + '\\n' \n                      + \"\u7576\u524d\u50f9\u683c: \" + str(round(DailyPrice[DailyPrice['coid']==ticker]['close_d'][-1])) + '\\n')\n    \n    elif MovingAvg_20D[ticker][-1] &gt; MovingAvg_20D[ticker][-2]:\n\n        params.append('\\n' + ticker + ':\\n' \n                      + \"\u6708\u5747\u7dda\u5f80\u4e0a\u70ba: \" + str(round(MovingAvg_20D[ticker][-1],2)) + '\\n' \n                      + \"\u65e5\u5831\u916c\u7387\u70ba: \" + str(round(DailyRt[ticker][-1],2)) + '%' + '\\n' \n                      + \"\u7576\u524d\u50f9\u683c: \" + str(round(DailyPrice[DailyPrice['coid']==ticker]['close_d'][-1])) + '\\n')\n    \n    elif MovingAvg_5D[ticker][-1] &gt; MovingAvg_5D[ticker][-2]:\n\n        params.append('\\n' + ticker + ':\\n' \n                      + \"\u4e94\u65e5\u5747\u7dda\u5f80\u4e0a\u70ba: \" + str(round(MovingAvg_5D[ticker][-1],2)) + '\\n'  \n                      + \"\u65e5\u5831\u916c\u7387\u70ba: \" + str(round(DailyRt[ticker][-1],2)) + '%' + '\\n' \n                      + \"\u7576\u524d\u50f9\u683c: \" + str(round(DailyPrice[DailyPrice['coid']==ticker]['close_d'][-1])) + '\\n')  \n    \nparams = {'message': params}\nLineNotify(params, token)<\/code><\/pre>\n<p class=\"wp-block-paragraph\" id=\"a015\">After everything is completed, we can see that our Line Notify will send the data which meets the condition we set earlier to our Line!!<\/p>\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/1KR7Qa1Nlv2M_9twzQ2gLeQ.png\"\/><\/figure>\n<h2 class=\"wp-block-heading\" id=\"2b5c\"><strong>Conclusion<\/strong><\/h2>\n<p class=\"wp-block-paragraph\" id=\"f5e4\">Today\u2019s content is mainly extended from\u00a0<a class=\"ek-link\" href=\"https:\/\/medium.com\/tej-api-financial-data-anlaysis\/introduction-2-building-your-own-database-through-tej-api-2ee3c14ba86d\" rel=\"noopener\" target=\"_blank\">Building your own database through TEJ API<\/a>. With Line Notify, we can directly send the information we want to our mobile phones every day. Today, we only use the moving average and daily return for demonstration.\u00a0<strong>You can also try your own indicators, such as technical indicators, moving average breakthroughs, or just want to know the latest closing price every day, etc.<\/strong>\u00a0In this way, it saves our time to check everything one by one!<\/p>\n<p class=\"wp-block-paragraph\" id=\"e95a\">Finally, if you like this topic, please click \ud83d\udc4f below, giving us more support and encouragement. Additionally, if you have any questions or suggestions, please leave a message or email us, we will try our best to reply to you.\ud83d\udc4d\ud83d\udc4d<\/p>\n<h2 class=\"wp-block-heading\" id=\"ab87\"><strong>Links related to this article again!<\/strong><\/h2>\n<ul class=\"wp-block-list\">\n<li><strong>1\ufe0f\u20e3 API Official Website:\u00a0<\/strong><a href=\"https:\/\/api.tej.com.tw\/\" rel=\"noreferrer noopener\" target=\"_blank\"><strong>TEJ API Official Website<\/strong><\/a><\/li>\n<li><strong>2\ufe0f\u20e3 The Product Package:\u00a0<\/strong><a href=\"https:\/\/eshop.tej.com.tw\/E-Shop\/Edata_caseIntro\/1\" rel=\"noreferrer noopener\" target=\"_blank\"><strong>TEJ E SHOP<\/strong><\/a><\/li>\n<li><strong>3\ufe0f\u20e3 Source Code:\u00a0<\/strong><a href=\"https:\/\/github.com\/tejtw\/TEJAPI_Python_Medium_Application\" rel=\"noreferrer noopener\" target=\"_blank\"><strong>TEJ GITHUB<\/strong><\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Sending the important data information to your phone through Line Notify After building our own database through TEJ API and understanding how to use Window Task Scheduler to update the database regularly a few weeks ago. Today we are going to teach you how to make it more convenient.\u00a0That is through the\u00a0Line Notify to automatically [\u2026]<\/p>\n","protected":false},"featured_media":2764,"template":"","tags":[65,70],"insight_category":[16],"class_list":["post-2771","insight","type-insight","status-publish","has-post-thumbnail","hentry","tag-python","tag-tej-api","insight_category-quant-data-science"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/insight\/2771","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/insight"}],"about":[{"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/types\/insight"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/media\/2764"}],"wp:attachment":[{"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/media?parent=2771"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/tags?post=2771"},{"taxonomy":"insight_category","embeddable":true,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/insight_category?post=2771"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}