Skip to content

Commit

Permalink
Fix $volume normalization issue (microsoft#792)
Browse files Browse the repository at this point in the history
* Fix $volume normalization issue

Fix: microsoft#765

* black formatting

black formatting

* black formatting

black formatting

* black formatting

black formatting
  • Loading branch information
2young-2simple-sometimes-naive authored Jan 1, 2022
1 parent 5692cc2 commit 79f34ea
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions qlib/contrib/data/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ def get_feature_config(self):
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
Expand Down Expand Up @@ -249,7 +249,7 @@ def parse_config_to_fields(config):
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])
Expand Down

0 comments on commit 79f34ea

Please sign in to comment.