Skip to content

Commit 79f34ea

Browse files
Fix $volume normalization issue (microsoft#792)
* Fix $volume normalization issue Fix: microsoft#765 * black formatting black formatting * black formatting black formatting * black formatting black formatting
1 parent 5692cc2 commit 79f34ea

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

qlib/contrib/data/handler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ def get_feature_config(self):
126126
fields += ["$vwap/$close"]
127127
names += ["VWAP0"]
128128
for i in range(59, 0, -1):
129-
fields += ["Ref($volume, %d)/$volume" % (i)]
129+
fields += ["Ref($volume, %d)/($volume+1e-12)" % (i)]
130130
names += ["VOLUME%d" % (i)]
131-
fields += ["$volume/$volume"]
131+
fields += ["$volume/($volume+1e-12)"]
132132
names += ["VOLUME0"]
133133

134134
return fields, names
@@ -249,7 +249,7 @@ def parse_config_to_fields(config):
249249
names += [field.upper() + str(d) for d in windows]
250250
if "volume" in config:
251251
windows = config["volume"].get("windows", range(5))
252-
fields += ["Ref($volume, %d)/$volume" % d if d != 0 else "$volume/$volume" for d in windows]
252+
fields += ["Ref($volume, %d)/($volume+1e-12)" % d if d != 0 else "$volume/($volume+1e-12)" for d in windows]
253253
names += ["VOLUME" + str(d) for d in windows]
254254
if "rolling" in config:
255255
windows = config["rolling"].get("windows", [5, 10, 20, 30, 60])

0 commit comments

Comments
 (0)