Micro-sheep / Micro-sheep/efinance
股票数据多线程下载的过程中,出现了异常:TypeError: __new__() got an unexpected keyword argument 'security_typeNa: '
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.1k
- Forks
- 755
- PR merge metrics
- No merged PRs in 30d
Description
堆栈信息:
`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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in efinance/utils/__init__.py at search_quote_locally and inspect how cached search results are converted into Quote. Reproduce the stock-history download failure with a cached result containing the unexpected security_typeNa key, then verify the handling of that result no longer raises TypeError and add or run a focused regression test if the repository provides one.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100