掘金社区

新手问题Pinned highlighted

sgchen2000 发表在问题反馈 2020-08-26 23:17:08

问题反馈
118
3
0

简单写一个读取财务数据的测试总是报找不到pandas模块,不知是什么原因?
0_1598455006088_1545d6bd-3afd-4ef5-a3c1-18eeff32563c-image.png

有没有新手教程?

评论: 3
  • 没有安装gm, 手动安装下,在cmd里输入python.exe -m pip install gm -i https://pypi.doubanio.com/simple

    2020-08-28 16:38:09
  • @技术支持1
    提示是已经安装了的
    0_1598621372838_d0190262-ab8e-49da-86c3-f07818f80029-image.png

    上面的错误是在掘金客户端运行的时候报的。
    如果在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):
    pass

    if 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)
    2020-08-28 21:31:18
  • import pandas as pd

    2020-09-09 08:09:22

Looks like your connection to 掘金量化社区 - 量化交易者的策略交流学习社区 was lost, please wait while we try to reconnect.