Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

股票数据多线程下载的过程中,出现了异常:TypeError: __new__() got an unexpected keyword argument 'security_typeNa: ' #154

Open
Earlyu opened this issue Oct 25, 2023 · 1 comment

Comments

@Earlyu
Copy link

Earlyu commented Oct 25, 2023

堆栈信息:
File "F:\基础脚本\venv\lib\site-packages\efinance\stock\getter.py", line 233, in get_quote_history df = get_quote_history_for_stock( File "F:\基础脚本\venv\lib\site-packages\efinance\common\getter.py", line 204, in get_quote_history return get_quote_history_single(codes, File "F:\基础脚本\venv\lib\site-packages\efinance\utils\__init__.py", line 39, in run values = func(*args, **kwargs) File "F:\基础脚本\venv\lib\site-packages\efinance\common\getter.py", line 85, in get_quote_history_single quote_id = get_quote_id(code) File "F:\基础脚本\venv\lib\site-packages\decorator.py", line 232, in fun return caller(func, *(extras + args), **kw) File "F:\基础脚本\venv\lib\site-packages\retry\api.py", line 73, in retry_decorator return __retry_internal(partial(f, *args, **kwargs), exceptions, tries, delay, max_delay, backoff, jitter, File "F:\基础脚本\venv\lib\site-packages\retry\api.py", line 33, in __retry_internal return f() File "F:\基础脚本\venv\lib\site-packages\efinance\utils\__init__.py", line 88, in get_quote_id quote = search_quote(stock_code) File "F:\基础脚本\venv\lib\site-packages\efinance\utils\__init__.py", line 118, in search_quote quote = search_quote_locally(keyword) File "F:\基础脚本\venv\lib\site-packages\efinance\utils\__init__.py", line 168, in search_quote_locally quote = Quote(**_q) TypeError: __new__() got an unexpected keyword argument 'security_typeNa: '

报错的方法:
`
def search_quote_locally(keyword: str) -> Union[Quote, None]:
"""
在本地里面使用搜索记录进行关键词搜索

Parameters
----------
keyword : str
    搜索词

Returns
-------
Union[Quote,None]

"""
q = SEARCH_RESULT_DICT.get(keyword)
# NOTE 兼容旧版本 给缓存加上最后修改时间
if q is None or not q.get('last_time'):
    return None
last_time: float = q['last_time']
# 缓存过期秒数
max_ts = 3600 * 24 * 3
now = time.time()
# 缓存过期,在线搜索
if (now - last_time) > max_ts:
    return None
# NOTE 一定要拷贝 否则改变源对象
_q = q.copy()
# NOTE 一定要删除它 否则会构造错误
del _q['last_time']
quote = Quote(**_q)
return quote`

报错原因是未知参数;已知参数如下:

`

存储证券代码的实体

Quote = namedtuple('Quote', ['code', 'name', 'pinyin', 'id', 'jys', 'classify', 'market_type',
'security_typeName', 'security_type', 'mkt_num', 'type_us', 'quote_id', 'unified_code', 'inner_code'])
`
但后面的数据似乎来自数据来源,并我是我能修改的。
出现这个问题的原因未知,下载脚本已经用了很长时间,并未有修改,昨天开始出现问题,一开始以为是ip被封,今天在测试依然如此,并且,出现这个问题下载的股票,是不一定的?

文件目录: efinance\utils_init_.py

@Earlyu
Copy link
Author

Earlyu commented Oct 25, 2023

关键字是'security_typeNa: ',我没有写错,就是复制的security_typeName 少了me,字符串了还多了冒号 :

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant