股票行情实时数据接口-A股,完全免费的沪深证券股票数据-中国股市,python最简封装的API接口

Overview

Ashare (免费 开源 极简 A股实时行情数据API)

中国股市A股股票行情实时数据最简封装API接口,包含日线,分时分钟线,全部格式成DataFrame格式数据,可用来研究,量化分析,证券股票程序化自动化交易系统 行情系统包括新浪腾讯双数据核心,自动故障切换,为量化研究者在数据获取方面极大地减轻工作量,更加专注于策略和模型的研究与实现。

功能特点

  • 核心库轻量化:项目库就一个文件Ashare.py,不用安装设置,可自由裁剪,随用随走 from Ashare import * 即可

  • 双内核封装,新浪财经,腾讯股票的实时行情数据,包括任意历史日线,周线,月线,分钟线,小时线等,已经稳定运行数年

  • 双内核一主一备,自动热备,自动切换,Ashare即使用来做量化实盘行情源也可以满足。

  • 全部数据格式清理成DataFrame格式数据,让您非常方便的使用pandas来分析和处理

  • 和其他行情库(tushare等)比的优点是什么? -- 简单 轻量 便携 免费 开源

  • Ashare把复杂的数据获取,拆分,整合逻辑全部封装成一个函数 get_price() 看完下面例子就会了

  • Ashare可以用在任何需要量化研究,量化分析的场合

先看一个最简单的例子 Demo1.py

from  Ashare import *
    
# 证券代码兼容多种格式 通达信,同花顺,聚宽
# 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)
#上证指数日线行情----------------------------------------------------
              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

再看一个配合MyTT的例子 Demo2.py

#股市行情数据获取和作图 -2
from  Ashare import *          #股票数据库    https://github.com/mpquant/Ashare
from  MyTT import *            #myTT麦语言工具函数指标库  https://github.com/mpquant/MyTT
    
# 证券代码兼容多种格式 通达信,同花顺,聚宽
# sh000001 (000001.XSHG)    sz399006 (399006.XSHE)   sh600519 ( 600519.XSHG ) 

df=get_price('000001.XSHG',frequency='1d',count=120)      #获取今天往前120天的日线实时行情
print('上证指数日线行情\n',df.tail(5))

#-------有数据了,下面开始正题 -------------
CLOSE=df.close.values;         OPEN=df.open.values           #基础数据定义,只要传入的是序列都可以 
HIGH=df.high.values;           LOW=df.low.values             #例如  CLOSE=list(df.close) 都是一样     

MA5=MA(CLOSE,5)                                #获取5日均线序列
MA10=MA(CLOSE,10)                              #获取10日均线序列
up,mid,lower=BOLL(CLOSE)                       #获取布林带指标数据

#-------------------------作图显示-----------------------------------------------------------------
import matplotlib.pyplot as plt ;  from matplotlib.ticker import MultipleLocator
plt.figure(figsize=(15,8))  
plt.plot(CLOSE,label='SHZS');    plt.plot(up,label='UP');           #画图显示 
plt.plot(mid,label='MID');       plt.plot(lower,label='LOW');
plt.plot(MA10,label='MA10',linewidth=0.5,alpha=0.7);
plt.show()
boll

团队其他开源项目 - 如果本项目能帮助到您,请右上角帮我们点亮 ★star 以示鼓励!

巴特量化

  • 数字货币 股市量化工具 行情系统软件开发 通达信同花顺公式开发 python量化系统开发

  • BTC虚拟货币量化交易策略开发 自动化交易策略运行


加入群聊

股市程序化交易大群,数字货币量化交易探讨, 圈内大咖量化策略分享

全是干货,无闲聊 ,物以类聚,人以群分,一起感受思维碰撞的力量!

HW 2: Visualizing interesting datasets

HW 2: Visualizing interesting datasets Check out the project instructions here! Mean Earnings per Hour for Males and Females My first graph uses data

7 Oct 27, 2021
Scientific Visualization: Python + Matplotlib

An open access book on scientific visualization using python and matplotlib

Nicolas P. Rougier 8.6k Dec 31, 2022
A way of looking at COVID-19 data that I haven't seen before.

Visualizing Omicron: COVID-19 Deaths vs. Cases Click here for other countries. Data is from Our World in Data/Johns Hopkins University. About this pro

1 Jan 10, 2022
Create HTML profiling reports from pandas DataFrame objects

