From e76b409d9a1f25b05cd2f223dc66b7e7104e9741 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E9=98=81=E9=94=90?= <40440788+2young-2simple-sometimes-naive@users.noreply.github.com> Date: Sat, 1 Jan 2022 10:44:17 -0500 Subject: [PATCH] Fix $volume normalization issue (#792) * Fix $volume normalization issue Fix: https://github.com/microsoft/qlib/issues/765 * black formatting black formatting * black formatting black formatting * black formatting black formatting --- qlib/contrib/data/handler.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qlib/contrib/data/handler.py b/qlib/contrib/data/handler.py index 1e82ed67e..3c6a93f22 100644 --- a/qlib/contrib/data/handler.py +++ b/qlib/contrib/data/handler.py @@ -126,9 +126,9 @@ class Alpha360(DataHandlerLP): fields += ["$vwap/$close"] names += ["VWAP0"] for i in range(59, 0, -1): - fields += ["Ref($volume, %d)/$volume" % (i)] + fields += ["Ref($volume, %d)/($volume+1e-12)" % (i)] names += ["VOLUME%d" % (i)] - fields += ["$volume/$volume"] + fields += ["$volume/($volume+1e-12)"] names += ["VOLUME0"] return fields, names @@ -249,7 +249,7 @@ class Alpha158(DataHandlerLP): names += [field.upper() + str(d) for d in windows] if "volume" in config: windows = config["volume"].get("windows", range(5)) - fields += ["Ref($volume, %d)/$volume" % d if d != 0 else "$volume/$volume" for d in windows] + fields += ["Ref($volume, %d)/($volume+1e-12)" % d if d != 0 else "$volume/($volume+1e-12)" for d in windows] names += ["VOLUME" + str(d) for d in windows] if "rolling" in config: windows = config["rolling"].get("windows", [5, 10, 20, 30, 60])