美股 本益成長比策略
In [ ]:
Copied!
%%capture
!pip install finlab
%%capture
!pip install finlab
獲利因子¶
業利益成長率大於營收年增率,代表公司追求本業獲利,而不強調營收。 本益成長比使用「營業利益成長率」取代「稅後淨利成長率」,更強調選出本業獲利成長性高,估值相對低的股票。
In [ ]:
Copied!
from finlab import data
from finlab.backtest import sim
本益比 = data.get('us_daily_metrics:pe')
營收= data.get('us_fundamental:revenue')
營業利益 = data.get('us_fundamental:opinc')
def 成長率(s):
return ((s-s.shift(4)) / s.shift(4).abs()) * 100
營收成長率 = 成長率(營收)
營業利益成長率 = 成長率(營業利益)
peg = (本益比/營業利益成長率)
cond1 = 本益比 > 0
cond2 = 營業利益成長率 > 20
cond3 = 營業利益成長率 > 營收成長率
cond_all = cond1 & cond2 & cond3
position = peg*cond_all
position = position[position > 0].is_smallest(10)
report = sim(resample='W', position=position, fee_ratio=0, tax_ratio=0, stop_loss=0.1, name='美股本益成長比', live_performance_start='2021-06-01')
# report.display()
from finlab import data
from finlab.backtest import sim
本益比 = data.get('us_daily_metrics:pe')
營收= data.get('us_fundamental:revenue')
營業利益 = data.get('us_fundamental:opinc')
def 成長率(s):
return ((s-s.shift(4)) / s.shift(4).abs()) * 100
營收成長率 = 成長率(營收)
營業利益成長率 = 成長率(營業利益)
peg = (本益比/營業利益成長率)
cond1 = 本益比 > 0
cond2 = 營業利益成長率 > 20
cond3 = 營業利益成長率 > 營收成長率
cond_all = cond1 & cond2 & cond3
position = peg*cond_all
position = position[position > 0].is_smallest(10)
report = sim(resample='W', position=position, fee_ratio=0, tax_ratio=0, stop_loss=0.1, name='美股本益成長比', live_performance_start='2021-06-01')
# report.display()
輸入成功!
WARNING:finlab.data:us_daily_metrics:pe -- Daily usage: 1042.8 / 5000 MB WARNING:finlab.data:us_fundamental:revenue -- Daily usage: 1047.4 / 5000 MB WARNING:finlab.data:us_fundamental:opinc -- Daily usage: 1052.1 / 5000 MB WARNING:finlab.data:us_fundamental:datekey -- Daily usage: 1057.2 / 5000 MB WARNING:finlab.data:security_categories -- Daily usage: 1057.3 / 5000 MB WARNING:finlab.data:us_tickers -- Daily usage: 1062.7 / 5000 MB WARNING:finlab.data:us_price:adj_close -- Daily usage: 1146.0 / 5000 MB WARNING:finlab.data:world_index:adj_close -- Daily usage: 1166.3 / 5000 MB WARNING:finlab.data:us_price:close -- Daily usage: 1207.8 / 5000 MB /usr/local/lib/python3.10/dist-packages/finlab/analysis/alphaBetaAnalysis.py:22: RuntimeWarning: invalid value encountered in double_scalars
| annualized_rate_of_return | sharpe | max_drawdown | win_ratio | |
|---|---|---|---|---|
| 36.47% | 0.72 | -42.34% | 43.82% |
| entry_date | exit_date | entry_sig_date | exit_sig_date | position | period | entry_index | exit_index | return | trade_price@entry_date | trade_price@exit_date | mae | gmfe | bmfe | mdd | pdays | weight | next_weights | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| stock_id | ||||||||||||||||||
| ALPS ALPINE SUMMIT ENERGY PARTNERS INC | 2023-05-22 | NaT | 2023-05-19 | NaT | 0.111111 | 14.0 | 1606.0 | -1.0 | -0.158661 | 0.687 | 0.578 | -0.158661 | 0.002911 | 0.002911 | -0.161103 | 1.0 | 0.111111 | 0.1 |
| CEIX CONSOL ENERGY INC | 2023-05-30 | NaT | 2023-05-26 | 2023-06-11 | 0.111111 | 9.0 | 1611.0 | -1.0 | 0.155808 | 54.490 | 62.980 | -0.009727 | 0.159112 | 0.000000 | -0.009727 | 7.0 | 0.111111 | 0.0 |
| FCNCA FIRST CITIZENS BANCSHARES INC | 2023-05-15 | NaT | 2023-05-12 | NaT | 0.100000 | 19.0 | 1601.0 | -1.0 | 0.015016 | 1265.960 | 1284.970 | -0.014819 | 0.043564 | 0.043564 | -0.055945 | 15.0 | 0.111111 | 0.1 |
| IMPP IMPERIAL PETROLEUM INC/MARSHALL ISLANDS | 2023-06-05 | NaT | 2023-06-02 | NaT | 0.111111 | 5.0 | 1615.0 | -1.0 | 0.134078 | 3.580 | 4.060 | 0.000000 | 0.134078 | 0.000000 | -0.010000 | 4.0 | 0.111111 | 0.1 |
| ISIG INSIGNIA SYSTEMS INC | 2023-05-15 | NaT | 2023-05-12 | NaT | 0.100000 | 19.0 | 1601.0 | -1.0 | -0.070088 | 7.990 | 7.430 | -0.076345 | 0.000000 | 0.000000 | -0.076345 | 0.0 | 0.111111 | 0.1 |
| LBRT LIBERTY ENERGY INC | 2023-04-24 | NaT | 2023-04-21 | NaT | 0.100000 | 34.0 | 1586.0 | -1.0 | -0.012292 | 13.830 | 13.660 | -0.151121 | 0.000000 | 0.000000 | -0.151121 | 0.0 | 0.111111 | 0.1 |
| PDCE PDC ENERGY INC | 2023-06-05 | NaT | 2023-06-02 | 2023-06-11 | 0.111111 | 5.0 | 1615.0 | -1.0 | 0.019258 | 70.620 | 71.980 | 0.000000 | 0.025772 | 0.000000 | -0.006350 | 4.0 | 0.111111 | 0.0 |
| PSHG PERFORMANCE SHIPPING INC | 2023-05-08 | NaT | 2023-05-05 | NaT | 0.111111 | 24.0 | 1596.0 | -1.0 | -0.052000 | 0.750 | 0.711 | -0.057333 | 0.080000 | 0.080000 | -0.127160 | 17.0 | 0.111111 | 0.1 |
| WTM WHITE MOUNTAINS INSURANCE GROUP LTD | 2023-05-15 | NaT | 2023-05-12 | NaT | 0.100000 | 19.0 | 1601.0 | -1.0 | 0.013726 | 1412.680 | 1432.070 | -0.066278 | 0.034587 | 0.000000 | -0.066278 | 6.0 | 0.111111 | 0.1 |
| PSIX POWER SOLUTIONS INTERNATIONAL INC | NaT | NaT | 2023-06-11 | NaT | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 0.000000 | 0.1 |
| SIG SIGNET JEWELERS LTD | NaT | NaT | 2023-06-11 | NaT | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 0.000000 | 0.1 |
| SLCA US SILICA HOLDINGS INC | NaT | NaT | 2023-06-11 | NaT | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 0.000000 | 0.1 |
In [ ]:
Copied!