diff --git a/vnpy/trader/vtFunction.py b/vnpy/trader/vtFunction.py index acd7405c..dafee913 100644 --- a/vnpy/trader/vtFunction.py +++ b/vnpy/trader/vtFunction.py @@ -8,18 +8,18 @@ import os import decimal import json from datetime import datetime +from math import isnan MAX_NUMBER = 10000000000000 MAX_DECIMAL = 4 - #---------------------------------------------------------------------- def safeUnicode(value): """检查接口数据潜在的错误,保证转化为的字符串正确""" # 检查是数字接近0时会出现的浮点数上限 if type(value) is int or type(value) is float: - if value > MAX_NUMBER: + if value > MAX_NUMBER or isnan(value): value = 0 # 检查防止小数点位过多