返回列表 发布新帖

002939.SZ get_financial_data 报 UnicodeDecodeError: 'utf-8' codec can't decode b

43 0
发表于 昨天 23:08 | 显示全部楼层 阅读模式
tests\xtquant\测试xtquant基本函数Test.py:101 (Test_xtQuant.test_get_financial)
self = <测试xtquant基本函数Test.Test_xtQuant testMethod=test_get_financial>

    def test_get_financial(self):
      client = xtdata.get_client()

      code = '600900.SH'
      # code = '001266.SZ'
      code = '002939.SZ'
      # code = '002397.SZ'
      # xtdata.download_financial_data(["000001.SZ", "600519.SH", "430017.BJ"])

      xtdata.download_financial_data2(stock_list=[code])
>     financial_data = xtdata.get_financial_data(stock_list=[code],
                                                 # table_list=["Balance", "Income"],
                                                 # start_time='20230101', end_time='20260101',
                                                 # report_type="announce_time"
                                                 report_type="report_time"
                                                 )

tests\xtquant\测试xtquant基本函数Test.py:111: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

stock_list = ['002939.SZ']
table_list = ['Balance', 'Income', 'CashFlow', 'Capital', 'HolderNum', 'Top10Holder', ...]
start_time = '', end_time = '', report_type = 'report_time'

    def get_financial_data(stock_list, table_list=[], start_time='', end_time='', report_type='report_time'):
        '''
         获取财务数据
        :param stock_list: (list)合约代码列表
        :param table_list: (list)报表名称列表
        :param start_time: (str)起始时间
        :param end_time: (str)结束时间
        :param report_type: (str) 时段筛选方式 'announce_time' / 'report_time'
        :return:
            field: list[str]
            date: list[int]
            stock: list[str]
            value: list[list[float]]
        '''
        client = get_client()
        all_table = {
            'Balance' : 'ASHAREBALANCESHEET'
            , 'Income' : 'ASHAREINCOME'
            , 'CashFlow' : 'ASHARECASHFLOW'
            , 'Capital' : 'CAPITALSTRUCTURE'
            , 'HolderNum' : 'SHAREHOLDER'
            , 'Top10Holder' : 'TOP10HOLDER'
            , 'Top10FlowHolder' : 'TOP10FLOWHOLDER'
            , 'PershareIndex' : 'PERSHAREINDEX'
        }

        if not table_list:
            table_list = list(all_table.keys())

        all_table_upper = {table.upper() : all_table[table] for table in all_table}
        req_list = []
        names = {}
        for table in table_list:
            req_table = all_table_upper.get(table.upper(), table)
            req_list.append(req_table)
            names[req_table] = table

        data = {}
        sl_len = 20
        stock_list2 = [stock_list[i : i + sl_len] for i in range(0, len(stock_list), sl_len)]
        for sl in stock_list2:
>           data2 = client.get_financial_data(sl, req_list, start_time, end_time, report_type)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E           UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 197-198: unexpected end of data

.venv\Lib\site-packages\xtquant\xtdata.py:359: UnicodeDecodeError

目前只有002939.SZ 有这个问题,其他的都是正常的

而且之前全部都是正常的,不会是这个股票最新的财报数据有问题吧?

已经试过删除本地文件后,下载再试,还是这样

试过了

image.png

这样是好的

就是这个股票的最新财务数据导致的报错

快点修复吧

回复

您需要登录后才可以回帖 登录 | 立即注册

客服专线

400-080-8112

用思考的速度交易,用真诚的态度合作,我们是认真的!
  • 关注公众号
  • 添加微信客服
Copyright © 2001-2026 迅投QMT社区 版权所有 All Rights Reserved. 京ICP备2025122616号-3
关灯 快速发帖
扫一扫添加微信客服
QQ客服返回顶部
快速回复 返回顶部 返回列表