Skip to main content

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

更多

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)

Source distribution for ashares 1.1
File Size Uploaded
ashares-1.1.macosx-10.9-x86_64.tar.gz 6.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ashares 1.1
File Interpreter ABI Platform
ashares-1.1-py3-none-any.whl Python 3 none any Details

Total release size: 12.4 kB

Release files / ashares-1.1.macosx-10.9-x86_64.tar.gz

Download URL ashares-1.1.macosx-10.9-x86_64.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
07bcc28b9c971c300830544afecf8921cd7dfdc718a5debd1d9b8667d216d8b5
BLAKE2b-256 checksum
How to use checksums
3c19233cbede5bd32ac1631bfdde4f11c498309147681efbe2cb5452fab6687d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.5

Release files / ashares-1.1-py3-none-any.whl

Download URL ashares-1.1-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
148953522518b798ba4c3ae46084ac946558fc2100fd49be4da0d98de4635dac
BLAKE2b-256 checksum
How to use checksums
90ba7cbfda7372ea9bb2dfca1e83bb26767b28acc83f62f55725a7e58e5fc9bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.5

Release history Release notifications | RSS feed

This release

1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page