fix: RS 계산을 np.divide(where=) 방식으로 교체 — epsilon 이상치 폭발 차단

Made-with: Cursor
This commit is contained in:
21in7
2026-03-02 00:30:36 +09:00
parent 9cac8a4afd
commit bcc717776d
2 changed files with 58 additions and 2 deletions

View File

@@ -242,8 +242,16 @@ def _calc_features_vectorized(
eth_r5 = _align(eth_ret_5, n).astype(np.float32)
xrp_r1 = ret_1.astype(np.float32)
xrp_btc_rs_raw = (xrp_r1 / (btc_r1 + 1e-8)).astype(np.float32)
xrp_eth_rs_raw = (xrp_r1 / (eth_r1 + 1e-8)).astype(np.float32)
xrp_btc_rs_raw = np.divide(
xrp_r1, btc_r1,
out=np.zeros_like(xrp_r1),
where=(btc_r1 != 0),
).astype(np.float32)
xrp_eth_rs_raw = np.divide(
xrp_r1, eth_r1,
out=np.zeros_like(xrp_r1),
where=(eth_r1 != 0),
).astype(np.float32)
extra = pd.DataFrame({
"btc_ret_1": _rolling_zscore(btc_r1),