# 探討一個全局有效的因子優化方法：xxx/Price 因子選股

台股研究 2024年6月10日 約 1 分鐘閱讀

把 EPS、ROE 等基本面因子除以股價打造 xxx/Price 因子，用 finlab is\_largest(30) 回測台股，eps/price 與 roe/price 的累積報酬都明顯高於原始 EPS、ROE 排序。附完整 Python 程式碼與選股邏輯解析。

把現有因子除以收盤價後，[選股策略](https://finlab.finance/tools/stock-selection)的回測結果有了變化。這篇比較修改前後的差異，並附 Python 程式碼。

## 因子選股的基本概念

在進行因子選股時，我們通常會根據一些財務指標來篩選股票。這些指標能夠幫助我們判斷一家公司是否具有投資價值。你可能常常聽到有人說「某檔股票的 EPS 是多少多少耶！股價才多少，這太便宜了！」，基於這樣的想法，我們 提出「xxx/Price」 因子，即任何基本面有關的因子都可以拿來除以 Price 試試看。

本文示範其中幾個，例如：

* 每股盈餘（EPS）
* 股東權益報酬率（ROE）

這兩個關鍵財務指標與股價進行對比，從而挑選出具有潛力的股票。

## 因子構建的數學邏輯

我們使用每股盈餘（EPS）除以收盤價，以及股東權益報酬率（ROE）除以收盤價來計算因子值。

顯示程式碼

```
from finlab import backtest
 
eps = data.get('financial_statement:每股盈餘')
roe = data.get('fundamental_features:ROE稅後')
eps_per_price = data.get('financial_statement:每股盈餘')	/ data.get('price:收盤價')
roe_per_price = data.get('fundamental_features:ROE稅後') / data.get('price:收盤價')
```

依本文重跑

## 執行這個策略

複製提示詞，讓 AI 依照上方證據的資料、條件與風險檢查重跑一次。

告訴你的AI：

幫我設定 FinLab，重現這篇文章，請讀：https\://finlab.finance/setup?relatedUrl=/blog/factor-divided-by-price-stock-selection

[免安裝，開啟 FinLab Studio](https://studio.finlab.finance/chat?lang=zh\&research_context=%7B%22v%22%3A1%2C%22source_url%22%3A%22https%3A%2F%2Ffinlab.finance%2Fblog%2Ffactor-divided-by-price-stock-selection%22%7D)

以下分別回測原始因子與除以股價後的因子：

顯示程式碼

```
r = {}
r['eps'] = backtest.sim(eps.is_largest(30), upload=False)
r['eps'].creturn.plot(label='eps')
 
r['roe'] = backtest.sim(roe.is_largest(30), upload=False)
r['roe'].creturn.plot(label='roe')
 
r['eps_per_price'] = backtest.sim(eps_per_price.is_largest(30), upload=False)
r['eps_per_price'].creturn.plot(label='better_eps')
 
r['roe_per_price'] = backtest.sim(roe_per_price.is_largest(30), upload=False)
r['roe_per_price'].creturn.plot(label='better_roe')
 
import matplotlib.pyplot as plt
plt.legend()
```

[![xxx\_per\_price 因子回測累積報酬率折線圖，顯示除以股價後的因子報酬率皆高於原始因子](https://r2.finlab.finance/blog/better_factor/image.png)](https://r2.finlab.finance/blog/better_factor/image.png)

> xxx\_per\_price 確實都比 xxx 還要獲得更高的報酬率

## 代碼解析

1. **計算 EPS/Price 和 ROE/Price**：首先，我們從資料庫中提取每股盈餘和 ROE 的數據，並將其分別除以收盤價，得到兩個相對指標。
2. **排名計算**：接著，我們對這兩個相對指標進行排名，並計算其百分比排名。將這兩個排名相加得到綜合排名。
3. **選股策略**：根據綜合排名，我們選取排名前 30 的股票作為投資組合。
4. **回測**：最後，我們對這個選股策略進行回測，驗證其有效性。

## 回測結果

這次回測中，xxx/Price 因子的報酬高於原始因子。

## 結語

如果您對這個策略有任何疑問或想要了解更多，歡迎留言討論。

***

## 延伸閱讀

* [EPS 跟 ROE 哪個比較好用？回測告訴你](https://finlab.finance/blog/eps-vs-roe-stock-selection)
* [PE、PB、PEG 三大估值因子台股 10 年回測](https://finlab.finance/blog/pe-pb-peg-backtest)

**投資警語：本文僅供教學參考，不構成投資建議。過去績效不代表未來表現，投資有風險。**

![韓承佑](https://finlab.finance/people/cheng-yu-han-avatar.jpg)

韓承佑

創辦人 & 量化研究員

韓承佑是 FinLab 創辦人，也是開源 Python 量化套件 finlab 的作者，長年投入台股與美股的量化策略研究、回測與教學。

[在 GitHub 上追蹤 →](https://github.com/koreal6803) [在 LinkedIn 上連結 →](https://www.linkedin.com/in/cheng-yu-han/)

FinLab AI

### 想建立自己的策略？

用自然語言描述你的選股想法，AI 自動驗證、回測、給你答案

[免費開始](https://finlab.finance/#get-started)

## 更多價值與基本面研究

[查看全部](https://finlab.finance/blog/category/value)

* [![現金股利調高選股：加進月營收動能，7 年年化 59.9%、夏普 1.83](https://r2.finlab.finance/blog/cash-dividend-increase-stock-selection/chart_equity.png) 現金股利調高選股：加進月營收動能，7 年年化 59.9%、夏普 1.83 年化報酬 59.9% · 台股](https://finlab.finance/blog/cash-dividend-increase-stock-selection)
* [![營收創新高選股：月營收動能優先買營收創 12 個月新高，年化 52.4%、夏普 1.62](https://r2.finlab.finance/blog/revenue-new-high-stock-selection/chart_equity.png) 營收創新高選股：月營收動能優先買營收創 12 個月新高，年化 52.4%、夏普 1.62 年化報酬 52.4% · 台股](https://finlab.finance/blog/revenue-new-high-stock-selection)
* [![月營收動能選股：台股 11 年回測年化 50%，夏普 1.46（附程式碼）](https://r2.finlab.finance/blog/monthly-revenue-momentum/chart_summary.png) 月營收動能選股：台股 11 年回測年化 50%，夏普 1.46（附程式碼） 年化報酬 50.0% · 台股](https://finlab.finance/blog/monthly-revenue-momentum)
* [![財報選股 3 指標回測：2020 年起年化 45.6%，近三年輸 0050](https://r2.finlab.finance/blog/fundamental-3-indicators/image-4-1024x938.png) 財報選股 3 指標回測：2020 年起年化 45.6%，近三年輸 0050 年化報酬 45.6% · 台股](https://finlab.finance/blog/fundamental-3-indicators)

來源：https://finlab.finance/blog/factor-divided-by-price-stock-selection｜資料日期：依上文各表格與段落標示｜頁面更新：2026-11-25
