{"action":"created","issue":{"url":"https://api.github.com/repos/vnpy/vnpy/issues/971","repository_url":"https://api.github.com/repos/vnpy/vnpy","labels_url":"https://api.github.com/repos/vnpy/vnpy/issues/971/labels{/name}","comments_url":"https://api.github.com/repos/vnpy/vnpy/issues/971/comments","events_url":"https://api.github.com/repos/vnpy/vnpy/issues/971/events","html_url":"https://github.com/vnpy/vnpy/issues/971","id":339232380,"node_id":"MDU6SXNzdWUzMzkyMzIzODA=","number":971,"title":"safeUnicode的完善","user":{"login":"miyihuxi","id":30117230,"node_id":"MDQ6VXNlcjMwMTE3MjMw","avatar_url":"https://avatars3.githubusercontent.com/u/30117230?v=4","gravatar_id":"","url":"https://api.github.com/users/miyihuxi","html_url":"https://github.com/miyihuxi","followers_url":"https://api.github.com/users/miyihuxi/followers","following_url":"https://api.github.com/users/miyihuxi/following{/other_user}","gists_url":"https://api.github.com/users/miyihuxi/gists{/gist_id}","starred_url":"https://api.github.com/users/miyihuxi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miyihuxi/subscriptions","organizations_url":"https://api.github.com/users/miyihuxi/orgs","repos_url":"https://api.github.com/users/miyihuxi/repos","events_url":"https://api.github.com/users/miyihuxi/events{/privacy}","received_events_url":"https://api.github.com/users/miyihuxi/received_events","type":"User","site_admin":false},"labels":[{"id":182220021,"node_id":"MDU6TGFiZWwxODIyMjAwMjE=","url":"https://api.github.com/repos/vnpy/vnpy/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-07-08T14:57:39Z","updated_at":"2018-07-18T08:48:20Z","closed_at":"2018-07-18T08:48:20Z","author_association":"NONE","body":"## 环境\r\n\r\n* 操作系统: 如Windows 7或者Ubuntu 16.04\r\n* Anaconda版本: 如Anaconda 4.0.0 Python 2.7 32位\r\n* vn.py版本: 如v1.7发行版或者dev branch 20170920（下载日期）\r\n\r\n## Issue类型\r\n三选一：Bug/Enhancement/Question\r\n\r\ndef safeUnicode(value):\r\n    \"\"\"检查接口数据潜在的错误，保证转化为的字符串正确\"\"\"\r\n    #float值为nan时出错，增加一个判断。\r\n    \r\n    def isnan(num):\r\n        return num != num\r\n\r\n    # 检查是数字接近0时会出现的浮点数上限\r\n    if type(value) is int or type(value) is float:\r\n        if value > MAX_NUMBER or isnan(value):\r\n            value = 0\r\n\r\n    # 检查防止小数点位过多\r\n    if type(value) is float:\r\n        print(value)\r\n        print(type(value))\r\n        d = decimal.Decimal(str(value))\r\n        print(d)\r\n        print(type(d))\r\n        if abs(d.as_tuple().exponent) > MAX_DECIMAL:\r\n            value = round(value, ndigits=MAX_DECIMAL)\r\n\r\n    return str(value)\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/vnpy/vnpy/issues/comments/405858248","html_url":"https://github.com/vnpy/vnpy/issues/971#issuecomment-405858248","issue_url":"https://api.github.com/repos/vnpy/vnpy/issues/971","id":405858248,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNTg1ODI0OA==","user":{"login":"vnpy","id":11263900,"node_id":"MDQ6VXNlcjExMjYzOTAw","avatar_url":"https://avatars0.githubusercontent.com/u/11263900?v=4","gravatar_id":"","url":"https://api.github.com/users/vnpy","html_url":"https://github.com/vnpy","followers_url":"https://api.github.com/users/vnpy/followers","following_url":"https://api.github.com/users/vnpy/following{/other_user}","gists_url":"https://api.github.com/users/vnpy/gists{/gist_id}","starred_url":"https://api.github.com/users/vnpy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vnpy/subscriptions","organizations_url":"https://api.github.com/users/vnpy/orgs","repos_url":"https://api.github.com/users/vnpy/repos","events_url":"https://api.github.com/users/vnpy/events{/privacy}","received_events_url":"https://api.github.com/users/vnpy/received_events","type":"User","site_admin":false},"created_at":"2018-07-18T08:48:20Z","updated_at":"2018-07-18T08:48:20Z","author_association":"OWNER","body":"检查了下，目前safeUnicode只使用在显示交易接口过来的原始数据上，几乎不会出现nan这种数据。\r\n\r\n如果用在了其他地方可能有nan的话，请根据需求来修改吧"}}
{"actor":{"display_login":"vnpy"}}