waditu / tushare

TuShare is a utility for crawling historical data of China stocks
BSD 3-Clause "New" or "Revised" License
12.79k stars 4.28k forks source link

trade_cal显示没有权限访问该接口,以及exception在python2下报错 #1205

Closed asukagit closed 4 years ago

asukagit commented 4 years ago

执行以下代码:

import tushare as ts
ts.set_token(my_token)
pro = ts.pro_api()
pro.trade_cal(exchange='', start_date='20180101', end_date='20181231')

返回如下内容:

Traceback (most recent call last): File "", line 1, in File "xxxx/lib/python2.7/site-packages/tushare/pro/client.py", line 43, in query raise Exception(result['msg']) Exception: <exception str() failed>

通过修改client.py 代码,打印result,得到如下内容:

{u'msg': u'\u62b1\u6b49\uff0c\u60a8\u6ca1\u6709\u6743\u9650\u8bbf\u95ee\u8be5\u63a5\u53e3\uff0c\u6743\u9650\u7684\u5177\u4f53\u8be6\u60c5\u8bbf\u95ee\uff1ahttps://tushare.pro/document/1?doc_id=108\u3002', u'code': -2002, u'data': None, u'request_id': u'5f092cd20f9311ea8d684f35110e99121574693621726767'}

msg: 抱歉,您没有权限访问该接口,权限的具体详情访问:https://tushare.pro/document/1?doc_id=108

我看文档里面没有说这个接口需要积分要求,请问这是什么问题,试了下访问同样没写积分要求的stock_basic接口能够返回数据。

还有在python2下,如果msg里面有非ascii的unicode会报错,转成utf-8正常

raise Exception(result['msg'].encode('utf-8')) Traceback (most recent call last): File "", line 1, in Exception: 抱歉,您没有权限访问该接口,权限的具体详情访问:https://tushare.pro/document/1?doc_id=108

raise Exception(result['msg']) Traceback (most recent call last): File "", line 1, in Exception: <exception str() failed>

tushare的id号是这个?reg=326905

jimmysoa commented 4 years ago

积分问题,可以适当提高积分