From 1307d637ec639ff609d6326248cdd693c83211cb Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Fri, 15 Dec 2017 20:30:19 +0800 Subject: [PATCH] [Fix]Close #638 --- vnpy/trader/vtFunction.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 # 检查防止小数点位过多