<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by 鄧昱辰 on Medium]]></title>
        <description><![CDATA[Stories by 鄧昱辰 on Medium]]></description>
        <link>https://medium.com/@Abnerteng?source=rss-2b2362117b38------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*53zgruzweJ6svZdVpJ37jw.png</url>
            <title>Stories by 鄧昱辰 on Medium</title>
            <link>https://medium.com/@Abnerteng?source=rss-2b2362117b38------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 19 May 2026 14:59:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@Abnerteng/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Refactor your Python code — 1]]></title>
            <link>https://medium.com/@Abnerteng/refactor-your-python-code-1-1f614d1204fa?source=rss-2b2362117b38------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f614d1204fa</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[coding-style]]></category>
            <category><![CDATA[code-refactoring]]></category>
            <dc:creator><![CDATA[鄧昱辰]]></dc:creator>
            <pubDate>Sun, 03 Mar 2024 12:24:19 GMT</pubDate>
            <atom:updated>2024-03-03T12:24:19.945Z</atom:updated>
            <content:encoded><![CDATA[<h3>Refactor your Python code — 1</h3><blockquote>“Any fool can write code that a computer can understand. Good programmers write code that humans can understand”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*V1EP6RRLGg6Pb7Av.jpg" /><figcaption>image by: <a href="https://weblogs.asp.net/uruit/code-refactoring">https://weblogs.asp.net/uruit/code-refactoring</a></figcaption></figure><p>在談 Refactor Python code 之前，需要先談談兩件重要的事</p><ol><li>.ipynb file</li><li>Coding Style</li></ol><p>我有 Code Refactor 這個觀念也是從一年前左右才建立起來的，在這之前我寫 code 很醜，可讀性與可擴充性都低到不行，也常常將一整個 .ipynb file 就直接丟在 GitHub repo 中。</p><p>而就是在實習時被 code review，舊的 code 也要常常拿出來改的情況下，才開始意識到繼續這樣寫 code 遲早有一天會出事，因此在主管的嚴格要求以及自己的研究下，慢慢建立起在乎 coding style 這樣的好習慣。</p><h3>.ipynb file</h3><p>為什麼要提到 .ipynb 呢？使用 .ipynb file 寫 Python 的人應該都知道這非常方便，變數可以直接改、直接檢查，東西做到一半壞掉可以修完再接著寫。</p><p>然而，這個 IDE 對於開發有幾個缺點</p><ol><li>非線性工作流程：雖然這也是優點之一，但基本上所有人都會不小心覆蓋到先前寫過的 code，導致在最後執行以為會成功的 code 出現 error message。</li><li>Trace code 不便：基本上 .ipynb file 在撰寫時就是一個檔案從頭寫到尾，以一個機器學習的 project 來說，從資料前處理到最後的模型解釋可能都在同一個檔案內。而這時缺點就浮現了，這可能會是個幾千行的 code，那當要 trace 某個 function 時，無疑就是大海撈針。</li><li>無法進行版本控制：.ipynb 是 JSON 格式的文件，且表格與圖片（輸出結果）皆儲存於其中，導致文件變得非常雜亂。</li><li>不利於自動化：無法使用 argument parser 進行參數解析，假設在訓練模型時每個 model 配到的 超參數都不同，我必須手動對 code 進行修改，但如果使用 .py 則可以配合 shell script 直接傳入不同組合的參數。。</li></ol><p>但這也不代表說在開發時不能使用 .ipynb file，只是在最後一定一定要將 .ipynb 轉成 .py 以利專案進行。</p><h3>Coding Style</h3><p>Coding style 其實是一個大議題，我們可以先看看有 coding style 與沒有 coding style 的差別：</p><ul><li>沒有 coding style</li></ul><pre>def Calcarea(a, b):<br>    return a * b<br><br>a = 5<br>b = 4<br>r = Calcarea(a, b)<br>print(r)</pre><ul><li>有 coding style</li></ul><pre>def calculate_area(len: int, wid: int) -&gt; int:<br>    &quot;&quot;&quot;<br>    Calculate the area of a rectangle<br><br>    Input<br>    - len: length of the rectangle<br>    - wid: width of the rectangle<br><br>    Output<br>    - Area of rectangle<br>    &quot;&quot;&quot;    <br>    return len * wid<br><br>length, width = 5, 4<br>area = calculate_area(length, width)<br><br>print(f&quot;The area of rectangle: {area}&quot;)</pre><p>必須說，沒有 coding style 的寫法是很快沒錯啦，但試想一下你要跟別人合作，或是多年後你發現當初寫錯了，要回來改這個 code，你的 coworker 或是你自己一定會想要把沒有 coding style 的你殺了，因為真的不知道要從何下手。</p><p>講了這麼多，要怎麼建立起 coding style 呢，他有沒有什麼規範可以參考？有的，以 Python 來說，最常見的就是 PEP8 格式（也是我自己參照的格式），簡單列舉一些 PEP8 的重要規範</p><ul><li>單行字數 ≤ 79</li><li>避免 import 自助餐</li></ul><pre>from utils import *</pre><ul><li>numerical operator 前後需要空格，但 kwargs 不需要</li></ul><pre>a = b + c<br>beta = (x.T @ y) / (x.T @ x)<br>df[&quot;pred&quot;] = predict_output <br>precision = evaluate(metric=&quot;precision&quot;)</pre><ul><li>命名規範：一般變數、函數全小寫，中間以 _ 隔開、class 的第一個字為大寫、常數為全大寫</li></ul><pre>length = 10<br><br>def calculate_length(*args, **kwargs):<br>    pass<br><br>class Evaluation:<br>    def __init__():<br>        pass<br><br>PI = 3.14</pre><p>今天大概就到這邊啦，有興趣的朋友們可以至 PEP8 官方文件觀看更細節的規範，下一次會介紹更進一步介紹 function 以及 class 的 coding style，以及自動幫你偵測 coding style 的 linter。</p><p><a href="https://peps.python.org/pep-0008/">PEP 8 - Style Guide for Python Code | peps.python.org</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f614d1204fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LaTeX tutorial — 版面設定]]></title>
            <link>https://medium.com/@Abnerteng/latex-tutorial-%E7%89%88%E9%9D%A2%E8%A8%AD%E5%AE%9A-a15ea5a14aac?source=rss-2b2362117b38------2</link>
            <guid isPermaLink="false">https://medium.com/p/a15ea5a14aac</guid>
            <category><![CDATA[latex]]></category>
            <category><![CDATA[layout]]></category>
            <dc:creator><![CDATA[鄧昱辰]]></dc:creator>
            <pubDate>Fri, 07 Jul 2023 10:17:29 GMT</pubDate>
            <atom:updated>2023-07-07T10:17:29.813Z</atom:updated>
            <content:encoded><![CDATA[<h3>LaTeX tutorial — 版面設定</h3><p>前年夏天的時候，我剛接觸 notion 中 Block equation 以及 Inline equation 這兩個撰寫數學式的好工具，那時候天真的以為 LaTeX 就這樣而已，好像沒有很難，直到第一次用 TeX Studio 寫報告時被 LaTeX 排版的設定嚇到了，怎麼那麼多參數要調，就算調了也不知道自己在調什麼。最後我花了整整一個月才把那份報告的排版調到自己滿意的程度，再者，排版才是 LaTeX 的精髓所在，因此今天這篇文章就要告訴剛入門 LaTeX 的讀者要如何寫出實用度極高的排版，以及每個參數代表的意義。</p><h3>Start!</h3><p>最原始的 LaTeX 排版就是不排版（當然沒有人這樣寫）</p><pre>\documentclass{12pt}[article]<br>\begin{document}<br>  Hello \LaTeX!<br>\end{document}</pre><p>在原始排版的基礎上，我們會使用一個叫 geometry 的套件，簡單來說，</p><p>geometry 套件可以讓我們輕易的更改整個文章的版面格式。</p><pre>\documentclass[a4paper, 12pt]{article}<br>%%=============Geometry package===============<br>\usepackage[textwidth=17cm, textheight=25.7cm]{geometry}<br><br>\begin{document}<br>  Hello \LaTeX<br>\end{document}</pre><p>如下圖所示，我將正文區域縮減至長 25.7 公分，寬 17 公分，也就是說，我留了左右各 2 公分 ((21–17)/2)，上下各 2 公分 ((29.7–25.7)/2) 的邊界。</p><p>那如果我想進一步調整上緣為 1 公分，下緣為 3 公分呢？我只需要多加兩個參數。</p><pre>\usepackage[textwidth=17cm, textheight=25.7cm, top=1cm, bottom=3cm]{geometry}<br><br>%% bottom=3cm 可以不加</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qqRWLw287aD7O8WQQzGdIw.png" /><figcaption>geometry 參數圖示</figcaption></figure><p>以下為常用參數介紹</p><pre>1. nohead: 等於 headheight=0pt, headsep=0pt<br>2. nofoot: 等於 footskip=0pt<br>3. hscale: 可列印區域之寬度與紙張寬度之比率，ex: hscale=0.8<br>4. marginparwidth: marginal note 之寬度<br>5. marginparsep: marginal note 與正文區域之間距<br>6. width: textwidth+marginparwidth+marginparsep</pre><h4>調整行距 / 段距</h4><pre>\linespread{2.0} <br>\setlength{\parskip}{1em}</pre><p>這樣就可以調整成原本的兩倍行距，以及段距 0.35416 cm (10pt)</p><h4>首行縮排 / 不縮排</h4><pre>\setlength{\parindent}{24pt}<br>\noindent</pre><p>假設在字體大小設定為 12pt 的情況下， \setlength{\parindent}{24pt} 的意思為首行縮排兩個字的距離; \noindent 則表示首行不縮排</p><p>最後附上我前一段時間整理的 LaTeX 模板給大家使用</p><p><a href="https://github.com/AbnerTeng/LaTeX-templates">https://github.com/AbnerTeng/LaTeX-templates</a></p><h3>Reference</h3><ol><li><a href="http://homepage.ntu.edu.tw/~ntut019/cwtex/cxbook3.pdf">http://homepage.ntu.edu.tw/~ntut019/cwtex/cxbook3.pdf</a></li><li><a href="https://texdoc.org/serve/geometry.pdf/0">https://texdoc.org/serve/geometry.pdf/0</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a15ea5a14aac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[python 實作配對交易策略-1]]></title>
            <link>https://medium.com/@Abnerteng/python-%E5%AF%A6%E4%BD%9C%E9%85%8D%E5%B0%8D%E4%BA%A4%E6%98%93%E7%AD%96%E7%95%A5-1-523815413dca?source=rss-2b2362117b38------2</link>
            <guid isPermaLink="false">https://medium.com/p/523815413dca</guid>
            <category><![CDATA[pair-trading]]></category>
            <category><![CDATA[quantitative-finance]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[economics]]></category>
            <dc:creator><![CDATA[鄧昱辰]]></dc:creator>
            <pubDate>Wed, 18 Jan 2023 10:09:46 GMT</pubDate>
            <atom:updated>2023-01-18T10:09:46.346Z</atom:updated>
            <content:encoded><![CDATA[<p>配對交易是基於假設兩檔股票之價差服從定態、或有均值回歸的特性。</p><p>首先要介紹的配對交易策略是 cointegration，也就是共整合交易策略，在介紹共整合時要先講解時間序列的兩個特性：定態(stationary) 與非定態(non-stationary)。</p><ol><li>定態時間序列</li></ol><p>定態時間序列又分為弱定態時間序列與強定態時間序列</p><p>一個時間序列為弱定態的條件為</p><ul><li>該時間序列的平均為常數，不隨時間變動而改變</li><li>該時間序列的變異數為有限</li><li>該時間序列的自我共變異數與 t 無關</li></ul><p>若該時間序列為嚴格定態，則其聯合機率分配不會因為時間點改變而改變。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*8l4t8uf8YDhLntc4ykp9hw.png" /><figcaption>定態時間序列</figcaption></figure><p>2. 非定態時間序列 non-stationary graph</p><p>非定態時間序列是一帶有趨勢之序列，所謂的趨勢是指時間序列資料持續而長期性的移動，而時間序列資料則沿著他的趨勢上下波動。由下圖可知此非定態時間序列有一個向下的趨勢。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*tLrVC6aOyi-HeFKGRK-2Qg.png" /><figcaption>非定態時間序列</figcaption></figure><p>而我們除了使用肉眼去分辨這個時間序列是否為定態，也可以使用廣為人知的 Augmented Dickey-Fuller test (ADF test) 對時間序列進行檢定。</p><p>若虛無假設為 y_t 具單根，對立假設 y_t 為定態，考慮以下迴歸式</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*l-SyLcGTT_kjEFzn.png" /></figure><p>並檢定</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/0*4e7jTunIEe38pCML.png" /></figure><p>以下為使用 python statsmodels 中的 adfuller 套件檢定上面兩圖的序列是否為單根的結果</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*6xTyavlCA3-01ZE9zgenNQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rseSwZVd9z1qkQKUMrHB0A.png" /></figure><p>在 Cointegration 的配對交易策略中，首先我們需要用股票A 與股票B 的報酬建構回歸式，我們會得到兩個參數，第一個是 beta, 也就是股票的購買比例，第二個是 epsilon, 也就是我們用來建構交易策略的價差</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/0*D7pX9OxOs9jQUscU.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*N0c9qKoBmUKtVXLzXvKhAg.png" /></figure><p>以下是用裕民(2606.TW) 以及陽明 (2609.TW) 作為交易對畫出的股價以及其價差的走勢圖</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iaMbcYsiG9urs3wD62U6bw.png" /></figure><p>而這組價差的 adf test value 為 -3.14, pvalue 為 0.0233, 因此為一定態時間序列，Cointegration test value 為 -4.752，代表這兩檔股票的走勢具有共整合關係。</p><p>第三步就是定義交易策略的部分，在傳統的共整合交易策略中，我們常常使用所有價差的 n 倍標準差加上價差的平均來建構所謂的閾值 (threshold)，以這種策略來說，閾值會是一條橫線。第二種則是類似布林通道的概念，使用當期價差加上n倍標準差當作閾值，這樣一來閾值便會是隨著價差而變動的序列。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*jEdj1oj1Azzh9zgUaape_w.png" /></figure><p>以下會使用發散1.5倍標準差、收斂0.5倍標準差當作圖示</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*41l_nq3bZ5uKZNgXDN92sQ.png" /></figure><p>下一期會為大家說明，如何建構基本的共整合配對交易策略，並比較幾種共整合配對交易策略的績效表現。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=523815413dca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[在 LaTeX 文件中嵌入程式碼]]></title>
            <link>https://medium.com/@Abnerteng/%E5%9C%A8-latex-%E6%96%87%E4%BB%B6%E4%B8%AD%E5%B5%8C%E5%85%A5%E7%A8%8B%E5%BC%8F%E7%A2%BC-1fb1e074623b?source=rss-2b2362117b38------2</link>
            <guid isPermaLink="false">https://medium.com/p/1fb1e074623b</guid>
            <category><![CDATA[latex]]></category>
            <category><![CDATA[code]]></category>
            <dc:creator><![CDATA[鄧昱辰]]></dc:creator>
            <pubDate>Sun, 06 Nov 2022 09:15:54 GMT</pubDate>
            <atom:updated>2022-11-06T09:15:54.175Z</atom:updated>
            <content:encoded><![CDATA[<p>嗨大家好久不見，今天要來講的是怎麼優雅地將程式碼放在文件當中。因為小弟我呢最近交的幾份作業都會需要有程式碼以及文字敘述，但是在我看來，好像大部分的同學都是用截圖的方式丟到 word ，美觀程度真的不是很高，所以身為 LaTeX 的瘋狂愛好者，就必須站出來，為大家介紹一下listings 這個牛逼套件。</p><h4>第一步：載入 listing 套件</h4><p>輸入 \usepackage{listings}</p><h4>第二步：設定程式碼的顏色以及版面</h4><p>listings 其實有超級多種東西可以設定，但是因為我比較喜歡簡潔一點的長相，所以我設定的東西其實沒有很多，但也是算非常夠用了。</p><ol><li><em>設定顏色</em></li></ol><p>有關於顏色的問題，因為 LaTeX 內建的顏色不是很好看，所以為了最大程度的美觀，可以自己設定酷酷的顏色。</p><p>在設定顏色之前，先載入兩個套件</p><pre>\usepackage{xcolor}<br>\usepackage{color}</pre><p>接著定義顏色</p><pre>\definecolor{dkgreen}{rgb}{0, 0,6, 0}<br>\definecolor{codegrey}{rgb}{0.5, 0.5, 0.5}<br>\definecolor{codepurple}{rgb}{0.58, 0, 0.82}</pre><p>顏色的設定以及調配使用的是 RGB 三原色的概念，所以大家可以根據小時候美術課的記憶來加色，將紅綠藍三原色的色光以不同比例相加。</p><p>2. <em>設定外觀</em></p><p>在設定外觀時，要先在參數外面包上一個 \lstset 的 function</p><pre>\lstset{</pre><pre>    frame = tb,<br>    language = C++,<br>    aboveskip = 3mm,<br>    belowskip = 3mm,<br>    numbers = left,<br>    numberstyle = \tiny\color{black}<br>    keywordstyle = \color{blue}<br>    commentstyle = \color{dkgreen}<br>    stringstyle = \color{codepurple}<br>    tabsize = 4<br>    basicstyle = {\small\ttfamily}   <br>}</pre><p>參數的部分我就不一一介紹，簡單來說，可以調的有外框樣式、語言、行距、字體、關鍵字及特殊字元顏色、tab鍵的長度等等。</p><p>到目前為止就已經把該設定的東西都設定好啦，特別注意一件事，這些設定的東西都是要在 \begin{document} 之前先設定好的！</p><h4>第三步：在文件中輸入程式碼</h4><p>接著進入 document 裏面，輸入 \begin{lstlisting} \end{lstlisting} ，就可以在 begin 與 end 中間嵌入程式碼了！</p><pre>\begin{lstlisting}<br>#include&lt;iostream&gt;</pre><pre>int main(void)<br>{<br>    std::cout &lt;&lt; &quot;i love LaTeX&quot; &lt;&lt; std::endl;<br>    return 0;<br>}<br>\end{lstlisting}</pre><p>寫完之後會長這樣</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OccB4FPN1KTNJJH7VW81lw.png" /></figure><p>嵌入程式碼的教學就到這邊～希望大家都可以多多使用這個功能讓作業更漂亮！</p><p><em>Source code</em></p><pre>\documentclass[12pt]{<strong>article</strong>}</pre><pre>\usepackage{<strong>listings</strong>}</pre><pre>\usepackage{<strong>listings</strong>}</pre><pre>\usepackage{<strong>xcolor</strong>}</pre><pre>\usepackage{<strong>color</strong>}</pre><pre><strong>\definecolor</strong>{dkgreen}{rgb}{0,0.6,0}</pre><pre><strong>\definecolor</strong>{codegrey}{rgb}{0.5,0.5,0.5}</pre><pre><strong>\definecolor</strong>{codepurple}{rgb}{0.58,0,0.82}</pre><pre><strong>\lstset</strong>{</pre><pre>frame=tb,</pre><pre>language=Python,</pre><pre>aboveskip=3mm,</pre><pre>belowskip=3mm,</pre><pre>showstringspaces=false,</pre><pre>columns=flexible,</pre><pre>basicstyle={<strong>\small\ttfamily</strong>},</pre><pre>numbers=left,</pre><pre>numberstyle=<strong>\tiny\color</strong>{black},</pre><pre>keywordstyle=<strong>\color</strong>{blue},</pre><pre>commentstyle=<strong>\color</strong>{dkgreen},</pre><pre>stringstyle=<strong>\color</strong>{codepurple},</pre><pre>breaklines=true,</pre><pre>breakatwhitespace=true,</pre><pre>tabsize=3</pre><pre>}</pre><pre><strong>\begin</strong>{document}</pre><pre><strong>\begin</strong>{lstlisting}</pre><pre>#include&lt;iostream&gt;<br></pre><pre>int main(void)</pre><pre>{</pre><pre>std::cout &lt;&lt; &quot;I love LaTeX&quot; &lt;&lt; std::endl;</pre><pre>return 0;</pre><pre>}</pre><pre><strong>\end</strong>{lstlisting}</pre><pre><strong>\end</strong>{document}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1fb1e074623b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bollinger Band strategy with python]]></title>
            <link>https://medium.com/@Abnerteng/bollinger-band-strategy-with-python-eb467fdd007a?source=rss-2b2362117b38------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb467fdd007a</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[finance]]></category>
            <category><![CDATA[bollinger-bands]]></category>
            <category><![CDATA[technical-analysis]]></category>
            <dc:creator><![CDATA[鄧昱辰]]></dc:creator>
            <pubDate>Sat, 13 Aug 2022 13:29:03 GMT</pubDate>
            <atom:updated>2022-08-13T13:36:50.392Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>如果已經知道如何使用 yfinance來擷取金融資料，那就可以來撰寫策略並建構回測框架</blockquote><p>首先，依照 yfinance 來擷取金融資料。在建構回測架構時，我們只需要用到 historical data, 也就是 OHLC data + volume.</p><p>回測資訊：以台積電為商品，交易頻率為日 k ，資金為$100，手續費 0.1425%，回測 2021–01–01 到 2022–07–31 的績效</p><pre>import yfinance as yf<br>import numpy as np<br>import pandas as pd<br>from pandas import Series, DataFrame</pre><pre>data = yf.download(&#39;2330.TW&#39;, start = &#39;2021-01-01&#39;, end = &#39;2022-07-31&#39;)<br>data.tail()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*BE-7194MQBF0TW2NfWTLAQ.png" /><figcaption>OHLC data</figcaption></figure><p>畫出價格走勢圖</p><pre>import matplotlib.pyplot as plt</pre><pre>plt.plot(data[&#39;Close&#39;], label = &#39;2330.TW&#39;)<br>plt.ylabel(&#39;Price&#39;)<br>plt.xlabel(&#39;time&#39;)<br>plt.legend()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*SiHzk5rSFvt0Lc8ta5hehw.png" /><figcaption>台積電收盤價走勢圖</figcaption></figure><h3>建構交易策略</h3><h4>Bollinger Band 參數設定及計算方法</h4><p>Bollinger Band 分為 Upper Bound, Lower Bound and 20SMA.</p><p>Upper Bound 的計算方式為: 20SMA + 2std, std 為價格的標準差</p><p>Lower Bound 的計算方式為: 20SMA -2std</p><p>而 Upper Bound 可以視作股價的壓力線，Lower Bound 則可以稱作股價的支撐線</p><blockquote>SMA 的 length 以及標準差的倍數皆為可調，可以透過最佳化來找出讓績效最好看的參數</blockquote><h4>Bollinger Band 交易邏輯</h4><p>先了解一下布林通道長什麼樣子</p><pre>plt.figure(figsize <em>=</em> (12, 8))</pre><pre>plt.plot(data[&#39;center&#39;], label <em>=</em> &#39;center&#39;, linestyle <em>=</em> &#39;--&#39;, color <em>=</em> &#39;gray&#39;)<br>plt.plot(BB[&#39;BBU&#39;], label <em>=</em> &#39;upper&#39;, color <em>=</em> &#39;blue&#39;)<br>plt.plot(BB[&#39;BBL&#39;], label <em>=</em> &#39;lower&#39;, color <em>=</em> &#39;blue&#39;)<br>plt.plot(data[&#39;Close&#39;], label <em>=</em> &#39;price&#39;, color <em>=</em> &#39;red&#39;)</pre><pre>plt.xlabel(&#39;time&#39;)<br>plt.ylabel(&#39;price&#39;)<br>plt.legend()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*g7WeXoGYl4rO-z-7mPbhuA.png" /><figcaption>布林通道</figcaption></figure><p>以一個2倍標準差的布林通道來說，95%的價格會落在此區間內，我們又可以從上述得知 Upper Bound 與 Lower Bound 分別是壓力與支撐線，股價若觸碰到這兩條線大概率會產生反彈。交易策略如下：</p><ol><li>股價由下往上穿過支撐線則買入或平倉</li><li>股價由上往下穿過壓力線則賣出或平倉</li></ol><p>撰寫交易策略最重要的一點就是要設定買進、放空以及未持倉的 signal，我將買入設為 1, 賣出設為 -1, 未持倉設為 0</p><p>平倉後要計算每一次買賣的報酬，而且要記得涵蓋手續費</p><pre>fund = 100 # 初始金額<br>money = 100 # 每次都 all in<br>fee = 0.001425 # 手續費 0.1425%</pre><pre>signal = 0<br>buy = []<br>short = []<br>sell = []<br>cover = []<br>profit_list = [0]<br>profit_with_fee_list = [0]</pre><pre>for i in range(len(data)):</pre><pre>    if i == len(data)-1:<br>        break</pre><pre>    if signal == 0:<br>        profit_list.append(0)<br>        profit_with_fee_list.append(0)<br>        <br>        if data[&#39;Close&#39;][i-1] &lt; BB[&#39;BBL&#39;][i-1] and data[&#39;Close&#39;][i] &gt; BB[&#39;BBL&#39;][i]:<br>            size = money / data[&#39;Open&#39;][i+1]<br>            signal = 1<br>            t = i+1<br>            buy.append(t)<br>        elif data[&#39;Close&#39;][i-1] &gt; BB[&#39;BBU&#39;][i-1] and data[&#39;Close&#39;][i] &lt; BB[&#39;BBU&#39;][i]:<br>            size <strong>=</strong> money <strong>/</strong> data[&#39;Open&#39;][i<strong>+</strong>1]<br>            signal <strong>=</strong> -1<br>            t <strong>=</strong> i<strong>+</strong>1<br>            short<strong>.</strong>append(t)<br>        <br>    elif signal <strong>==</strong> 1:<br>        profit <strong>=</strong> size <strong>*</strong> (data[&#39;Open&#39;][i<strong>+</strong>1] <strong>-</strong> data[&#39;Open&#39;][i])<br>        profit_list<strong>.</strong>append(profit)<br>            <br>        if data[&#39;Close&#39;][i-1] &gt; BB[&#39;BBU&#39;][i-1] and data[&#39;Close&#39;][i] &lt; BB[&#39;BBU&#39;][i] or i <strong>==</strong> len(data)<strong>-</strong>2:<br>            profit_with_fee <strong>=</strong> profit<strong>-</strong>money<strong>*</strong>fee<strong>-</strong>(money+profit)<strong>*</strong>fee<br>            profit_with_fee_list<strong>.</strong>append(profit_with_fee)<br>            sell<strong>.</strong>append(i<strong>+</strong>1)<br>            signal = 0<br>        else:<br>            profit_with_fee <strong>=</strong> profit<br>            profit_with_fee_list<strong>.</strong>append(profit_with_fee)<br>            <br>    elif signal <strong>==</strong> -1: <br>        profit <strong>=</strong> size <strong>*</strong> (data[&#39;Open&#39;][i] <strong>-</strong> data[&#39;Open&#39;][i<strong>+</strong>1])<br>        profit_list<strong>.</strong>append(profit)<br>        <br>        if data[&#39;Close&#39;][i-1] &lt; BB[&#39;BBL&#39;][i-1] and data[&#39;Close&#39;][i] &gt; BB[&#39;BBL&#39;][i] or i <strong>==</strong> len(data)<strong>-</strong>2:<br>            gain <strong>=</strong> size <strong>*</strong> (data[&#39;Open&#39;][i] <strong>-</strong> data[&#39;Open&#39;][i<strong>+</strong>1])<br>            profit_with_fee <strong>=</strong> profit <strong>-</strong> money<strong>*</strong>fee<strong>-</strong>(money+profit)<strong>*</strong>fee<br>            profit_with_fee_list<strong>.</strong>append(profit_with_fee)<br>            cover<strong>.</strong>append(i<strong>+</strong>1)<br>            signal = 0<br>        else:<br>            profit_with_fee <strong>=</strong> profit<br>            profit_with_fee_list<strong>.</strong>append(profit_with_fee)<br>            <br>equity <strong>=</strong> pd<strong>.</strong>DataFrame({&#39;profit&#39;:np<strong>.</strong>cumsum(profit_list), &#39;profitwithfee&#39;:np<strong>.</strong>cumsum(profit_with_fee_list)}, index<strong>=</strong>data<strong>.</strong>index)<br>print(equity)<br>equity<strong>.</strong>plot(grid<strong>=True</strong>, figsize<strong>=</strong>(12, 8));</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*1LzJURabHmePQ9NSKb3qaQ.png" /><figcaption>equity curve of Bollinger Band strategy</figcaption></figure><p>由上圖可知，一年多下來，只有20%左右的報酬率，顯然不是太好，因此我推薦幾種改善方式</p><ol><li>配合其他指標一起使用（MACD, RSI 等等）</li><li>使用布林通道的衍伸指標（BBandWidth, %b）</li><li>使用濾網</li><li>設定停利停損點</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb467fdd007a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Collecting financial data from yfinance package]]></title>
            <link>https://medium.com/@Abnerteng/collecting-financial-data-from-yfinance-package-308b105eb974?source=rss-2b2362117b38------2</link>
            <guid isPermaLink="false">https://medium.com/p/308b105eb974</guid>
            <category><![CDATA[finance]]></category>
            <category><![CDATA[stocks]]></category>
            <category><![CDATA[yfinance]]></category>
            <category><![CDATA[mplfinance]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[鄧昱辰]]></dc:creator>
            <pubDate>Thu, 04 Aug 2022 15:24:17 GMT</pubDate>
            <atom:updated>2022-08-04T15:25:57.671Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>第一次寫 python 的文章，有點怕自己寫的不好，反正大家就加減看當作參考，如果有不對的地方歡迎糾正。</blockquote><p>今天要講的是如何運用 yfinance這個套件來取得股價資料，他會叫做 yfinance正是因為他是從 yahoo finance 這個網站中取得這些資料的。當然 yfinance能拿到的絕不單單只有股價的歷史資料而已，只是我常用也比較熟的只有這個，所以就不班門弄斧ㄌ。</p><p>要使用 yfinance這個套件，我們必須要先下載</p><pre>pip3 install yfinance</pre><p>如果你是 python 2 的版本，就用</p><pre>pip install yfinance</pre><p>下載好後就可以在 python 的 IDLE 上 import 這個套件</p><pre>import yfinance as yf</pre><p>接下來要進入本篇重點，取得股價歷史資料的部份。</p><p>從 yfinance的 user manual 可以知道，要取得歷史資料可以使用 yf.download這個指令。</p><pre>yf.download(&#39;AAPL&#39;, start = &#39;2020-01-01&#39;, end = &#39;2022-08-01&#39;)</pre><p>這樣就可以獲得從 2020–01–01 到 2022–08–01 AAPL 這檔股票的 OHLC data</p><blockquote>OHLC 就是 Open, High, Low, Close</blockquote><p>我們也可以用 yf.Ticker 這個指令來獲得歷史資料，雖然沒有像 yf.download 這麼方便，但他可以用更簡單的方式拿到不同種類的資料</p><pre>AAPL = yf.Ticker(&#39;AAPL&#39;)<br>history_data = AAPL.history(period = &#39;max&#39;) ## 取得歷史資料<br>cash_flow = AAPL.cashflow ## 取得現金流量資料</pre><p>還有很多很多種資料可以拿，這個就不細講ㄌ，大家可以自行上網欣賞</p><p>如果不想要美股資料，想要台股資料的話，可以去 yahoo finance 的網站上看台股的股票代號</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2h3tP_PZKmb9h3Jqd6Yrjg.png" /><figcaption>yahoo finance</figcaption></figure><p>可以知道說台積電的股票代號叫做 2330.TW, 知道後就可以直接讀進來</p><pre>import yfinance as yf<br>TSMC = yf.download(&#39;2330.TW&#39;, start = &#39;2022-01-01&#39;, end = &#39;2022-08-01&#39;)<br>TSMC.tail(5)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/433/1*eqRbhk77HScBXOiHESexqQ.png" /><figcaption>OHLC data of 2330.TW</figcaption></figure><p>之後就可以對股票的收盤價做分析，比如說可以畫個 k棒以及 長短 SMA</p><p>先將短期均線以及長期均線畫出來</p><pre>TSMC[&#39;5SMA&#39;] <em>=</em> TSMC[&#39;Close&#39;].rolling(window <em>=</em> 5, center <em>=</em> False).mean()<br>TSMC[&#39;34SMA&#39;] <em>=</em> TSMC[&#39;Close&#39;].rolling(window <em>=</em> 34, center <em>=</em> False).mean()</pre><p>接著開始畫圖，使用 mplfinance 當作繪圖工具</p><pre><em>import</em> mplfinance <em>as</em> mpf<br>candle_data <em>=</em> TSMC[[&#39;Open&#39;, &#39;High&#39;, &#39;Low&#39;, &#39;Close&#39;, &#39;Volume&#39;]]<br>LSMA <em>=</em> [ mpf.make_addplot(TSMC[&#39;5SMA&#39;], color <em>=</em> &#39;blue&#39;),mpf.make_addplot(TSMC[&#39;34SMA&#39;], color <em>=</em> &#39;orange&#39;) ]<br>mpf.plot(data <em>=</em> candle_data, type <em>=</em> &#39;candle&#39;, style <em>=</em> &#39;binance&#39;, addplot <em>=</em> LSMA, figratio <em>=</em> (18, 10), title <em>=</em> &#39;TSMC&#39;, volume <em>=</em> True)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*6fXLVrjTehybadm7rKTviA.png" /><figcaption>2330.TW 技術分析圖</figcaption></figure><p>關於 yfinance 以及 mplfinance 的 user manual, 我會貼在下面讓大家參考</p><p>yfinance</p><p><a href="https://pypi.org/project/yfinance/">yfinance</a></p><p>mplfinance</p><p><a href="https://github.com/matplotlib/mplfinance">GitHub - matplotlib/mplfinance: Financial Markets Data Visualization using Matplotlib</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=308b105eb974" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LaTeX tutorial — math mode]]></title>
            <link>https://medium.com/%E8%BB%9F%E9%AB%94%E8%88%87%E9%87%91%E8%9E%8D%E7%9A%84%E5%B0%8F%E5%B0%8F%E7%99%BD%E6%95%85%E4%BA%8B/latex-tutorial-math-mode-db874fdcaca1?source=rss-2b2362117b38------2</link>
            <guid isPermaLink="false">https://medium.com/p/db874fdcaca1</guid>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[latex]]></category>
            <dc:creator><![CDATA[鄧昱辰]]></dc:creator>
            <pubDate>Thu, 16 Jun 2022 13:12:48 GMT</pubDate>
            <atom:updated>2022-06-16T13:12:48.996Z</atom:updated>
            <content:encoded><![CDATA[<h3>LaTeX tutorial — math mode</h3><blockquote>其實這篇原本是要在 \graphicx and \geometry後面才寫的，但有鑒於不少朋友最近有報需要用到數學式或插入程式碼的功能，因此先介紹這兩個。</blockquote><blockquote>因為我很懶我不想寫太多，我的介紹內容主要都是針對最常用也最基本的東西為主，所以想了解詳細或更深入的內容可以用 overleaf 查詢。</blockquote><h3>How to start typing math equation?</h3><p>Mathmode 是在 LaTeX 上輸入數學或拉丁符號所使用的功能，這個功能算是 LaTeX 的重頭戲，大家可能會想說，我前面介紹這麼多，我怎麼覺得用 word / pages 還比較方便？</p><p>是，前面介紹的確實也可以很簡單的用 word / pages 處理，頂多就是沒這麼好看而已，但接下來的內容，大家將會看到為什麼 LaTeX 這麼受大家喜愛的原因。</p><p>首先我們要介紹如何插入數學式</p><ul><li>$...$</li><li>\[...\]</li><li>\begin{equation}...\end{equation} 或 \begin{equation*}...\end{equation*}</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GHpjMj3FBqthDzYMFP2A7Q.png" /><figcaption>開始使用 math mode</figcaption></figure><p>大家應該很明顯的可以看到差別</p><ol><li>使用 $…$時，數學式會跟你的字在同一行，其他則是獨立一行。</li><li>equation 跟 equation*的差別只在於有沒有編號而已。</li></ol><h3>How to type basic math equations?</h3><p>大家現在都會使用上述幾種方法打數學式ㄌ，但一定有人（可能很少啦）不知道要怎麼打次方、小符號、分數等等的比較特別的樣式，我馬上來介紹，先上圖</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yo47vxFfKDFUaka5pSc5fw.png" /><figcaption>基本數學符號</figcaption></figure><ul><li>用 _來打右下角的小標</li><li>用 ^打次方</li><li>用 \frac{}{}打分數，做邊放分子，右邊放分母</li><li>用 \sqrt{}打根號</li><li>用 \拉丁符號拼音呈現那個符號</li><li>若要空格，用 \加一個空白鍵，若要大空格，用 \quad\</li><li>乘法用 \times</li></ul><h3>How to type equations like difference, integrals etc.</h3><p>大家現在一定都會打基本的數學式了，接下來要介紹積分、極限、加總怎麼打</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N94Qos2gUj-NSYroGHOylw.png" /><figcaption>微積分啦</figcaption></figure><ul><li>積分用 \int_{下界}^{上界}</li><li>極限用 \limit{下面那行}</li><li>加總用 \sum_{下界}^{上界}</li><li>箭頭用 \to</li><li>無限用 \infty</li><li>機率近似用 \stackrel{p}{\to}大括號內可以換成任何東西， \stackrel主要是要呈現上標的概念</li></ul><h3>Matrix and Simultaneous equations</h3><p>因為數學式可以講的東西實在太多太多太多了，所以就用矩陣還有聯立方程式來收尾，大家如果以後要使用 LaTeX 來寫數學作業的話，需要用到的功能可能不只是上述這些，所以還是建議大家在熟悉基本的東西時可以多上網查。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XfObGRIWTEN13jKWJudplA.png" /><figcaption>矩陣與聯立方程</figcaption></figure><ul><li>矩陣用 \begin{bmatrix}...\end{matrix}</li><li>聯立方程式用 \begin{cases}...\end{cases}</li></ul><blockquote>特別注意，使用下面這兩種都必須在數學式環境中使用，所以要先加 \begin{equation}...\end{equation} 或 \[...\]</blockquote><p>今天先到這裡，其實這樣就可以很有效的處理大學部的數學作業了，至於有些我覺得比較沒那麼常用的大就再參考網路，附上連結</p><p><a href="https://www.overleaf.com/learn/latex/Mathematical_expressions">Mathematical expressions</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db874fdcaca1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/%E8%BB%9F%E9%AB%94%E8%88%87%E9%87%91%E8%9E%8D%E7%9A%84%E5%B0%8F%E5%B0%8F%E7%99%BD%E6%95%85%E4%BA%8B/latex-tutorial-math-mode-db874fdcaca1">LaTeX tutorial — math mode</a> was originally published in <a href="https://medium.com/%E8%BB%9F%E9%AB%94%E8%88%87%E9%87%91%E8%9E%8D%E7%9A%84%E5%B0%8F%E5%B0%8F%E7%99%BD%E6%95%85%E4%BA%8B">軟體與金融的小小白故事</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LaTeX tutorial-lists]]></title>
            <link>https://medium.com/%E8%BB%9F%E9%AB%94%E8%88%87%E9%87%91%E8%9E%8D%E7%9A%84%E5%B0%8F%E5%B0%8F%E7%99%BD%E6%95%85%E4%BA%8B/latex-tutorial-lists-1a457b64c28c?source=rss-2b2362117b38------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a457b64c28c</guid>
            <category><![CDATA[latex]]></category>
            <category><![CDATA[notes]]></category>
            <category><![CDATA[lists]]></category>
            <dc:creator><![CDATA[鄧昱辰]]></dc:creator>
            <pubDate>Fri, 10 Jun 2022 17:57:26 GMT</pubDate>
            <atom:updated>2022-06-10T18:54:38.123Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>這次會專注在介紹 LaTeX 其中一個基本的功能 : List 。List 是專門用於條列式的文章結構，最常見的應用範圍即是筆記。</blockquote><h3>Lists is LaTeX</h3><p>常用的 list 三種，這邊先舉例性質比較相似的兩種： itemize 以及 enumerate</p><ol><li>itemize</li></ol><pre>\begin{itemize}<br>  \item item 1<br>  \item item 2<br>  \item item 3<br>\end{itemize}</pre><p>2. enumerate</p><pre>\begin{enumerate}<br>  \item item 1<br>  \item item 2<br>  \item item 3<br>\end{enumerate}</pre><p>我們可以看一下差別</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8gKb8Wqq_5K5ncXvsyEXsw.png" /><figcaption>itemize 與 enumerate 之差別</figcaption></figure><ul><li>我們可以知道，使用 itemize 顯示的會是點，使用 enumerate 顯示的會是數字</li></ul><p>再來，要介紹第三種 list</p><p>3. description</p><p>description 的特點在於標籤可以由使用者自行輸入</p><pre>\begin{description}<br>  \item This is an entry without label<br>  \item[One-line description] This is an one-line description. \end{description}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FGeitX8FUvLE00RDpkM7QA.png" /><figcaption>description 的用法</figcaption></figure><h3>Changing labels of individual entries</h3><p>如果我們需要的不只是點或數字的符號時，可以使用 \item[label text] 來更換符號</p><pre>\begin{itemize}<br>  \item[!] A point to exclaim something<br>  \item[$\blacksquare$] Make the point square<br>  \item[NOTE] This is a NOTE label<br>  \item[] This is a blank label<br>\end{itemize}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lmVudq9E69suupwrOn4f_g.png" /><figcaption>不同形式的標籤</figcaption></figure><blockquote>值得注意的是，當我們選擇使用 $\blacksquare$ 時，因為它屬於數學符號的一部分，所以我們必須增加使用數學符號的三個套件</blockquote><pre>\usepackage{amsmath}<br>\usepackage{MnSymbol}<br>\usepackage{wasysym}</pre><h3>Nested list</h3><p>Nested 指的是巢狀結構，意即可以在 list 中再放入一個甚至多個 lists，形成一份篇幅較大的筆記</p><pre>\begin{enumerate}<br>    \item number item 1<br>    \begin{itemize}<br>      \item bullet item 1<br>      \item bullet item 2<br>      \begin{description}<br>      \item[Note:] Note<br>      \item[Caveat!] Warning<br>      \end{description}<br>    \end{itemize}<br>    \item number item 2<br>\end{enumerate}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y57a-4PLIeXZNup7xqMcmQ.png" /><figcaption>不同種類堆疊</figcaption></figure><p>另外我們也可以讓同種 lists 做堆疊，這樣會顯現出不同的 label style</p><pre>%% nest with \enumerate<br>\begin{enumerate}<br>    \item First level item<br>    \item First level item<br>    \begin{enumerate}<br>      \item Second level item<br>      \item Second level item<br>      \begin{enumerate}<br>        \item Third level item<br>        \item Third level item<br>        \begin{enumerate}<br>          \item Fourth level item<br>          \item Fourth level item<br>        \end{enumerate}<br>      \end{enumerate}<br>    \end{enumerate}<br>  \end{enumerate}<br>%% nest with \itemize<br>\begin{itemize}<br>    \item First level item<br>    \item First level item<br>    \begin{itemize}<br>      \item Second level item<br>      \item Second level item<br>      \begin{itemize} <br>        \item Third level item<br>        \item Third level item<br>        \begin{itemize}<br>          \item Fourth level item<br>          \item Fourth level item<br>        \end{itemize}<br>      \end{itemize}<br>    \end{itemize}<br> \end{itemize}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m_-He_UfVHWfBs4iNbw7iQ.png" /><figcaption>同種類堆疊</figcaption></figure><p>list 的部分就先介紹到這邊，如果有興趣往下延伸的話可以參考 Overleaf 中的 Customizing lists，裡面有介紹許多種自定義 label style 的方法</p><p><a href="https://www.overleaf.com/learn/latex/Lists">Lists</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a457b64c28c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/%E8%BB%9F%E9%AB%94%E8%88%87%E9%87%91%E8%9E%8D%E7%9A%84%E5%B0%8F%E5%B0%8F%E7%99%BD%E6%95%85%E4%BA%8B/latex-tutorial-lists-1a457b64c28c">LaTeX tutorial-lists</a> was originally published in <a href="https://medium.com/%E8%BB%9F%E9%AB%94%E8%88%87%E9%87%91%E8%9E%8D%E7%9A%84%E5%B0%8F%E5%B0%8F%E7%99%BD%E6%95%85%E4%BA%8B">軟體與金融的小小白故事</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LaTeX tutorial -basic function]]></title>
            <link>https://medium.com/%E8%BB%9F%E9%AB%94%E8%88%87%E9%87%91%E8%9E%8D%E7%9A%84%E5%B0%8F%E5%B0%8F%E7%99%BD%E6%95%85%E4%BA%8B/latex-tutorial-basic-function-239bcd0ed48e?source=rss-2b2362117b38------2</link>
            <guid isPermaLink="false">https://medium.com/p/239bcd0ed48e</guid>
            <category><![CDATA[documentary]]></category>
            <category><![CDATA[latex]]></category>
            <dc:creator><![CDATA[鄧昱辰]]></dc:creator>
            <pubDate>Tue, 07 Jun 2022 05:53:02 GMT</pubDate>
            <atom:updated>2022-06-07T05:53:02.069Z</atom:updated>
            <content:encoded><![CDATA[<p>這次要來介紹 LaTeX 最基礎的排版功能，包含設定字體大小、字體樣式（粗體、斜體字、底線）、文件結構等</p><h4>Start Using LaTeX</h4><blockquote>所有的程式碼都是可以在 VScode 上執行 （因為我用 VScode）</blockquote><p>LaTeX 大致上的排版會長這樣</p><pre>\documentclass[12pt]{article} <br>\usepackage{} <br>\usepackage{} <br>\begin{document} <br>    You can type here. <br>\end{document}</pre><ul><li>[] 中可以選擇字體大小紙張大小，例如 [10pt, letterpaper]</li><li>{}中可以選擇文件類別，例如 {article} 、{report}、或專門製作履歷的 {moderncv}</li><li>\usepackage{} 是用來載入套件，之後會說到</li><li>文章開始與結束需打 \begin{document}與 \end{document}</li></ul><p>以下為輸出範例</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2ssNGYQVhtFiNbgaJhqt0w.png" /></figure><p>附上 overleaf 的更詳細解說</p><p><a href="https://www.overleaf.com/learn/latex/Creating_a_document_in_LaTeX">Creating a document in LaTeX</a></p><h4>Settings of words</h4><p>\textbf 是粗體, \underline是底線, \textit或 \emph都是斜體字</p><pre>\textbf{bold text}\\ <br>\underline{you can type text with an underline}\\ <br>\textit{it&#39;s for italicized text}, \emph{have the same effect}</pre><ul><li>使用 \\或 \newline來換行</li></ul><p>我們可以用 {}來製造雙層的效果</p><pre>\textbf{\textit{italicized bold text}}</pre><p>以下為輸出範例</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ADKz49jIBvklCn8uG2JNlQ.png" /></figure><h4>Document Structure</h4><p>由大到小分別是</p><pre>\part{part}<br>  \chapter{chapter}<br>   \section{section}<br>    \subsection{subsection}<br>     \subsubsection{subsubsection}<br>      \paragraph{paragraph}<br>       \subparagraph{subparagraph}</pre><ul><li>特別注意， \chapter 僅適用於 report 或 book 樣式的文件。</li><li>以 section 為例，可以選擇使用 \section{}或 \section*{}。 * 的用途是為章節加入數字，可以看以下範例</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GhqF85DmvMlWfbxik4LJ9Q.png" /></figure><p>今天先介紹到這篇，下一篇的主題為 lists in LaTeX，用 LaTeX 做條列式筆記</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=239bcd0ed48e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/%E8%BB%9F%E9%AB%94%E8%88%87%E9%87%91%E8%9E%8D%E7%9A%84%E5%B0%8F%E5%B0%8F%E7%99%BD%E6%95%85%E4%BA%8B/latex-tutorial-basic-function-239bcd0ed48e">LaTeX tutorial -basic function</a> was originally published in <a href="https://medium.com/%E8%BB%9F%E9%AB%94%E8%88%87%E9%87%91%E8%9E%8D%E7%9A%84%E5%B0%8F%E5%B0%8F%E7%99%BD%E6%95%85%E4%BA%8B">軟體與金融的小小白故事</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LaTeX tutorial]]></title>
            <link>https://medium.com/@Abnerteng/latex-tutorial-cd9d549c3514?source=rss-2b2362117b38------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd9d549c3514</guid>
            <category><![CDATA[latex]]></category>
            <category><![CDATA[document]]></category>
            <dc:creator><![CDATA[鄧昱辰]]></dc:creator>
            <pubDate>Sun, 05 Jun 2022 14:34:49 GMT</pubDate>
            <atom:updated>2022-06-07T06:03:39.382Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>在政大金融面試那篇文章中有提到自己的備審資料是用 TeX 族群中的 XeTeX / XeLaTeX 編寫的，而會想寫這篇文章的原因是因為家妹最近在上台大經濟系朱玉琦老師的總體經濟學時有一份報告需要使用 LaTeX 來完成，有鑒於許多大學生對此不是非常熟悉，因此寫下這篇文章。</blockquote><h3>What is LaTeX ?</h3><p>LaTeX 是一種文件排版系統，可以用來編輯要出版的研究論文、書籍等文件，甚至也可以製作投影片。</p><p>LaTeX 跟其他文書軟體最大的不同在於，LaTeX 是屬於後端排版的系統，使用類似編寫程式語言的方法來完成文件，這也成為 LaTeX 較難上手的原因。</p><h3>Why do we use LaTeX ?</h3><blockquote>既然 LaTeX 上手困難，那為什麼還要學 LaTeX ?</blockquote><ol><li>LaTeX 編輯的文件通常都比使用 Microsoft Word 編輯的文件還要更有美感，特別是在數學、資工、電機、物理、經濟等使用到較多數學的文件或論文，使用 LaTeX 打出來的數學式就是特別香、特別好看。</li><li>LaTeX 在各種平台上都可以使用，完全免費且支援各大作業系統，不像 Microsoft Office 專門坑錢。</li><li>LaTeX 擁有各式各樣的 package，提供各種實用、酷炫的功能。</li><li>LaTeX 不需要手動排版，一切交給電腦及程式碼，再也不用體會使用 word 時，一直瘋狂按 tab 鍵但文字卻不為所動的感覺。</li></ol><h3>Problems of LaTeX</h3><blockquote>世界上沒有任何事情是完美的，LaTeX 亦然</blockquote><ol><li>LaTeX 上手難度高，初學者需要克服以編寫程式碼來打文件的心魔，但學習曲線陡峭，自己試過一次就會知道這種感覺。</li><li>製作小篇幅，甚至是單頁的報告或心得，使用 LaTeX 顯得大費周章。的確，LaTeX 較適合撰寫大篇幅文章，例如學位論文。</li></ol><blockquote>這邊就懶得介紹 LaTeX 的下載方式，網路上打 LaTeX Download 基本上就 ok</blockquote><h3>Application / Web server</h3><p>Overleaf 是最推薦新手使用的 LaTeX 線上編輯器，裡面有各式各樣的模板可以使用，版面清楚簡潔。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YeKVo07u9mGBltQE.png" /></figure><p>overleaf 介面</p><p>2. Visual Studio Code</p><p>VScode 是我用來編寫 LaTeX 文件所使用的軟體，會使用 VScode 的原因在於我可以在上面同時寫python 以及 LaTeX，超方便的啦。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mv3jjBbcMlXBnoBF.png" /></figure><p>從 extension 尋找 LaTeX</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GLzTjU6_Fpz1xNu_.png" /></figure><p>新增檔案，語言選擇 LaTeX</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ITsTP0mKfjmyBK7G.png" /></figure><p>VScode 介面</p><p>這篇先到這裡，LaTeX 的模板介紹、使用及基本撰寫方法會在之後介紹。</p><p><em>Originally published at </em><a href="https://medium.com/@Abnerteng/latex-tutorial-146d35511d57"><em>https://medium.com</em></a><em> on June 5, 2022.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd9d549c3514" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>