feat: 推荐原因丰富化——因子值→带数字/方向的中文描述

This commit is contained in:
lookt
2026-09-16 14:27:56 +08:00
parent 93ea5037ce
commit 42e1e68e26
5 changed files with 251 additions and 3 deletions
+35
View File
@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
"""服务器调试:两级状态桶在 000993 上的真实分布"""
import sys
import warnings
sys.path.insert(0, '/opt/a_stock_timeline')
warnings.filterwarnings('ignore')
from src.fetcher.kline_fetcher import KlineFetcher
from src.quant.model import per_stock_expected, _bucket, rsi_series
import numpy as np
import pandas as pd
DB = '/opt/a_stock_timeline/data/a_stock.db'
kf = KlineFetcher(DB)
k = kf.load('000993', 'day', 150)
print('bars:', len(k))
close = k['close'].reset_index(drop=True)
ma20 = close.rolling(20).mean()
rsi = rsi_series(close)
for fine in (True, False):
cur = _bucket(close.iloc[-1], ma20.iloc[-1], rsi.iloc[-1], fine)
rets = []
horizon = 5
for t in range(30, len(close) - horizon):
b = _bucket(close.iloc[t], ma20.iloc[t], rsi.iloc[t], fine)
if b == cur:
rets.append(close.iloc[t + horizon] / close.iloc[t] - 1)
med = float(np.median(rets)) if rets else None
print('fine={} 桶={} 样本={} 中位={}'.format(fine, cur, len(rets), med))
med, n, bucket = per_stock_expected(k)
print('per_stock_expected:', med, n, bucket)