Pandas Profiling Documentation | Slack | Stack Overflow Generates profile reports from a pandas DataFrame. The pandas df.describe() function is great

10k Jan 01, 2023
Analysis and plotting for motor/prop/ESC characterization, thrust vs RPM and torque vs thrust

esc_test This is a Python package used to plot and analyze data collected for the purpose of characterizing a particular propeller, motor, and ESC con

Alex Spitzer 1 Dec 28, 2021
Designed a greedy algorithm based on Markov sequential decision-making process in MATLAB/Python to optimize using Gurobi solver

Designed a greedy algorithm based on Markov sequential decision-making process in MATLAB/Python to optimize using Gurobi solver, the wheel size, gear shifting sequence by modeling drivetrain constrai

Sabbella Prasanna 1 Jan 11, 2022
This project is created to visualize the system statistics such as memory usage, CPU usage, memory accessible by process and much more using Kibana Dashboard with Elasticsearch.

System Stats Visualizer This project is created to visualize the system statistics such as memory usage, CPU usage, memory accessible by process and m

Vishal Teotia 5 Feb 06, 2022
Tools for exploratory data analysis in Python

Dora Exploratory data analysis toolkit for Python. Contents Summary Setup Usage Reading Data & Configuration Cleaning Feature Selection & Extraction V

Nathan Epstein 599 Dec 25, 2022
PyFlow is a general purpose visual scripting framework for python

PyFlow is a general purpose visual scripting framework for python. State Base structure of program implemented, such things as packages disco

1.8k Jan 07, 2023
Script to create an animated data visualisation for categorical timeseries data - GIF choropleth map with annotations.

choropleth_ldn Simple script to create a chloropleth map of London with categorical timeseries data. The script in main.py creates a gif of the most f

1 Oct 07, 2021
Shaded 😎 quantile plots

shadyquant 😎 This python package allows you to quantile and plot lines where you have multiple samples, typically for visualizing uncertainty. Your d

Mehrad Ansari 13 Sep 29, 2022
Fast data visualization and GUI tools for scientific / engineering applications

PyQtGraph A pure-Python graphics library for PyQt5/PyQt6/PySide2/PySide6 Copyright 2020 Luke Campagnola, University of North Carolina at Chapel Hill h

pyqtgraph 3.1k Jan 08, 2023
Data visualization electromagnetic spectrum

Datenvisualisierung-Elektromagnetischen-Spektrum Anhand des Moduls matplotlib sollen die Daten des elektromagnetischen Spektrums dargestellt werden. D

Pulsar 1 Sep 01, 2022
Data Visualizations for the #30DayChartChallenge

The #30DayChartChallenge This repository contains all the charts made for the #30DayChartChallenge during the month of April. This project aims to exp

Isaac Arroyo 7 Sep 20, 2022
Matplotlib tutorial for beginner

matplotlib is probably the single most used Python package for 2D-graphics. It provides both a very quick way to visualize data from Python and publication-quality figures in many formats. We are goi

Nicolas P. Rougier 2.6k Dec 28, 2022
Regress.me is an easy to use data visualization tool powered by Dash/Plotly.

Regress.me Regress.me is an easy to use data visualization tool powered by Dash/Plotly. Regress.me.-.Google.Chrome.2022-05-10.15-58-59.mp4 Get Started

Amar 14 Aug 14, 2022
Open-source demos hosted on Dash Gallery

Dash Sample Apps This repository hosts the code for over 100 open-source Dash apps written in Python or R. They can serve as a starting point for your

Plotly 2.7k Jan 07, 2023
Generate visualizations of GitHub user and repository statistics using GitHub Actions.

GitHub Stats Visualization Generate visualizations of GitHub user and repository statistics using GitHub Actions. This project is currently a work-in-

Aditya Thakekar 1 Jan 11, 2022
Automatically generate GitHub activity!

Commit Bot Automatically generate GitHub activity! We've all wanted to be the developer that commits every day, but that requires a lot of work. Let's

Ricky 4 Jun 07, 2022
ICS-Visualizer is an interactive Industrial Control Systems (ICS) network graph that contains up-to-date ICS metadata

ICS-Visualizer is an interactive Industrial Control Systems (ICS) network graph that contains up-to-date ICS metadata (Name, company, port, user manua

QeeqBox 2 Dec 13, 2021