過濾KY股財報
安裝套件¶
In [ ]:
Copied!
!pip install finlab > log.txt
!pip install finlab > log.txt
現金流量策略¶
In [ ]:
Copied!
from finlab import data
from finlab.backtest import sim
營業現金流 = data.get("financial_statement:營業活動之淨現金流入_流出").deadline()
投資現金流 = data.get("financial_statement:投資活動之淨現金流入_流出").deadline()
融資現金流 = data.get("financial_statement:籌資活動之淨現金流入_流出").deadline()
roe = data.get("fundamental_features:ROE稅後").deadline()
close = data.get("price:收盤價")
position = (營業現金流 > 0) & (投資現金流 > 0) & (融資現金流 < 0) & (roe > 5) & (close > 10)
from finlab import data
from finlab.backtest import sim
營業現金流 = data.get("financial_statement:營業活動之淨現金流入_流出").deadline()
投資現金流 = data.get("financial_statement:投資活動之淨現金流入_流出").deadline()
融資現金流 = data.get("financial_statement:籌資活動之淨現金流入_流出").deadline()
roe = data.get("fundamental_features:ROE稅後").deadline()
close = data.get("price:收盤價")
position = (營業現金流 > 0) & (投資現金流 > 0) & (融資現金流 < 0) & (roe > 5) & (close > 10)
In [ ]:
Copied!
# 過濾 KY股
sc = data.get("security_categories")
position_col = position.columns
ky_filter = position_col[~position_col.isin(list(sc[sc["name"].str.contains("KY")]["stock_id"]))]
position = position[ky_filter]
report = sim(position,resample="M",name="過濾KY股財報", upload=False)
report.display()
# 過濾 KY股
sc = data.get("security_categories")
position_col = position.columns
ky_filter = position_col[~position_col.isin(list(sc[sc["name"].str.contains("KY")]["stock_id"]))]
position = position[ky_filter]
report = sim(position,resample="M",name="過濾KY股財報", upload=False)
report.display()
stock_id 1539 0.043478 2303 0.043478 2504 0.043478 2636 0.043478 3093 0.043478 3131 0.043478 3169 0.043478 3557 0.043478 4506 0.043478 4945 0.043478 5534 0.043478 6195 0.043478 6278 0.043478 6281 0.043478 6294 0.043478 6506 0.043478 6542 0.043478 6683 0.043478 6706 0.043478 6747 0.043478 6761 0.043478 8084 0.043478 8421 0.043478 Name: 2022-07-31 00:00:00, dtype: float64
Timestamp('2022-07-31 00:00:00')