掘金社区
简单写一个读取财务数据的测试总是报找不到pandas模块,不知是什么原因?
有没有新手教程?
-
没有安装gm, 手动安装下,在cmd里输入python.exe -m pip install gm -i https://pypi.doubanio.com/simple
-
@技术支持1
提示是已经安装了的
上面的错误是在掘金客户端运行的时候报的。
如果在vscode中运行,显示的是以下错误:
2020-08-28 21:28:53,974 WARNING [fundamental.py:68] error code=1000, error info=错误或无效的token
2020-08-28 21:28:53,978 WARNING [fundamental.py:68] error code=1000, error info=错误或无效的token
2020-08-28 21:28:53,981 WARNING [fundamental.py:68] error code=1000, error info=错误或无效的token
2020-08-28 21:28:53,982 ERROR [query.py:92] 获取不到基本面服务地址
Traceback (most recent call last):
File "C:\Users\cym\AppData\Roaming\Python\Python37\site-packages\gm\api\query.py", line 50, in wrapper
return func(*args, **kw)
File "C:\Users\cym\AppData\Roaming\Python\Python37\site-packages\gm\retrying.py", line 37, in wrapped_f
return Retrying(*dargs, **dkw).call(f, *args, **kw)
File "C:\Users\cym\AppData\Roaming\Python\Python37\site-packages\gm\retrying.py", line 201, in call
raise attempt.get()
File "C:\Users\cym\AppData\Roaming\Python\Python37\site-packages\gm\retrying.py", line 239, in get
six.reraise(self.value[0], self.value[1], self.value[2])
File "C:\Users\cym\AppData\Roaming\Python\Python37\site-packages\six.py", line 703, in reraise
raise value
File "C:\Users\cym\AppData\Roaming\Python\Python37\site-packages\gm\retrying.py", line 189, in call
attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
File "C:\Users\cym\AppData\Roaming\Python\Python37\site-packages\gm\api\query.py", line 118, in get_fundamentals
limit=limit)
File "C:\Users\cym\AppData\Roaming\Python\Python37\site-packages\gm\model\fundamental.py", line 87, in get_fundamentals
self._init_addr()
File "C:\Users\cym\AppData\Roaming\Python\Python37\site-packages\gm\model\fundamental.py", line 70, in _init_addr
raise EnvironmentError("获取不到基本面服务地址")
OSError: 获取不到基本面服务地址
[]代码如下:
coding=utf-8
from future import print_function, absolute_import
from gm.api import *策略中必须有init方法
def init(context):
passif name == 'main':
#run(strategy_id='f189c2b5-e6e2-11ea-86bb-4c72b9acd97f',
# filename='main.py',
# mode=MODE_BACKTEST,
# token='b884dd0e52daf072ca7e5ff6ef7aa655b5ede3a5',
# backtest_start_time='2016-06-17 13:00:00',
# backtest_end_time='2017-08-21 15:00:00')my_symbols = ['SHSE.600000', 'SZSE.000001'] df = get_fundamentals(table='balance_sheet', start_date='2016-01-20', end_date='2016-01-20', fields='CURFDS, SETTRESEDEPO, PLAC, TRADFINASSET, ', symbols=my_symbols, filter='CURFDS > 0 and TOTLIABSHAREQUI > 0' ) print(df)
-
import pandas as pd
-
@sgchen2000 检查下token是否正确,token在终端头像的系统设置里