{"id":20923466,"url":"https://github.com/mpquant/ashare","last_synced_at":"2025-05-14T09:06:24.552Z","repository":{"id":37399068,"uuid":"376044850","full_name":"mpquant/Ashare","owner":"mpquant","description":"股票行情实时数据接口-A股,完全免费的沪深证券股票数据-中国股市,python最简封装的API接口,包含日线,历史K线,分时线,分钟线,全部实时采集，系统包括新浪腾讯双数据核心采集获取，自动故障切换，STOCK数据格式成DataFrame格式,可用来查询研究量化分析，股票程序自动化交易系统.为量化研究者在数据获取方面极大地减轻工作量，更加专注于策略和模型的研究与实现。","archived":false,"fork":false,"pushed_at":"2025-01-17T09:12:13.000Z","size":177,"stargazers_count":2190,"open_issues_count":16,"forks_count":488,"subscribers_count":23,"default_branch":"main","last_synced_at":"2025-04-14T19:54:00.815Z","etag":null,"topics":["python","quant","stock","tushare"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mpquant.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-11T14:06:17.000Z","updated_at":"2025-04-14T08:34:31.000Z","dependencies_parsed_at":"2025-01-12T18:00:45.138Z","dependency_job_id":"0230a759-7c1e-4221-b66a-243604cf12f3","html_url":"https://github.com/mpquant/Ashare","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpquant%2FAshare","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpquant%2FAshare/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpquant%2FAshare/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpquant%2FAshare/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mpquant","download_url":"https://codeload.github.com/mpquant/Ashare/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254110374,"owners_count":22016391,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","quant","stock","tushare"],"created_at":"2024-11-18T20:15:58.759Z","updated_at":"2025-05-14T09:06:24.518Z","avatar_url":"https://github.com/mpquant.png","language":"Python","readme":"# Ashare ( 开源 极简 A股实时行情数据API)\n\n中国股市A股股票行情实时数据最简封装API接口,包含日线,分时分钟线,全部格式成DataFrame格式数据,可用来研究，量化分析，证券股票程序化自动化交易系统\n行情系统包括新浪腾讯双数据核心，自动故障切换，为量化研究者在数据获取方面极大地减轻工作量，更加专注于策略和模型的研究与实现。\n\n功能特点\n---\n* 核心库轻量化:项目库就一个文件Ashare.py,不用安装设置，可自由裁剪，随用随走 `from Ashare import *` 即可\n\n* 双内核封装，新浪财经，腾讯股票的实时行情数据，包括任意历史日线，周线，月线，分钟线，小时线等，已经稳定运行数年\n\n* 双内核一主一备，自动热备，自动切换，Ashare即使用来做量化实盘行情源也可以满足。\n\n* 全部数据格式清理成DataFrame格式数据，让您非常方便的使用pandas来分析和处理\n\n* 和其他行情库（tushare等）比的优点是什么？ --  简单 轻量  便携   开源\n\n* Ashare把复杂的数据获取，拆分，整合逻辑全部封装成一个函数 `get_price()` 看完下面例子就会了 \n\n* Ashare可以用在任何需要量化研究，量化分析的场合\n\n\n\n### 先看一个最简单的例子 [Demo1.py](https://github.com/mpquant/Ashare/blob/main/Demo1.py)\n\n```python\nfrom  Ashare import *\n    \n# 证券代码兼容多种格式 通达信，同花顺，聚宽\n# sh000001 (000001.XSHG)    sz399006 (399006.XSHE)   sh600519 ( 600519.XSHG ) \n\ndf=get_price('sh000001',frequency='1d',count=5)      #默认获取今天往前5天的日线实时行情\nprint('上证指数日线行情\\n',df)\n\ndf=get_price('000001.XSHG',frequency='1d',count=5,end_date='2021-04-30')  #可以指定结束日期，获取历史行情\nprint('上证指数历史行情\\n',df)                        \n\ndf=get_price('000001.XSHG',frequency='1w',count=5,end_date='2018-06-15')  #支持'1d'日, '1w'周,  '1M'月  \nprint('上证指数历史周线\\n',df) \n\ndf=get_price('sh600519',frequency='15m',count=5)     #分钟线实时行情，可用'1m','5m','15m','30m','60m'\nprint('贵州茅台15分钟线\\n',df)\n\ndf=get_price('600519.XSHG',frequency='60m',count=6)  #分钟线实时行情，可用'1m','5m','15m','30m','60m'\nprint('贵州茅台60分钟线\\n',df)\n```\n\n\n\n```\n#上证指数日线行情----------------------------------------------------\n              open    close     high      low       volume\n2021-06-07  3597.14  3599.54  3600.38  3581.90  303718677.0\n2021-06-08  3598.75  3580.11  3621.52  3563.25  304491470.0\n2021-06-09  3576.80  3591.40  3598.71  3572.64  298323296.0\n2021-06-10  3587.53  3610.86  3624.34  3584.13  318174808.0\n2021-06-11  3614.11  3589.75  3614.40  3587.15  360554970.0\n\n\n#贵州茅台60分钟线----------------------------------------------------\n                       open    close     high      low    volume\n2021-06-10 14:00:00  2237.00  2224.16  2245.00  2222.00   4541.53\n2021-06-10 15:00:00  2222.21  2238.48  2240.34  2222.21   4146.88\n2021-06-11 10:30:00  2239.00  2220.00  2244.00  2197.86  12030.00\n2021-06-11 11:30:00  2220.01  2210.18  2231.80  2200.18   4868.00\n2021-06-11 14:00:00  2210.10  2223.35  2224.48  2206.01   4544.00\n2021-06-11 15:00:00  2223.33  2178.81  2226.80  2178.81  12529.00\n```\n\n\n### 再看一个配合[MyTT](https://github.com/mpquant/MyTT)的例子 [Demo2.py](https://github.com/mpquant/Ashare/blob/main/Demo2.py)\n\n```python\n#股市行情数据获取和作图 -2\nfrom  Ashare import *          #股票数据库    https://github.com/mpquant/Ashare\nfrom  MyTT import *            #myTT麦语言工具函数指标库  https://github.com/mpquant/MyTT\n    \n# 证券代码兼容多种格式 通达信，同花顺，聚宽\n# sh000001 (000001.XSHG)    sz399006 (399006.XSHE)   sh600519 ( 600519.XSHG ) \n\ndf=get_price('000001.XSHG',frequency='1d',count=120)      #获取今天往前120天的日线实时行情\nprint('上证指数日线行情\\n',df.tail(5))\n\n#-------有数据了，下面开始正题 -------------\nCLOSE=df.close.values;         OPEN=df.open.values           #基础数据定义，只要传入的是序列都可以 \nHIGH=df.high.values;           LOW=df.low.values             #例如  CLOSE=list(df.close) 都是一样     \n\nMA5=MA(CLOSE,5)                                #获取5日均线序列\nMA10=MA(CLOSE,10)                              #获取10日均线序列\nup,mid,lower=BOLL(CLOSE)                       #获取布林带指标数据\n\n#-------------------------作图显示-----------------------------------------------------------------\nimport matplotlib.pyplot as plt ;  from matplotlib.ticker import MultipleLocator\nplt.figure(figsize=(15,8))  \nplt.plot(CLOSE,label='SHZS');    plt.plot(up,label='UP');           #画图显示 \nplt.plot(mid,label='MID');       plt.plot(lower,label='LOW');\nplt.plot(MA10,label='MA10',linewidth=0.5,alpha=0.7);\nplt.show()\n```\n\n\u003cdiv  align=\"center\"\u003e \u003cimg src=\"/img/sh_boll.png\" width = \"960\" height = \"480\" alt=\"boll\" /\u003e \u003c/div\u003e\n\n\n----------------------------------------------------\n### 团队其他开源项目 - 如果本项目能帮助到您，请右上角帮我们点亮 ★star 以示鼓励！\n* [MyTT 通达信,同花顺公式指标，文华麦语言的python实现](https://github.com/mpquant/MyTT)\n\n* [Ashare最简股票行情数据接口API,A股行情完全开源免费](https://github.com/mpquant/Ashare)\n\n----------------------------------------------------\n\n![加入群聊](https://github.com/mpquant/Ashare/blob/main/img/qrcode.png) \n\n\u003e #### 股市程序化交易大群, 圈内大咖量化策略分享\n\u003e #### 全是干货，无闲聊 ，物以类聚,人以群分，一起感受思维碰撞的力量!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpquant%2Fashare","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmpquant%2Fashare","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpquant%2Fashare/lists"}