waditu / tushare

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

使用了set_token之后,不传pro_api参数报错,与文档说明不符。 #806

Open julycoolwind opened 6 years ago

julycoolwind commented 6 years ago
 import tushare as ts
 ts.set_token('affae7ca8011b231e31**************377fc6f')
 df = ts.pro_bar(ts_code='000001.SZ',start_date='19990101', end_date='', adj='qfq')  Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/tushare/pro/data_pro.py", line 67, in pro_bar
    api = pro_api if pro_api is not None else pro_api()
TypeError: 'NoneType' object is not callable

平台账号:julycoolwind@hotmail.com

nfang commented 6 years ago

未初始化接口。

...
ts.set_token('xxxxxx')
pro = ts.pro_api()
df = pro.pro_bar(ts_code='000001.SZ')
...

cf. 调取pro版数据

liyanglzu commented 5 years ago

接楼上,实际上是有个官方说非必须的参数(pro_api | str | N | pro版api对象)未能获得参数传入。 可以如此修改: api = ts.pro_api('affae7ca8011b231e31**377fc6f') df = ts.pro_bar(pro_api=api,ts_code='000001.SZ',start_date='19990101', end_date='', adj='qfq') 嗯,楼主比较懒,就是官方的调用方式。不过官方用例都是指定了pro_api的值的 另外哈,本人比较喜欢每次都设置自己的token,所以每次初始化时都会有pro=ts.pro_api(mytoken)的操作,顺便测试了楼上的方法,好像不传入pro_api是不行的。嗯,也有可能是我使用有误。

jimmysoa commented 5 years ago

是mac系统吗? @julycoolwind