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

关于「名称」或「code」重名时,查询结果和期望不一致的疑问? #176

Open
iamjackie opened this issue May 16, 2024 · 4 comments

Comments

@iamjackie
Copy link

iamjackie commented May 16, 2024

当我要查询的「代码」或者「名称」重名了,指向了两个不同的股票/指数的时候,好像永远只能获取到其中固定的一个结果。
market_type并不能解决问题?(1:market_type和ef.utils.search_quote中获取的market_type并不是同一个东西;2:现有手段其实并不能查询到某一个股票的market_type是什么,我都不知道,那更没法用market_type来查询了)

那如何才能获取所有的结果呢?或者如何才能拿到期望的值?

看源代码,好像最终都是通过quote_id去查询的数据,但封装的接口好像不支持用quote_id去查询各类数据。
那如果处理重名问题呀?请不吝赐教,非常感谢!

譬如:
1.查询【000100】,可能期望是:
[
{
"code": "000100",
"name": "TCL科技",
"pinyin": "TCLKJ",
"id": "0001002",
"jys": "6",
"classify": "AStock",
"market_type": "2",
"security_typeName": "深A",
"security_type": "2",
"mkt_num": "0",
"type_us": "6",
"quote_id": "0.000100",
"unified_code": "000100",
"inner_code": "35851998011206"
},
{
"code": "000100",
"name": "上证F500",
"pinyin": "SZF500",
"id": "0001001",
"jys": "1",
"classify": "Index",
"market_type": "1",
"security_typeName": "指数",
"security_type": "5",
"mkt_num": "1",
"type_us": "1",
"quote_id": "1.000100",
"unified_code": "000100",
"inner_code": "29676111691840"
}
]

2.查询【中证500】,可能是:
[
{
"value": "1.000905",
"code": "000905",
"name": "中证500",
"pinyin": "ZZ500",
"id": "0009051",
"jys": "1",
"classify": "Index",
"market_type": "1",
"security_typeName": "指数",
"security_type": "5",
"mkt_num": "1",
"type_us": "1",
"quote_id": "1.000905",
"unified_code": "000905",
"inner_code": "47193402436496"
},
{
"value": "0.399905",
"code": "399905",
"name": "中证500",
"pinyin": "ZZ500",
"id": "3999052",
"jys": "5",
"classify": "Index",
"market_type": "2",
"security_typeName": "指数",
"security_type": "5",
"mkt_num": "0",
"type_us": "5",
"quote_id": "0.399905",
"unified_code": "399905",
"inner_code": "23230172814944"
},
{
"value": "90.BK0701",
"code": "BK0701",
"name": "中证500",
"pinyin": "ZZ500",
"id": "BK07011",
"jys": "3",
"classify": "BK",
"market_type": "1",
"security_typeName": "板块",
"security_type": "9",
"mkt_num": "90",
"type_us": "3",
"quote_id": "90.BK0701",
"unified_code": "BK0701",
"inner_code": "24950575717760"
}
]

@BranChai
Copy link

不要用代码查,使用名字查试试,例如上证50代码时000016,不要使用000016,而是直接使用【上证50】
efinance.stock.get_quote_history('上证50')

@iamjackie
Copy link
Author

不要用代码查,使用名字查试试,例如上证50代码时000016,不要使用000016,而是直接使用【上证50】 efinance.stock.get_quote_history('上证50')

股票名也会有重名的,譬如沪深300ETF,其实对应了多个股票代码的不同股票。

@BranChai
Copy link

BranChai commented Jun 14, 2024

我想到的两种办法,一种是把名称尽量补全,第二种是限定market_type,比如ef.stock.get_quote_history('000016', market_type=MarketType.A_stock_index),这样只会获取上证50指数

@BranChai
Copy link

BranChai commented Jul 31, 2024

df=ef.stock.get_quote_history('1.000688',beg='20240709',end='20240709',
klt =101,fqt =2,
quote_id_mode=True
)

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

2 participants