{"id":16676,"date":"2022-01-11T02:34:54","date_gmt":"2022-01-10T18:34:54","guid":{"rendered":"https:\/\/www.tejwin.com\/?post_type=insight&#038;p=16676"},"modified":"2024-05-16T13:36:40","modified_gmt":"2024-05-16T05:36:40","slug":"pairs-trading","status":"publish","type":"insight","link":"https:\/\/www.tejwin.com\/en\/insight\/pairs-trading\/","title":{"rendered":"Pairs Trading"},"content":{"rendered":"\n<p id=\"36ba\">Establish a pairs trading strategy between Evergreen Shipping and Yang Ming Shipping with Python.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter is-resized caption-align-center\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/1EdDn4YCpJIqdt470Pt0cag.jpg\" alt=\"\" style=\"width:838px;height:559px\"\/><figcaption class=\"wp-element-caption\">Photo by&nbsp;<a href=\"https:\/\/unsplash.com\/@towfiqu999999?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText\" rel=\"noreferrer noopener\" target=\"_blank\">Towfiqu barbhuiya<\/a>&nbsp;on&nbsp;<a href=\"https:\/\/unsplash.com\/s\/photos\/finance?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText\" rel=\"noreferrer noopener\" target=\"_blank\">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-69d397ce2379b\" 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-69d397ce2379b\"  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:\/\/www.tejwin.com\/en\/insight\/pairs-trading\/#Highlights\" >Highlights<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.tejwin.com\/en\/insight\/pairs-trading\/#Preface\" >Preface<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.tejwin.com\/en\/insight\/pairs-trading\/#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-4\" href=\"https:\/\/www.tejwin.com\/en\/insight\/pairs-trading\/#Database_Used\" >Database Used<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.tejwin.com\/en\/insight\/pairs-trading\/#Data_Processing\" >Data Processing<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.tejwin.com\/en\/insight\/pairs-trading\/#Cointegration_test\" >Cointegration test<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.tejwin.com\/en\/insight\/pairs-trading\/#Build_pairs_trading_strategy\" >Build pairs trading strategy<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.tejwin.com\/en\/insight\/pairs-trading\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.tejwin.com\/en\/insight\/pairs-trading\/#Source_Code\" >Source Code<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.tejwin.com\/en\/insight\/pairs-trading\/#Extended_Reading\" >Extended Reading<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.tejwin.com\/en\/insight\/pairs-trading\/#Related_Link\" >Related Link<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"21b6\"><span class=\"ez-toc-section\" id=\"Highlights\"><\/span><strong>Highlights<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Difficulty:\u2605\u2605\u2605\u2606\u2606<\/li>\n\n\n\n<li>Reminder: Pairs trading combines two or three types of assets with a hedging effect to eliminate market risks, obtain a market-neutral impact, and set entry and exit conditions to generate entry and exit signals in the asset price difference sequence.\u00a0<a href=\"https:\/\/medium.com\/tej-api-%E9%87%91%E8%9E%8D%E8%B3%87%E6%96%99%E5%88%86%E6%9E%90\/%E8%B3%87%E6%96%99%E7%A7%91%E5%AD%B8-%E5%8D%81-arima-garch%E6%A8%A1%E5%9E%8B-%E4%B8%8A-4cf07dac75fd\" target=\"_blank\" rel=\"noopener\">The concept of stationary state<\/a>\u00a0has been introduced before; this article further applies the theory of time series to pairs trading. If you want to know more theoretical derivation, you can refer to\u00a0<a href=\"https:\/\/www.books.com.tw\/booksComment\/getCommemt\/E050038439\" target=\"_blank\" aria-label=\" (opens in a new tab)\" rel=\"noreferrer noopener\" class=\"ek-link\">the actual practice of finance<\/a>.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"3b3b\"><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=\"4d2d\">When the market capital is excessively flooded, to avoid systemic risks, investors often establish long and short positions at the same time through asset allocation to eliminate most market risks and obtain stable returns. However, we select Evergreen and Yangming as the stock pair for pairs trading and use a single root test to determine whether the two-level spread has a stationary state. That is, it confirms that Evergreen and Yangming have a cointegration relationship. When the spread deviates, buy undervalued stocks, sell overvalued stocks, and reverse the position to earn the spread when the spread corrects.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"96f5\"><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=\"4e20\">Windows OS and Jupyter Notebook<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># \u57fa\u672c\u529f\u80fd<br>import pandas as pd<br>import numpy as np<br>from arch.unitroot import ADF<br>import statsmodels.api as sm# \u7e6a\u5716<br>import matplotlib.pyplot as plt<br>plt.rcParams['font.sans-serif'] = ['Microsoft JhengHei']<br>plt.rcParams['axes.unicode_minus'] = False# TEJ API<br>import tejapi<br>tejapi.ApiConfig.api_key = 'Your Key'<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"a669\"><span class=\"ez-toc-section\" id=\"Database_Used\"><\/span><strong>Database Used<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p id=\"2300\"><a href=\"https:\/\/api.tej.com.tw\/columndoc.html?subId=50\" rel=\"noreferrer noopener\" target=\"_blank\">Return Information Data Table<\/a>\uff1a Listed securities with the daily return. Code is \u2018TWN\/EWPRCD2\u2019.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"aa6f\"><span class=\"ez-toc-section\" id=\"Data_Processing\"><\/span><strong>Data Processing<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p id=\"a29e\">Import the share price returns of Evergreen and Yang Ming from the TEJ database.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># \u532f\u5165\u8cc7\u6599<br>stock = tejapi.get('TWN\/EWPRCD2',<br>                   coid = ['2603','2609'],<br>                   mdate= {'gte': '2019-06-01','lte':'2021-06-30'},<br>                   opts={'columns':['coid','mdate','roia']},<br>                   chinese_column_name=True,paginate=True)stock = stock.pivot(index='\u65e5\u671f', columns='\u8b49\u5238\u78bc', values='\u65e5\u5831\u916c\u7387(%)')<br>stock.columns = ['2603 \u9577\u69ae','2609 \u967d\u660e']<br>stock = stock * 0.01<br>stock.tail(6)<\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/1_-8rsclb9pitZOaiHUS8Bw.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"d105\"><span class=\"ez-toc-section\" id=\"Cointegration_test\"><\/span><strong>Cointegration test<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p id=\"fbb7\"><strong>Step 1.&nbsp;<\/strong>The series of daily stock returns have a stationary state<\/p>\n\n\n\n<p id=\"06f7\">We can see that the two-level daily rate of return fluctuates around 0 from the figure below, and we can confirm that the two-level daily rate of return series has a steady state.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># \u9577\u69ae\u8207\u967d\u660e \u65e5\u5831\u916c\u7387\u7684\u6642\u5e8f\u5716<br>fig = plt.figure(figsize = (15,8))<br>ax = fig.add_subplot()ax.plot(stock['2603 \u9577\u69ae'] ,linewidth=2, alpha=1)<br>ax.plot(stock['2609 \u967d\u660e'] ,linewidth=2, alpha=0.7)<br>ax.axhline(0,color = 'black')<br>ax.set_title('\u9577\u69ae\u8207\u967d\u660e \u65e5\u5831\u916c\u7387\u7684\u6642\u5e8f\u5716' ,fontsize=20 ,fontweight='bold')<br>ax.legend(['2603 \u9577\u69ae','2609 \u967d\u660e'],loc='best')<br>ax.set_ylabel('\u5831\u916c\u7387', fontsize=12,rotation=0)<br>ax.grid(axis='y')<\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/1_1ZXA65usxZMZwkKD99wVMAQ.png\" alt=\"\"\/><\/figure>\n\n\n\n<p id=\"1ae8\"><strong>Step 2.&nbsp;<\/strong>Calculate the spread of the stock pair<\/p>\n\n\n\n<p id=\"103b\">First, We divide the backtest period into the formation and trading periods. When we calculate the spread sequence of the trading period to avoid the forward-looking bias, we use the alpha coefficient value and the beta coefficient value obtained from the linear regression of the spread series in the formation period to calculate the spread series for the trading period.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># \u50f9\u5dee<br>def CointegrationSpread(df,formStart,formEnd,tradeStart,tradeEnd):<br>    formX = df[(df.index &gt;= formStart) &amp; (df.index &lt;= formEnd)]['2603 \u9577\u69ae']<br>    formY = df[(df.index &gt;= formStart) &amp; (df.index &lt;= formEnd)]['2609 \u967d\u660e']<br>    tradeX = df[(df.index &gt;= tradeStart) &amp; (df.index &lt;= tradeEnd)]['2603 \u9577\u69ae']<br>    tradeY = df[(df.index &gt;= tradeStart) &amp; (df.index &lt;= tradeEnd)]['2609 \u967d\u660e']<br>    <br>    results = sm.OLS(formY,sm.add_constant(formX)).fit()<br>    spread = tradeY - results.params[0] - results.params[1] * tradeX<br>    return spreadSpread_2020_10_12 = CointegrationSpread(stock,'2019-06-01','2020-06-30','2020-10-01','2020-12-31')<br>Spread_2021_01_03 = CointegrationSpread(stock,'2020-01-01','2020-12-31','2021-01-01','2021-03-30')# \u5c0d\u5169\u6a94\u80a1\u50f9\u7684\u50f9\u5dee\u5e8f\u5217\u505a\u5b9a\u614b\u6027\u6aa2\u5b9a<br>adfSpread = ADF(Spread_2021_10_12, trend='n')<br>print(adfSpread.summary().as_text())<\/pre>\n\n\n\n<p id=\"304c\">We see in the below figure that we can reject the null hypothesis at the 1% significance level, indicating that the 2021_10_12 spread series is stationary. The daily return series of Evergreen and Yangming have a cointegration relationship.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/1664wVy2PvWjwHc3ABIsmLg.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"333f\"><span class=\"ez-toc-section\" id=\"Build_pairs_trading_strategy\"><\/span><strong>Build pairs trading strategy<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p id=\"88e2\">We formulate trading strategies based on the opening and closing points,<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>When the spread crosses \u03bc+1.5\u03c3, short the paired stocks and open a position in the opposite direction (sell Yangming; buy Evergreen).<\/li>\n\n\n\n<li>When the spread crosses below \u03bc+0.2\u03c3, long for paired stocks and close the position in the opposite direction.<\/li>\n\n\n\n<li>When the spread crosses \u03bc\u22121.5\u03c3, go long for paired stocks and open positions opposite (buy Yangming; sell Evergreen).<\/li>\n\n\n\n<li>When the spread crosses \u03bc\u22120.2\u03c3, short the paired stock and closes the position in the opposite direction.<\/li>\n\n\n\n<li>When the spread exceeds \u03bc\u00b12.5\u03c3, the position will be closed immediately.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">Spread_2021_01_03 = Spread_2021_01_03.to_frame()<br>Spread_2021_01_03.columns = ['\u50f9\u5dee']Spread_2021_01_03['\u958b\u5009\u5e73\u5009\u5340\u9593'] = \\<br>    pd.cut(Spread_2021_01_03['\u50f9\u5dee'] ,<br>           (float('-inf') ,mu-2.5*sd ,mu-1.5*sd ,mu-0.2*sd ,<br>            mu+0.2*sd ,mu+1.5*sd ,mu+2.5*sd ,float('inf')) ,labels=False)-3Spread_2021_01_03['\u4ea4\u6613\u8a0a\u865f'] = \\<br>    np.select([(Spread_2021_01_03['\u958b\u5009\u5e73\u5009\u5340\u9593'].shift() == 1) &amp;<br>               (Spread_2021_01_03['\u958b\u5009\u5e73\u5009\u5340\u9593'] == 2),<br>               <br>               (Spread_2021_01_03['\u958b\u5009\u5e73\u5009\u5340\u9593'].shift() == 1) &amp;<br>               (Spread_2021_01_03['\u958b\u5009\u5e73\u5009\u5340\u9593'] == 0),<br>               <br>               (Spread_2021_01_03['\u958b\u5009\u5e73\u5009\u5340\u9593'].shift() == 2) &amp;<br>               (Spread_2021_01_03['\u958b\u5009\u5e73\u5009\u5340\u9593'] == 3),<br>               <br>               (Spread_2021_01_03['\u958b\u5009\u5e73\u5009\u5340\u9593'].shift() == -1) &amp;<br>               (Spread_2021_01_03['\u958b\u5009\u5e73\u5009\u5340\u9593'] == -2),<br>               <br>               (Spread_2021_01_03['\u958b\u5009\u5e73\u5009\u5340\u9593'].shift() == -1) &amp;<br>               (Spread_2021_01_03['\u958b\u5009\u5e73\u5009\u5340\u9593'] == 0),<br>               <br>               (Spread_2021_01_03['\u958b\u5009\u5e73\u5009\u5340\u9593'].shift() == -2) &amp;<br>               (Spread_2021_01_03['\u958b\u5009\u5e73\u5009\u5340\u9593'] == -3)],<br>              <br>              [-2,2,3,1,-1,-3],default = 0)position = [Spread_2021_01_03['\u4ea4\u6613\u8a0a\u865f'][0]]<br>ns = len(Spread_2021_01_03['\u4ea4\u6613\u8a0a\u865f'])Spread_2021_01_03['\u5009\u4f4d\u60c5\u6cc1'] = pd.Series(position,index=Spread_2021_01_03.index)<br>Spread_2021_01_03['\u5009\u4f4d\u60c5\u6cc1'] = Spread_2021_01_03['\u5009\u4f4d\u60c5\u6cc1'].shift() # \u9694\u5929\u958b\u76e4\u624d\u9032\u5834Spread_2021_01_03 = Spread_2021_01_03.join(stock)<br>Spread_2021_01_03['\u7b56\u7565\u5831\u916c\u7387'] = \\<br>    np.select([Spread_2021_01_03['\u5009\u4f4d\u60c5\u6cc1'] == 1,<br>               Spread_2021_01_03['\u5009\u4f4d\u60c5\u6cc1'] == 0,<br>               Spread_2021_01_03['\u5009\u4f4d\u60c5\u6cc1'] == -1],<br>              [Spread_2021_01_03['2609 \u967d\u660e'] * -1 + Spread_2021_01_03['2603 \u9577\u69ae'] * 1,<br>               0,<br>               Spread_2021_01_03['2609 \u967d\u660e'] * 1 + Spread_2021_01_03['2603 \u9577\u69ae'] * -1], default=np.nan)Spread_2021_01_03['\u7d2f\u7a4d\u5831\u916c\u7387'] = (Spread_2021_01_03['\u7b56\u7565\u5831\u916c\u7387'] + 1).cumprod() -1<br>Spread_2021_01_03.head(10)<\/pre>\n\n\n\n<p id=\"850c\">We complete the above strategy and present the strategy\u2019s cumulative return and a maximum drawdown in the graph below.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/1VLBONO9_oR2gQjNlt5EOyA.png\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/19LOQJKd9YGhgu9zqcBut9A.png\" alt=\"\"\/><\/figure>\n\n\n\n<p id=\"76a4\">From the maximum drawdown chart, We can find that the maximum drawdown of the two pairs trade has fallen below 8% in a row, which means that the strategy\u2019s stop-loss mechanism is not very good, or the \u03bc mean and \u03c3 parameters are out of order. In the future, you can try to lower the standard of 2.5\u03c3 or calculate the \u03bc mean and \u03c3 standard deviation of the formation period spread series in a rolling method because the volatility of maritime stocks in the first half of 2021 is extremely high. As a result, the trading period fell in 2021. From January to March 2020, the formation period is from January to December 2020.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"ee2b\"><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=\"d487\">The content of this webpage is not an investment device and does not constitute an offer or solicitation to offer or recommendation of any investment product. It is for learning purposes only and does not consider your individual needs, investment objectives, and specific financial circumstances. Investment involves risk. Past performance is not indicative of future performance. Readers are requested to use their independent thinking skills to make investment decisions independently. The author will not be involved if losses are incurred due to relevant suggestions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"b35d\"><span class=\"ez-toc-section\" id=\"Source_Code\"><\/span><strong>Source Code<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/gist.github.com\/tej87681088\/78e7f08d59edcabe80f475ddd8c63c07#file-tejapi_medium-10-ipynb\" class=\"ek-link\" target=\"_blank\" rel=\"noopener\">Click here to go Github<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"d5bb\"><span class=\"ez-toc-section\" id=\"Extended_Reading\"><\/span><strong>Extended Reading<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.tejwin.com\/en\/insight\/arima-garch-modelpart-1\/\" class=\"ek-link\">ARIMA-GARCH Model(Part 1)<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"dcc5\"><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\" rel=\"noreferrer noopener\" target=\"_blank\">TEJ E-Shop<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Establish a pairs trading strategy between Evergreen Shipping and Yang Ming Shipping with Python. Highlights Preface When the market capital is excessively flooded, to avoid systemic risks, investors often establish long and short positions at the same time through asset allocation to eliminate most market risks and obtain stable returns. However, we select Evergreen and [&hellip;]<\/p>\n","protected":false},"featured_media":16678,"template":"","tags":[2583,2613,2371,3005],"insight-category":[690,50],"class_list":["post-16676","insight","type-insight","status-publish","has-post-thumbnail","hentry","tag-finance","tag-pair-trading","tag-python","tag-tejapi-application","insight-category-data-analysis","insight-category-fintech"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/insight\/16676","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"}],"version-history":[{"count":1,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/insight\/16676\/revisions"}],"predecessor-version":[{"id":23306,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/insight\/16676\/revisions\/23306"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/media\/16678"}],"wp:attachment":[{"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/media?parent=16676"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/tags?post=16676"},{"taxonomy":"insight-category","embeddable":true,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/insight-category?post=16676"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}