知行多空线指标接入选股与事件回测;大盘总览走 quicksync 统一入口;candles 批量 upsert 分批防 asyncpg 参数超限

This commit is contained in:
2026-09-02 16:51:52 +08:00
parent 6ef8c585d6
commit bec4e8149c
5 changed files with 48 additions and 21 deletions

View File

@@ -59,6 +59,12 @@ def _boll(df: pd.DataFrame, p: dict) -> dict[str, pd.Series]:
return {"boll_upper": out["upper"], "boll_mid": out["mid"], "boll_lower": out["lower"]}
def _zhixing(df: pd.DataFrame, p: dict) -> dict[str, pd.Series]:
dk = ind.zhixing_dkx(df["close"], m1=int(p["m1"]), m2=int(p["m2"]),
m3=int(p["m3"]), m4=int(p["m4"]))
return {"zhixing_dkx": dk, "zhixing_trend": ind.ema2(df["close"])}
def _close(df: pd.DataFrame, p: dict) -> dict[str, pd.Series]:
return {"close": df["close"]}
@@ -82,6 +88,8 @@ FAMILIES: dict[str, FamilyDef] = {
"rsi": FamilyDef("RSI", ("period",), {"period": 14}, 25, _rsi),
"ma": FamilyDef("MA", ("period",), {"period": 20}, 25, _ma),
"boll": FamilyDef("BOLL", ("period", "std"), {"period": 20, "std": 2}, 25, _boll),
"zhixing": FamilyDef("知行", ("m1", "m2", "m3", "m4"),
{"m1": 14, "m2": 28, "m3": 57, "m4": 114}, 114, _zhixing),
"close": FamilyDef("收盘价", (), {}, 1, _close),
"pct_chg": FamilyDef("日涨跌幅", (), {}, 1, _pct_chg),
}
@@ -91,12 +99,14 @@ INDICATOR_FAMILY: dict[str, str] = {
"macd_dif": "macd", "macd_dea": "macd", "macd_hist": "macd",
"rsi": "rsi", "ma": "ma",
"boll_upper": "boll", "boll_mid": "boll", "boll_lower": "boll",
"zhixing_dkx": "zhixing", "zhixing_trend": "zhixing",
"close": "close", "pct_chg": "pct_chg",
}
_IND_SUFFIX = {"kdj_k": "K", "kdj_d": "D", "kdj_j": "J",
"macd_dif": "DIF", "macd_dea": "DEA", "macd_hist": "",
"boll_upper": "上轨", "boll_mid": "中轨", "boll_lower": "下轨"}
"boll_upper": "上轨", "boll_mid": "中轨", "boll_lower": "下轨",
"zhixing_dkx": "多空线", "zhixing_trend": "趋势线"}
def _family_of(indicator: str) -> str: