资金异动方向两套写法都认
This commit is contained in:
parent
3c43f7814f
commit
5cdb3b0ee4
|
|
@ -520,7 +520,9 @@ def _bycode_metrics(c, code, cap):
|
|||
g = lambda k, dv=None: payload.get(k, f.get(k, dv))
|
||||
_d = str(g("direction") or "").lower()
|
||||
rows.append(_row("metrics", "盘中资金异动", _id_ms(sid), cat="fund_flow", cat_label="资金异动",
|
||||
direction={"inflow": "看涨", "outflow": "看跌"}.get(_d, g("direction")),
|
||||
direction={"inflow": "看涨", "up": "看涨", "long": "看涨", "bull": "看涨",
|
||||
"outflow": "看跌", "down": "看跌", "short": "看跌",
|
||||
"bear": "看跌"}.get(_d, g("direction")),
|
||||
flow=_d or None, level=g("level"),
|
||||
value=_num(g("value") if g("value") is not None else g("net")),
|
||||
z_dd=_num(g("z_dd")), window_net=_num(g("window_net")),
|
||||
|
|
|
|||
|
|
@ -158,6 +158,9 @@ def test_parse_sources():
|
|||
assert len(mrows) == 1 and mrows[0]["time"] == "13:41" and mrows[0]["z_dd"] == 2.4
|
||||
assert mrows[0]["ts_from"] == "stream_id", "时间取自流 id 是写入时刻, 必须标出来"
|
||||
assert mrows[0]["direction"] == "看涨" and mrows[0]["flow"] == "up", mrows[0]
|
||||
assert us._bycode_metrics(_FakeRedis({"mtf:intraday:stream:metrics": [
|
||||
("%d-0" % _today_ms(9, 51), {"data": '{"ts_code": "601126.SH", "direction": "横着走"}'})]}),
|
||||
"601126.SH", 5000)[0][0]["direction"] == "横着走", "认不出的方向原样留着, 不假装知道"
|
||||
# 时间线是五路混着排的, 方向必须同一套说法, 且不许把英文枚举直接印给人看
|
||||
m2 = us._bycode_metrics(_FakeRedis({"mtf:intraday:stream:metrics": [
|
||||
("%d-0" % _today_ms(9, 50), {"data": '{"ts_code": "601126.SH", "direction": "outflow"}'})]}),
|
||||
|
|
|
|||
Loading…
Reference in New Issue