<?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/%E8%B2%A1%E5%A0%B1/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.finlab.tw</link>
	<description>深入淺出的量化投資，讓你在在茫茫股海中，找到專屬於自己的投資方法</description>
	<lastBuildDate>Sun, 30 Oct 2022 08:05:56 +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/tw_stock_financial_statement_time_series_knowledge/</link>
					<comments>https://www.finlab.tw/tw_stock_financial_statement_time_series_knowledge/#respond</comments>
		
		<dc:creator><![CDATA[Ben]]></dc:creator>
		<pubDate>Fri, 28 Oct 2022 10:31:13 +0000</pubDate>
				<category><![CDATA[Python新手教學]]></category>
		<category><![CDATA[FinLab 量化平台]]></category>
		<category><![CDATA[生產力]]></category>
		<category><![CDATA[FinlabDataframe]]></category>
		<category><![CDATA[台股]]></category>
		<category><![CDATA[策略開發豆知識]]></category>
		<category><![CDATA[財報]]></category>
		<category><![CDATA[資料處理]]></category>
		<guid isPermaLink="false">https://www.finlab.tw/?p=4720</guid>

					<description><![CDATA[目前正逢財報季，有些公司已經上傳第三季財報，許多已基本面為選股主軸的用戶都開始緊盯自己的程式是否跑出新的指引？許多新手用戶對財報資料的發佈時間和資料操作不熟悉，這篇文章將娓娓道來台股財報資料的時序細節，花幾分鐘，你會了解財報「發布日、截止日、FinlabDataFrame的資料索引轉換方法，讓你上手財報資料選股策略。]]></description>
										<content:encoded><![CDATA[
<p class="has-medium-font-size">目前正逢財報季，有些公司已經上傳第三季財報，許多已基本面為選股主軸的用戶都開始緊盯自己的程式是否跑出新的指引？藉於新手用戶對財報資料的發佈時間和資料操作不熟悉，這篇文章將娓娓道來台股財報資料的時序細節，花幾分鐘，你會了解財報「發布日、截止日、FinlabDataFrame的資料索引轉換方法，讓你上手財報資料選股策略的前處理。</p>



<h2>財報發布日定義</h2>



<p class="has-medium-font-size">FinLab 資料庫系統會每天更新、檢查財報資料，財報發布日以<a href="https://doc.twse.com.tw/server-java/t57sb01?step=1&amp;colorchg=1&amp;co_id=1101&amp;year=&amp;seamon=&amp;mtype=A&amp;" target="_blank" rel="noopener">財報電子檔</a>內的資料上傳日當基準資料。你可能疑惑怎麼在新聞或公司重訊已看到 EPS 多少了，但抓下的財報或財報電子檔卻沒有當季資料？那是因為有些公司的財報電子檔上傳日會比董事會重訊發布晚個幾天，通常是因為公司內部或會計作業問題，某些會計項目可能還會再校對或微調等等，實際數字以公司財報完整電子檔上傳才是比較穩當的做法。 大部分的公司會在財報截止日前一週內才上傳完畢。</p>



<h2>財報截止日定義</h2>



<p class="has-medium-font-size">所有公司都必須在每季財報截止日前上傳財報電子書，若沒有即時上傳，通常代表財務狀況出問題、會計師審核上出狀況&#8230;若沒在規定期限內補正，後續面臨暫停交易或下市風險。<br>台股上市櫃公司一年要上傳4次財報，興櫃只要上傳第二季和第四季財報，監理強度不同。各產業截止日細節如下列供參：</p>



<h3>上市櫃一般公司</h3>



<p class="has-medium-font-size">季別/財報截止日對應為下列對應，遇假日則遞延到次一個交易日。</p>



<ul class="has-medium-font-size"><li>Q1：當年5/15</li><li>Q2：當年8/14。若為2021年後的KY股，因監管法規改變，改成8/31。</li><li>Q3：當年11/14</li><li>Q4：次年3/31</li></ul>



<h3>保險業</h3>



<p class="has-medium-font-size">季別/財報截止日對應為下列對應，遇假日則遞延到次一個交易日。</p>



<ul class="has-medium-font-size"><li>Q1：當年4/30</li><li>Q2：當年8/31</li><li>Q3：當年10/30</li><li>Q4：次年3/31</li></ul>



<h3>金融業</h3>



<p class="has-medium-font-size">這邊指的是非保險的金融業，如銀行、證券、票券、金控業者。季別/財報截止日對應為下列對應，遇假日則遞延到次一個交易日。</p>



<ul class="has-medium-font-size"><li>Q1：當年5/15</li><li>Q2：當年8/31</li><li>Q3：當年11/14</li><li>Q4：次年3/31</li></ul>



<h2>量化平台財報資料操作</h2>



<h3>取得資料</h3>



<p class="has-medium-font-size">至<a href="https://ai.finlab.tw/database/#financial_statement" target="_blank" rel="noopener">財報資料庫</a>複製財報項目的使用方法，即可取得財報資料。<br>欄位是每家公司的股號，包含所有公開發行公司，索引則是每季的季別，ex : 2013Q1。<br>新手會疑惑為什麼看到一堆NaN ?不要緊張，不是資料出問題，而是這些公司當時未上市櫃或按規定不用發布財報。</p>



<figure class="wp-block-image size-large"><img width="1024" height="565" src="https://www.finlab.tw/wp-content/uploads/2022/10/截圖-2022-10-28-下午5.25.31-1024x565.png" alt="截圖 2022 10 28 下午5.25.31" class="wp-image-4721" srcset="https://www.finlab.tw/wp-content/uploads/2022/10/截圖-2022-10-28-下午5.25.31-1024x565.png 1024w, https://www.finlab.tw/wp-content/uploads/2022/10/截圖-2022-10-28-下午5.25.31-300x166.png 300w, https://www.finlab.tw/wp-content/uploads/2022/10/截圖-2022-10-28-下午5.25.31-768x424.png 768w, https://www.finlab.tw/wp-content/uploads/2022/10/截圖-2022-10-28-下午5.25.31-1536x848.png 1536w, https://www.finlab.tw/wp-content/uploads/2022/10/截圖-2022-10-28-下午5.25.31-2048x1130.png 2048w" sizes="(max-width: 1024px) 100vw, 1024px" title="台股財報資料豆知識 ｜ 時序索引操作 1"></figure>



<p class="has-medium-font-size">另外提一個小技巧，如果你想要拿掉未上市櫃公司來方便觀察資料，可以使用pandas的<a href="https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.dropna.html" target="_blank" rel="noopener">dropna</a>進行操作。下面的例子會排除掉每一欄位沒有20格有數值的欄位，篩出上市櫃有較久歷史的公司，就可以顯示中間部分的資料，像是1101台泥等等。</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="534" src="https://www.finlab.tw/wp-content/uploads/2022/10/截圖-2022-10-28-下午5.34.53-1024x534.png" alt="截圖 2022 10 28 下午5.34.53" class="wp-image-4722" srcset="https://www.finlab.tw/wp-content/uploads/2022/10/截圖-2022-10-28-下午5.34.53-1024x534.png 1024w, https://www.finlab.tw/wp-content/uploads/2022/10/截圖-2022-10-28-下午5.34.53-300x157.png 300w, https://www.finlab.tw/wp-content/uploads/2022/10/截圖-2022-10-28-下午5.34.53-768x401.png 768w, https://www.finlab.tw/wp-content/uploads/2022/10/截圖-2022-10-28-下午5.34.53-1536x802.png 1536w, https://www.finlab.tw/wp-content/uploads/2022/10/截圖-2022-10-28-下午5.34.53-2048x1069.png 2048w" sizes="(max-width: 1024px) 100vw, 1024px" title="台股財報資料豆知識 ｜ 時序索引操作 2"></figure>



<h3>時序轉換</h3>



<p class="has-medium-font-size">上面原始財報數據的日期索引是如「2022-Q1」這類的文字格式，雖然回測將不同尺度的資料取交集時會自動將時序轉成財報發布日的datetime格式，但若有其他用途，想將時序索引從文字轉換成財報發布日的datetime格式，該如何做呢？</p>



<h4>季別文字轉財報發佈日</h4>



<p class="has-medium-font-size">轉非常的簡單，只要加上 <code>index_str_to_date()</code> ，就能將資料轉換，這是<a href="https://doc.finlab.tw/reference/dataframe/#finlab.dataframe.FinlabDataFrame.index_str_to_date" target="_blank" rel="noopener">FinlabDataFrame</a>類別內建的方法。<br>從下圖所示，可以看到加完 <code>index_str_to_date()</code>後，索引改變了。<br>要注意的是，如果公司還沒有正式上傳「<a href="https://doc.twse.com.tw/server-java/t57sb01?step=1&amp;colorchg=1&amp;co_id=1101&amp;year=&amp;seamon=&amp;mtype=A&amp;" target="_blank" rel="noopener">財報電子書</a>」，雖然<a href="https://mops.twse.com.tw/mops/web/t203sb02" target="_blank" rel="noopener">XBRL資訊平台</a>已經有數值可下載，但由於財報電子書上傳日資料未定，資料仍會被歸到截止日的欄位。<br>現在正臨2022-Q3財報季，沒有財報電子書上傳日的數值都會放到最後兩欄的財報截止日，2022-10-31是保險業Q3截止日、2022-11-14則是一般上市櫃公司的Q3截止日，不用擔心回測會用到未來資料，回測會再去與收盤價的交易日索引做對應，遇假日會遞延到下一個交易日。<br>你可能會好奇，公司每季只會發布一次財報，為何日期會那麼多天？那是因為只要A日有任一家公司有上傳紀錄，為方便回測，索引都會加入發布日，如果其他公司在A日沒發布財報，其他公司則會套用近一期數值做填充。</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="486" src="https://www.finlab.tw/wp-content/uploads/2022/10/截圖-2022-10-28-下午5.48.13-1024x486.png" alt="截圖 2022 10 28 下午5.48.13" class="wp-image-4723" srcset="https://www.finlab.tw/wp-content/uploads/2022/10/截圖-2022-10-28-下午5.48.13-1024x486.png 1024w, https://www.finlab.tw/wp-content/uploads/2022/10/截圖-2022-10-28-下午5.48.13-300x142.png 300w, https://www.finlab.tw/wp-content/uploads/2022/10/截圖-2022-10-28-下午5.48.13-768x364.png 768w, https://www.finlab.tw/wp-content/uploads/2022/10/截圖-2022-10-28-下午5.48.13-1536x728.png 1536w, https://www.finlab.tw/wp-content/uploads/2022/10/截圖-2022-10-28-下午5.48.13-2048x971.png 2048w" sizes="(max-width: 1024px) 100vw, 1024px" title="台股財報資料豆知識 ｜ 時序索引操作 3"></figure>



<h4>季別文字轉財報截止日</h4>



<p class="has-medium-font-size">若想使用財報截止日做回測與選股，可以使用 <code>deadline()</code> ，就能將資料轉換，這是<a href="https://doc.finlab.tw/reference/dataframe/#finlab.dataframe.FinlabDataFrame.deadline" target="_blank" rel="noopener">FinlabDataFrame</a> 類別內建的方法。注意財報資料與其他時間尺度的資料做交集時，預設是使用財報發布日，所以若要使用截止日當條件，一定要加上 <code>deadline()</code>，使用範例如下。</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="366" src="https://www.finlab.tw/wp-content/uploads/2022/10/截圖-2022-10-28-下午6.06.38-1024x366.png" alt="截圖 2022 10 28 下午6.06.38" class="wp-image-4724" srcset="https://www.finlab.tw/wp-content/uploads/2022/10/截圖-2022-10-28-下午6.06.38-1024x366.png 1024w, https://www.finlab.tw/wp-content/uploads/2022/10/截圖-2022-10-28-下午6.06.38-300x107.png 300w, https://www.finlab.tw/wp-content/uploads/2022/10/截圖-2022-10-28-下午6.06.38-768x274.png 768w, https://www.finlab.tw/wp-content/uploads/2022/10/截圖-2022-10-28-下午6.06.38-1536x548.png 1536w, https://www.finlab.tw/wp-content/uploads/2022/10/截圖-2022-10-28-下午6.06.38-2048x731.png 2048w" sizes="(max-width: 1024px) 100vw, 1024px" title="台股財報資料豆知識 ｜ 時序索引操作 4"></figure>



<p class="has-medium-font-size">截止日日期索引包括一般公司、保險業、金融業的規定日期，若當日沒數值，則會拿近一筆數值來補，以方便回測。</p>



<h2>結論</h2>



<p class="has-medium-font-size">經過上述說明，是不是對 FinLab 量化平台的財報資料操作與原理更為熟悉了呢？<br>如果想進一步學習用財報來選股，可參考這篇<a href="https://www.finlab.tw/basic_score_strategy/">財務指標計分法的教學</a>～<br>如果還有其他相關問題，歡迎隨時與我們討論喔！</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.finlab.tw/tw_stock_financial_statement_time_series_knowledge/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">4720</post-id>	</item>
	</channel>
</rss>
