<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>策略優化 &#8211; FinLab</title>
	<atom:link href="https://www.finlab.tw/tag/%E7%AD%96%E7%95%A5%E5%84%AA%E5%8C%96/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.finlab.tw</link>
	<description>深入淺出的量化投資，讓你在在茫茫股海中，找到專屬於自己的投資方法</description>
	<lastBuildDate>Thu, 20 Jul 2023 15:16:36 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.0.9</generator>

<image>
	<url>https://www.finlab.tw/wp-content/uploads/2020/07/favicon.png</url>
	<title>策略優化 &#8211; FinLab</title>
	<link>https://www.finlab.tw</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">179699571</site>	<item>
		<title>產業面選股策略｜同業本益比比較法</title>
		<link>https://www.finlab.tw/industry_pe_strategy/</link>
					<comments>https://www.finlab.tw/industry_pe_strategy/#respond</comments>
		
		<dc:creator><![CDATA[Ben]]></dc:creator>
		<pubDate>Wed, 02 Nov 2022 02:23:38 +0000</pubDate>
				<category><![CDATA[FinLab 量化平台]]></category>
		<category><![CDATA[VIP文章]]></category>
		<category><![CDATA[選股策略]]></category>
		<category><![CDATA[VIP限定]]></category>
		<category><![CDATA[本益比]]></category>
		<category><![CDATA[產業面]]></category>
		<category><![CDATA[策略優化]]></category>
		<guid isPermaLink="false">https://www.finlab.tw/?p=4755</guid>

					<description><![CDATA[「希望加入同業本益比及股價淨值比資料，這將對台灣價值股的相關策略研發十分有幫助。 有此資料便可排除產業帶來的本益比及淨值比差異。」
「我想寫成挑出每個低於個別產業平均本益比之個股所組成的投資組合。」
這是 FinLab 高手用戶在 Discord 許願池 寫下的願望，許願池的用意在有些特殊功能在外面的產品找不到，或是程式比較難撰寫，只要你的想法具有研究價值與具體描述，那願望成真不會是夢。
產業面選股加上個股因子的進階策略怎麼開發？馬上來實現～]]></description>
										<content:encoded><![CDATA[
<p class="has-medium-font-size">「希望加入同業本益比及股價淨值比資料，這將對台灣價值股的相關策略研發十分有幫助。 有此資料便可排除產業帶來的本益比及淨值比差異。」<br>「我想寫成挑出每個低於個別產業平均本益比之個股所組成的投資組合。」<br>這是 FinLab 高手用戶在 <a href="https://discord.com/channels/897386624067969034/1036947070155763753" target="_blank" rel="noopener">Discord 許願池</a> 寫下的願望，許願池的用意在有些特殊功能在外面的產品找不到，或是程式比較難撰寫，只要你的想法具有研究價值與具體描述，那願望成真不會是夢。<br>產業面選股加上個股因子的進階策略怎麼開發？馬上來實現～</p>



<h2>產業資料</h2>



<p class="has-medium-font-size">FinLab 的產業主題資料來源主要取自「<a href="https://ic.tpex.org.tw/" target="_blank" rel="noopener">產業價值鍊資訊平台</a>」。從 <a href="https://ai.finlab.tw/database#security_industry_themes" target="_blank" rel="noopener">FinLab資料庫</a> 只要一行程式碼就能下載全部的細產業資訊。要注意的是此份資料僅限 <a href="https://ai.finlab.tw/pricing" target="_blank" rel="noopener">VIP</a> 使用。<br>FinLab 其實過去已做過類似分析內容：「<a href="https://www.finlab.tw/finlab-tw-stock-pe-strategy/">本益比選股策略 | 產業因子分析</a>」，不過當時是以證交所一般版塊分類，沒有像 <a href="https://ic.tpex.org.tw/" target="_blank" rel="noopener">產業價值鍊資訊平台</a> 的分類那麼細緻。</p>



<figure class="wp-block-image size-large"><img width="1024" height="404" src="https://www.finlab.tw/wp-content/uploads/2022/11/截圖-2022-11-02-上午7.30.52-1024x404.png" alt="截圖 2022 11 02 上午7.30.52" class="wp-image-4756" srcset="https://www.finlab.tw/wp-content/uploads/2022/11/截圖-2022-11-02-上午7.30.52-1024x404.png 1024w, https://www.finlab.tw/wp-content/uploads/2022/11/截圖-2022-11-02-上午7.30.52-300x118.png 300w, https://www.finlab.tw/wp-content/uploads/2022/11/截圖-2022-11-02-上午7.30.52-768x303.png 768w, https://www.finlab.tw/wp-content/uploads/2022/11/截圖-2022-11-02-上午7.30.52-1536x607.png 1536w, https://www.finlab.tw/wp-content/uploads/2022/11/截圖-2022-11-02-上午7.30.52-2048x809.png 2048w" sizes="(max-width: 1024px) 100vw, 1024px" title="產業面選股策略｜同業本益比比較法 1"><figcaption>資料庫</figcaption></figure>



<p class="has-medium-font-size">每家公司所屬產業的資訊放在 catergory 內。例如台泥的產業序列裡有主產業的水泥，也有細產業「水泥:水泥成品」(格式為「主產業:細產業」)。</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="810" src="https://www.finlab.tw/wp-content/uploads/2022/11/截圖-2022-11-02-上午7.35.04-1024x810.png" alt="截圖 2022 11 02 上午7.35.04" class="wp-image-4757" srcset="https://www.finlab.tw/wp-content/uploads/2022/11/截圖-2022-11-02-上午7.35.04-1024x810.png 1024w, https://www.finlab.tw/wp-content/uploads/2022/11/截圖-2022-11-02-上午7.35.04-300x237.png 300w, https://www.finlab.tw/wp-content/uploads/2022/11/截圖-2022-11-02-上午7.35.04-768x608.png 768w, https://www.finlab.tw/wp-content/uploads/2022/11/截圖-2022-11-02-上午7.35.04-1536x1216.png 1536w, https://www.finlab.tw/wp-content/uploads/2022/11/截圖-2022-11-02-上午7.35.04.png 1716w" sizes="(max-width: 1024px) 100vw, 1024px" title="產業面選股策略｜同業本益比比較法 2"></figure>



<h2>簡單回測範例</h2>



<p class="has-medium-font-size">如何把「我想寫成挑出每個低於個別產業平均本益比之個股所組成的投資組合。」這個目標變簡單？許多新手覺得程式開發太難的原因是目標複雜，我們可以先將大目標切成幾個小目標。例如先不要想做出每一個產業的投組，先從一個產業開始做，當一個產業測試完沒問題，再來思考重複執行與合併的問題。下面的程式範例以水泥產業為例子進行回測，程式並不難。</p>



<pre class="wp-block-code"><code lang="python" class="language-python">from finlab import data
from finlab.backtest import sim

# 取出產業題材
themes = data.get('security_industry_themes')

# 選出產業包含「水泥」公司
ind = themes[themes['category'].str.contains('水泥')]
pe = data.get('price_earning_ratio:本益比')
ind_pe = pe[list(ind['stock_id'].dropna())]

# 計算每日產業本益比中位數
ind_pe_med = ind_pe.median(axis=1)

# 選出本益比小於同業本益比中位數且本益比小於25的公司
position = (ind_pe &lt; ind_pe_med) &amp; (ind_pe &lt; 25)

# 回測
report = sim(position, upload=False)
report.display()</code></pre>



<figure class="wp-block-image size-full"><img loading="lazy" width="800" height="600" src="https://www.finlab.tw/wp-content/uploads/2022/11/newplot-2.png" alt="newplot 2" class="wp-image-4758" srcset="https://www.finlab.tw/wp-content/uploads/2022/11/newplot-2.png 800w, https://www.finlab.tw/wp-content/uploads/2022/11/newplot-2-300x225.png 300w, https://www.finlab.tw/wp-content/uploads/2022/11/newplot-2-768x576.png 768w" sizes="(max-width: 800px) 100vw, 800px" title="產業面選股策略｜同業本益比比較法 3"></figure>



<h2>產業因子篩選</h2>



<p class="has-medium-font-size">簡單範例測完以後，會發現踏出成功的第一步，但接下來還有些問題要處理。</p>



<ul class="has-medium-font-size"><li>有一些產業比較冷門，業內公司太少，統計樣本不夠。</li><li>產業那麼多，哪一些產業才適合用同業本益比比較法？</li><li>如何比較產業回測？</li></ul>



<h3>取樣統計樣本</h3>



<p class="has-medium-font-size">流程說明寫在以下程式註解，若你對 python 不熟，有幾個關鍵字需要先熟悉，例如「<a href="https://www.796t.com/content/1515241329.html" target="_blank" rel="noopener">eval</a>」、「<a href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.explode.html" target="_blank" rel="noopener">pandas explode</a>」、「<a href="https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.groupby.html" target="_blank" rel="noopener">pandas groupby</a>」。<br>依據此程式範例，最後選定 36 個產業來做回測。</p>



<pre class="wp-block-code"><code lang="python" class="language-python"># 取出產業題材
themes = data.get('security_industry_themes')
# 複製一個 themes 來計算每個產業內有多少公司？
copied_themes = themes.copy()
# 將 category 陣列從文字格式轉成陣列格式
copied_themes['category'] = copied_themes['category'].apply(lambda s:eval(s))
# 以 pandas 的 explode 展開資料
exploded_themes = copied_themes.explode(['category'])
# 分群產業計算公司數
themes_count = exploded_themes.groupby('category')['stock_id'].count()
# 取出家數大於20家公司的主產業
large_themes = themes_count[themes_count &gt;= 20].index
primary_themes = [i for i in large_themes if ':' not in i]

# primary_themes:
# ['LED照明產業', '交通運輸及航運', '人工智慧', '休閒娛樂', '其他', 
#  '半導體', '印刷電路板', '大數據', '太空衛星科技', '太陽能產業', 
#  '平面顯示器', '建材營造', '文化創意業', '汽車', '石化及塑橡膠', 
#  '紡織', '能源元件', '被動元件', '製藥', '觸控面板', 
#  '貿易百貨', '資通訊安全', '軟體服務', '通信網路', '連接器', '運動科技', 
#  '醫療器材', '金融', '鋼鐵', '雲端運算', '電動車輛產業', 
#  '電子商務', '電機機械', '電腦及週邊設備', '風力發電', '食品', '食品生技']</code></pre>



<p></p>



<h3>產業面回測比較</h3>



<p class="has-medium-font-size">接下來要回測36個產業，模擬回測至2018-12-31，用此回測結果選出前n大適合產業，再用選出的產業因子回測 2019 後的數據。<br>比較36個回測有什麼好工具嗎？很多人可能不知道FinLab早已有工具可用，放在 <code>finlab.optimize</code> 之下的 ReportCollection ，可以產生多策略比較圖表，想了解細節的可以看<a href="https://doc.finlab.tw/reference/optimize/#finlab.optimize.combinations.ReportCollection" target="_blank" rel="noopener">函數庫文件</a>。</p>



<pre class="wp-block-code"><code lang="python" class="language-python"># 模擬回測至2018-12-31，用此回測結果選出前n大適合產業，再用選出的產業模擬
def sim_industry_position_by_pe(ind):
    stock_ids = exploded_themes[exploded_themes['category'].apply(lambda s:s==ind)]
    pe = data.get('price_earning_ratio:本益比')
    ind_pe = pe[list(set(stock_ids['stock_id']))]
    ind_pe_med = ind_pe.median(axis=1)
    position = (ind_pe &lt; ind_pe_med)
    position = position.loc[:'2018']
    # 2週換股一次
    report = sim(position, upload=False, position_limit=0.2,resample='2W')
    return report


# 產生回測組合
reports = {ind: sim_industry_position_by_pe(ind) for ind in primary_themes }
# 放入回測報告組合比較器
collection = ReportCollection(reports)


# 繪圖產業回測報酬率曲線
import plotly.graph_objects as go

fig = go.Figure()
reports = collection.reports
# 報酬率曲線繪圖label按高低排序
dataset = {k: v for k, v in sorted(reports.items(), key=lambda item: item[1].creturn[-1], reverse=True)}
for k, v in dataset.items():
    series = v.creturn
    fig.add_trace(go.Scatter(x=series.index, y=series.values, mode='lines', name=k, meta=k,
                              hovertemplate="%{meta}&lt;br&gt;Date:%{x}&lt;br&gt;Creturns:%{y}&lt;extra&gt;&lt;/extra&gt;"))
fig.update_layout(title={'text': 'Cumulative returns', 'x': 0.49, 'y': 0.9, 'xanchor': 'center',
                          'yanchor': 'top'})
fig.show()

# 產生回測數據分群柱狀圖
collection.plot_stats().show()

# 產生評分熱力圖
heatmap = collection.plot_stats(mode='heatmap')
heatmap 
</code></pre>



<p class="has-medium-font-size">輸出報酬率曲線，發現表現最好的前15名產業為「&#8217;紡織&#8217;, &#8216;電機機械&#8217;, &#8216;大數據&#8217;, &#8216;雲端運算&#8217;, &#8216;醫療器材&#8217;, &#8216;電動車輛產業&#8217;, &#8216;貿易百貨&#8217;, &#8216;食品&#8217;, &#8216;軟體服務&#8217;, &#8216;汽車&#8217;, &#8216;金融&#8217;, &#8216;太陽能產業&#8217;, &#8216;石化及塑橡膠&#8217;, &#8216;資通訊安全&#8217;, &#8216;人工智慧&#8217;」，傳產、軟體居多，電子業排名很後面。</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="265" src="https://www.finlab.tw/wp-content/uploads/2022/11/newplot-14-1024x265.png" alt="newplot 14" class="wp-image-4775" srcset="https://www.finlab.tw/wp-content/uploads/2022/11/newplot-14-1024x265.png 1024w, https://www.finlab.tw/wp-content/uploads/2022/11/newplot-14-300x78.png 300w, https://www.finlab.tw/wp-content/uploads/2022/11/newplot-14-768x199.png 768w, https://www.finlab.tw/wp-content/uploads/2022/11/newplot-14-1536x397.png 1536w, https://www.finlab.tw/wp-content/uploads/2022/11/newplot-14.png 2029w" sizes="(max-width: 1024px) 100vw, 1024px" title="產業面選股策略｜同業本益比比較法 4"></figure>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" src="https://www.finlab.tw/wp-content/uploads/2022/11/newplot-5-1024x265.png" alt="newplot 5" class="wp-image-4760" width="840" height="217" srcset="https://www.finlab.tw/wp-content/uploads/2022/11/newplot-5-1024x265.png 1024w, https://www.finlab.tw/wp-content/uploads/2022/11/newplot-5-300x78.png 300w, https://www.finlab.tw/wp-content/uploads/2022/11/newplot-5-768x199.png 768w, https://www.finlab.tw/wp-content/uploads/2022/11/newplot-5-1536x397.png 1536w, https://www.finlab.tw/wp-content/uploads/2022/11/newplot-5.png 2029w" sizes="(max-width: 840px) 100vw, 840px" title="產業面選股策略｜同業本益比比較法 5"><figcaption>回測數據分群柱狀圖</figcaption></figure>



<p class="has-medium-font-size">一個好多策略不是看報酬率高低就好，ReportCollection 的<a href="https://doc.finlab.tw/reference/optimize/#finlab.optimize.combinations.ReportCollection.plot_stats" target="_blank" rel="noopener"> 熱力圖</a> 將 策略群的數據做分級處理，最後將個指標的分數取平均(最右欄)，可以大致先出體質相對前段班的產業回測。前15名大致和報酬率排名差不多。</p>



<figure class="wp-container-2 wp-block-gallery-1 wp-block-gallery has-nested-images columns-default is-cropped">
<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="680" data-id="4774" src="https://www.finlab.tw/wp-content/uploads/2022/11/截圖-2022-11-02-下午12.05.27-1024x680.png" alt="截圖 2022 11 02 下午12.05.27" class="wp-image-4774" srcset="https://www.finlab.tw/wp-content/uploads/2022/11/截圖-2022-11-02-下午12.05.27-1024x680.png 1024w, https://www.finlab.tw/wp-content/uploads/2022/11/截圖-2022-11-02-下午12.05.27-300x199.png 300w, https://www.finlab.tw/wp-content/uploads/2022/11/截圖-2022-11-02-下午12.05.27-768x510.png 768w, https://www.finlab.tw/wp-content/uploads/2022/11/截圖-2022-11-02-下午12.05.27-1536x1020.png 1536w, https://www.finlab.tw/wp-content/uploads/2022/11/截圖-2022-11-02-下午12.05.27.png 1807w" sizes="(max-width: 1024px) 100vw, 1024px" title="產業面選股策略｜同業本益比比較法 6"><figcaption>熱力圖</figcaption></figure>
</figure>



<h2>多產業策略</h2>



<p class="has-medium-font-size">「假設做出來兩個產業的position,要如何合併？rows數相同, columns數不同,而且columns中stock_id有重複,但是其中的真偽值不同,要作聯集(or)？」</p>



<p class="has-medium-font-size">選好產業後，我們可以將每一個產業的訊號部位組裝成一個總合訊號部位，之後回測2019年後的測試集績效。</p>



<pre class="wp-block-code"><code lang="python" class="language-python">def get_industry_position_by_pe(ind):
    stock_ids = exploded_themes[exploded_themes['category'].apply(lambda s:s==ind)]
    pe = data.get('price_earning_ratio:本益比')
    ind_pe = pe[list(set(stock_ids['stock_id']))]
    ind_pe_med = ind_pe.median(axis=1)
    position = (ind_pe &lt; ind_pe_med)
    return position


# 選出綜合評分前15高的產業
inds = heatmap.index[:15]

# 部位訊號合併
all_position = pd.concat([get_industry_position_by_pe(ind) for ind in inds],axis=1)

# 處理欄位重複問題，一家公司可能橫跨多產業，只要有一個產業選到，就選入。使用groupby mean處理重複同stock_id
buy = all_position.groupby(level=0, axis=1).mean() &gt; 0
report = sim(buy.loc['2019':], position_limit=0.2,resample='2W',upload=False)
report.display()</code></pre>



<p class="has-medium-font-size">比較一下2018年前「綜合評分前15高的產業」和「綜合評分前15名之後的產業」，可以發現雖然後者報率比較優(半導體前幾年爆發)，但回撤波動比前者高很多，前者除了2020年疫情剛爆發時崩跌，向下波動比較穩定，維持在-10%上下，尤其是空頭年份2022表現比後者穩不少，也較大盤抗跌，牛市時比成長股弱勢，但熊市時有優勢，具價值股特性。<br>要選前10還是前15名產業，可自由設定。</p>



<figure class="wp-block-image size-full"><img loading="lazy" width="800" height="600" src="https://www.finlab.tw/wp-content/uploads/2022/11/newplot-16.png" alt="newplot 16" class="wp-image-4779" srcset="https://www.finlab.tw/wp-content/uploads/2022/11/newplot-16.png 800w, https://www.finlab.tw/wp-content/uploads/2022/11/newplot-16-300x225.png 300w, https://www.finlab.tw/wp-content/uploads/2022/11/newplot-16-768x576.png 768w" sizes="(max-width: 800px) 100vw, 800px" title="產業面選股策略｜同業本益比比較法 7"><figcaption>綜合評分前15高的產業</figcaption></figure>



<figure class="wp-block-image size-full"><img loading="lazy" width="800" height="600" src="https://www.finlab.tw/wp-content/uploads/2022/11/newplot-17.png" alt="newplot 17" class="wp-image-4780" srcset="https://www.finlab.tw/wp-content/uploads/2022/11/newplot-17.png 800w, https://www.finlab.tw/wp-content/uploads/2022/11/newplot-17-300x225.png 300w, https://www.finlab.tw/wp-content/uploads/2022/11/newplot-17-768x576.png 768w" sizes="(max-width: 800px) 100vw, 800px" title="產業面選股策略｜同業本益比比較法 8"><figcaption>綜合評分前15名之後的產業</figcaption></figure>



<h2>策略優化</h2>



<p class="has-medium-font-size">上述產業面選股的回測驗証了價值股特性，但有個問題是選出來的標的太多了，實務上不能能選買，且牛市時動能差了點，所以我們可嘗試加上一些個股條件和流動性條件去限縮標的數量，增加一點成長股因子，讓策略更有實戰能力。台股長期對月營收條件、規模因子友善，是不錯的選項。<br>加入的個股條件為「近3月平均營收」大於「近12月平均營收」、近月單月營收年增率大於20%、近3月平均營收的年增率大於15%、五日均量大於100張、最後選出符合前述條件五日均量前10小的標的。</p>



<h3>策略程式</h3>



<pre class="wp-block-code"><code lang="python" class="language-python">def get_industry_position_by_pe(ind):
    stock_ids = exploded_themes[exploded_themes['category'].apply(lambda s:s==ind)]
    pe = data.get('price_earning_ratio:本益比')
    stock_ids = [i for i in list(set(stock_ids['stock_id'])) if i in pe.columns]
    ind_pe = pe[stock_ids]
    ind_pe_med = ind_pe.median(axis=1)
    position = (ind_pe &lt; ind_pe_med)
    return position


inds = heatmap.index[:15]
all_position = pd.concat([get_industry_position_by_pe(ind) for ind in inds],axis=1)
all_position= all_position.groupby(level=0, axis=1).mean() &gt; 0

vol=data.get('price:成交股數')
close = data.get('price:收盤價')
pe = data.get('price_earning_ratio:本益比')
rev=data.get('monthly_revenue:當月營收')
rev_rf=data.get('monthly_revenue:去年同月增減(%)')
rev_ma3=rev.average(3)
rev_ma12=rev.average(12)
vol_ma5 = vol.average(5)

extra_conds = ((rev_ma3 &gt; rev_ma12).sustain(3)) &amp; (rev_rf &gt;= 20) &amp; (rev_ma3/rev_ma3.shift(12) &gt;= 1.15) &amp; (vol_ma5 &gt;= 100*1000)
buy = all_position &amp; extra_conds
buy *= vol_ma5
buy = buy[buy&gt;0].is_smallest(10)


report = sim(buy, position_limit=0.2,resample='2W',stop_loss=0.2,upload=True)
report.benchmark = data.get('benchmark_return:發行量加權股價報酬指數').squeeze()
report.display()</code></pre>



<p class="has-medium-font-size"><br></p>



<h3>同業本益比比較法的產業面選股＊個股條件的回測結果</h3>



<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="678" src="https://www.finlab.tw/wp-content/uploads/2022/11/截圖-2022-11-02-下午12.07.16-1024x678.png" alt="截圖 2022 11 02 下午12.07.16" class="wp-image-4777" srcset="https://www.finlab.tw/wp-content/uploads/2022/11/截圖-2022-11-02-下午12.07.16-1024x678.png 1024w, https://www.finlab.tw/wp-content/uploads/2022/11/截圖-2022-11-02-下午12.07.16-300x199.png 300w, https://www.finlab.tw/wp-content/uploads/2022/11/截圖-2022-11-02-下午12.07.16-768x509.png 768w, https://www.finlab.tw/wp-content/uploads/2022/11/截圖-2022-11-02-下午12.07.16.png 1378w" sizes="(max-width: 1024px) 100vw, 1024px" title="產業面選股策略｜同業本益比比較法 9"></figure>



<figure class="wp-block-image size-full"><img loading="lazy" width="800" height="600" src="https://www.finlab.tw/wp-content/uploads/2022/11/newplot-15.png" alt="newplot 15" class="wp-image-4784" srcset="https://www.finlab.tw/wp-content/uploads/2022/11/newplot-15.png 800w, https://www.finlab.tw/wp-content/uploads/2022/11/newplot-15-300x225.png 300w, https://www.finlab.tw/wp-content/uploads/2022/11/newplot-15-768x576.png 768w" sizes="(max-width: 800px) 100vw, 800px" title="產業面選股策略｜同業本益比比較法 10"></figure>



<h3>單用外加的個股條件的回測結果</h3>



<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="670" src="https://www.finlab.tw/wp-content/uploads/2022/11/截圖-2022-11-02-上午9.37.20-1024x670.png" alt="截圖 2022 11 02 上午9.37.20" class="wp-image-4768" srcset="https://www.finlab.tw/wp-content/uploads/2022/11/截圖-2022-11-02-上午9.37.20-1024x670.png 1024w, https://www.finlab.tw/wp-content/uploads/2022/11/截圖-2022-11-02-上午9.37.20-300x196.png 300w, https://www.finlab.tw/wp-content/uploads/2022/11/截圖-2022-11-02-上午9.37.20-768x503.png 768w, https://www.finlab.tw/wp-content/uploads/2022/11/截圖-2022-11-02-上午9.37.20.png 1389w" sizes="(max-width: 1024px) 100vw, 1024px" title="產業面選股策略｜同業本益比比較法 11"></figure>



<figure class="wp-block-image size-full"><img loading="lazy" width="800" height="600" src="https://www.finlab.tw/wp-content/uploads/2022/11/newplot-13.png" alt="newplot 13" class="wp-image-4769" srcset="https://www.finlab.tw/wp-content/uploads/2022/11/newplot-13.png 800w, https://www.finlab.tw/wp-content/uploads/2022/11/newplot-13-300x225.png 300w, https://www.finlab.tw/wp-content/uploads/2022/11/newplot-13-768x576.png 768w" sizes="(max-width: 800px) 100vw, 800px" title="產業面選股策略｜同業本益比比較法 12"></figure>



<h3>回測分析</h3>



<p class="has-medium-font-size">可以發現「同業本益比比較法的產業選股＊個股條件」後，年化報酬率、夏普率、勝率表現明顯比「原多產業投組」、「單用外加的個股條件」要好，不僅解決檔數問題，也同時兼備穿越牛熊的能力。</p>



<h2>結論</h2>



<p class="has-medium-font-size">這篇應用跨了許多面向，讓你一次學會：</p>



<ul class="has-medium-font-size"><li>產業資訊處理</li><li>產業面策略～同業本益比比較法的程式撰寫</li><li>多策略回測比較報告生成</li><li>產業面選股*個股基本面的策略優化<br></li></ul>



<p class="has-medium-font-size">是不是很有收穫呢？要知道「產業分析模組」在別家軟體可是要另外付費1000/月的模組功能，「產業面選股主題」的主題在外面課程也要千把塊，沒想到FinLab一個月不到千元的費用就包含了，還外送你「產業面*個股基本面」的策略程式，這絕對在外面軟體的GUI按不出來，學會寫程式，就是有彈性的好處，不用受制於操作介面，也不用學虛無飄渺的操作心法，操盤人多年盤感與產業知識絕對不是你短時間可以複製，但是複製程式卻是很簡單的事&#8230;你要選擇哪一個？</p>



<ul class="has-medium-font-size"><li><a href="https://colab.research.google.com/drive/11Qi_d-4-fIjE-ds6pj4Et0nV4w18ZBIa?usp=sharing" target="_blank" rel="noopener">colab 範例檔連結</a></li><li><a href="https://ai.finlab.tw/strategyview/?uid=TJN4FDuqrwU8DML7DAjUYFIMutp2&amp;sid=%E5%A4%9A%E7%94%A2%E6%A5%AD%E5%83%B9%E6%8A%95" target="_blank" rel="noopener">多產業價投策略</a>複製部署</li><li><a href="https://ai.finlab.tw/industry?industry=%E8%BE%B2%E6%A5%AD%E7%A7%91%E6%8A%80&amp;tab=%E6%9D%BF%E5%A1%8A%E5%9C%96" target="_blank" rel="noopener">產業板塊圖</a></li></ul>
]]></content:encoded>
					
					<wfw:commentRss>https://www.finlab.tw/industry_pe_strategy/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">4755</post-id>	</item>
	</channel>
</rss>
