ashares
代码非原创,是对项目Ashare的封装, 中国股市A股股票行情实时数据最简封装API接口, 包含日线,分时分钟线,全部格式成DataFrame格式数据,可用来研究,量化分析,证券股票程序化自动化交易系统 行情系统包括新浪腾讯双数据核心,自动故障切换,为量化研究者在数据获取方面极大地减轻工作量,更加专注于策略和模型的研究与实现。
功能特点
- 双内核封装,新浪财经,腾讯股票的实时行情数据,包括任意历史日线,周线,月线,分钟线,小时线等,已经稳定运行数年
- 双内核一主一备,自动热备,自动切换,Ashare即使用来做量化实盘行情源也可以满足。
- 全部数据格式清理成DataFrame格式数据,让您非常方便的使用pandas来分析和处理
- 和其他行情库(tushare等)比的优点是什么? -- 简单 轻量 便携 开源
- Ashare把复杂的数据获取,拆分,整合逻辑全部封装成一个函数
get_price()看完下面例子就会了 - Ashare可以用在任何需要量化研究,量化分析的场合
安装
pip install akshares
快速上手
from ashares import get_price,
# 证券代码兼容多种格式 通达信,同花顺,聚宽
# sh000001 (000001.XSHG) sz399006 (399006.XSHE) sh600519 ( 600519.XSHG )
df=get_price('sh000001', frequency='1d', count=5) #默认获取今天往前5天的日线实时行情
print('上证指数日线行情\n',df)
df=get_price('000001.XSHG',frequency='1d',count=5,end_date='2021-04-30') #可以指定结束日期,获取历史行情
print('上证指数历史行情\n',df)
df=get_price('000001.XSHG',frequency='1w',count=5,end_date='2018-06-15') #支持'1d'日, '1w'周, '1M'月
print('上证指数历史周线\n',df)
df=get_price('sh600519',frequency='15m',count=5) #分钟线实时行情,可用'1m','5m','15m','30m','60m'
print('贵州茅台15分钟线\n',df)
df=get_price('600519.XSHG',frequency='60m',count=6) #分钟线实时行情,可用'1m','5m','15m','30m','60m'
print('贵州茅台60分钟线\n',df)
Run
#上证指数日线行情----------------------------------------------------
open close high low volume
2021-06-07 3597.14 3599.54 3600.38 3581.90 303718677.0
2021-06-08 3598.75 3580.11 3621.52 3563.25 304491470.0
2021-06-09 3576.80 3591.40 3598.71 3572.64 298323296.0
2021-06-10 3587.53 3610.86 3624.34 3584.13 318174808.0
2021-06-11 3614.11 3589.75 3614.40 3587.15 360554970.0
#贵州茅台60分钟线----------------------------------------------------
open close high low volume
2021-06-10 14:00:00 2237.00 2224.16 2245.00 2222.00 4541.53
2021-06-10 15:00:00 2222.21 2238.48 2240.34 2222.21 4146.88
2021-06-11 10:30:00 2239.00 2220.00 2244.00 2197.86 12030.00
2021-06-11 11:30:00 2220.01 2210.18 2231.80 2200.18 4868.00
2021-06-11 14:00:00 2210.10 2223.35 2224.48 2206.01 4544.00
2021-06-11 15:00:00 2223.33 2178.81 2226.80 2178.81 12529.00
更多
-
公众号:大邓和他的python
Metadata
Release files for ashares 1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ashares-1.1.macosx-10.9-x86_64.tar.gz | 6.5 kB | Without provenance | Details for ashares-1.1.macosx-10.9-x86_64.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ashares-1.1-py3-none-any.whl | Python 3 | none | any | Details for ashares-1.1-py3-none-any.whl |
Total release size: 12.4 kB
Security for ashares 1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.