pip install lixinger-openapi
pip install git+http://github.com/ShekiLyu/lixinger-openapi.git
pip install --upgrade lixinger-openapi
pip install --upgrade git+http://github.com/ShekiLyu/lixinger-openapi.git
接口名 | 接口功能 |
---|---|
set_token | 设置token |
query_json | 查询数据(json格式) |
query_dataframe | 查询数据(dataframe格式) |
import lixinger_openapi as lo
lo.set_token("your_token")
set_token会目录下生成token.cfg文件保存token,所以在当前目录只需加载一次。如果不想写token.cfg文件,可以如下设置:
lo.set_token("your_token", write_token=False)
json_rlt = lo.query_json('a.stock.fundamental.non_financial',
{
"date": "2018-01-19",
"stockCodes": [
"000028",
"600511"
],
"metricsList": [
"pe_ttm",
"mc"
]
})
print(json_rlt)
{'data': [{'date': '2018-01-19T00:00:00+08:00', 'pe_ttm': 21.046568599508507, 'stockCode': '000028', 'mc': 26663748314.4}, {'date': '2018-01-19T00:00:00+08:00', 'pe_ttm': 21.459988206744743, 'stockCode': '600511', 'mc': 20346751061}], 'code': 0, 'msg': 'success'}
dataframe_rlt = lo.query_dataframe('a.stock.fundamental.non_financial',
{
"date": "2018-01-19",
"metricsList": ["pe_ttm", "mc"],
"stockCodes": ["000028", "600511"]
})
print('code: '+ str(dataframe_rlt['code']))
print('\ndata:')
print(dataframe_rlt['data'])
print('\nmsg: ' + dataframe_rlt['msg'])
code: 0
data:
date mc pe_ttm stockCode
0 2018-01-19T00:00:00+08:00 2.666375e+10 21.046569 000028
1 2018-01-19T00:00:00+08:00 2.034675e+10 21.459988 600511
msg: success
json_rlt = lo.query_json('a.index', {
"stockCodes": [
"000016"
]
})
print(json_rlt)
{'data': [{'source': 'sh', 'cnName': '上证50', 'publishDate': '2004-01-01T16:00:00.000Z', 'stockCode': '000016', 'areaCode': 'cn', 'market': 'a'}], 'code': 0, 'msg': 'success'}
dataframe_rlt = lo.query_dataframe('a.index', {
"stockCodes": [
"000016"
]
})
print('code: '+ str(dataframe_rlt['code']))
print('\ndata:')
print(dataframe_rlt['data'])
print('\nmsg: ' + dataframe_rlt['msg'])
code: 0
data:
areaCode cnName market publishDate source stockCode
0 cn 上证50 a 2004-01-01T16:00:00.000Z sh 000016
msg: success