百度云域名怎么做网站,做配单ic去什么网站好,wordpress如何关闭网站,襄阳seo顾问最最近一两年内#xff0c;股票量化分析逐渐成为热门话题。而从事这一领域工作的第一步#xff0c;就是获取全面且准确的股票数据。因为无论是实时交易数据、历史交易记录、财务数据还是基本面信息#xff0c;这些数据都是我们进行量化分析时不可或缺的宝贵资源。我们的主要…最最近一两年内股票量化分析逐渐成为热门话题。而从事这一领域工作的第一步就是获取全面且准确的股票数据。因为无论是实时交易数据、历史交易记录、财务数据还是基本面信息这些数据都是我们进行量化分析时不可或缺的宝贵资源。我们的主要任务是从这些数据中提炼出有价值的信息为我们的投资策略提供有力的指导。
在数据探索的旅途中我尝试了多种方法包括自编网易股票页面爬虫、申万行业数据爬虫以及同花顺问财的爬虫甚至还使用了聚宽的免费数据API。然而爬虫作为数据源常常显得不够稳定给我们的量化分析带来不小的困扰。
在量化分析领域实时且准确的数据接口是成功的基石。经过多次实际测试我将已确认可用的数据接口分享给正在从事量化分析的朋友们希望能够对你们的研究和工作有所帮助接下来我会用Python、JavaScriptNode.js、Java、C#和Ruby五种主流语言的实例代码给大家逐一演示一下如何获取各类股票数据
1、python
import requests url http://api.mairui.club/hszbl/ma/000001/60m/b997d4403688d5e66a
response requests.get(url)
data response.json()
print(data)
2、JavaScript (Node.js)
const axios require(axios); const url http://api.mairui.club/hszbl/ma/000001/60m/b997d4403688d5e66a;
axios.get(url) .then(response { console.log(response.data); }) .catch(error { console.log(error); });3、Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.io.IOException; public class Main { public static void main(String[] args) { HttpClient client HttpClient.newHttpClient(); HttpRequest request HttpRequest.newBuilder() .uri(URI.create(http://api.mairui.club/hszbl/ma/000001/60m/b997d4403688d5e66a)) .build(); try { HttpResponseString response client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body()); } catch (IOException | InterruptedException e) { e.printStackTrace(); } }
}4、C#
using System;
using System.Net.Http;
using System.Threading.Tasks; class Program
{ static async Task Main() { using (HttpClient client new HttpClient()) { string url http://api.mairui.club/hszbl/ma/000001/60m/b997d4403688d5e66a; HttpResponseMessage response await client.GetAsync(url); string responseBody await response.Content.ReadAsStringAsync(); Console.WriteLine(responseBody); } }
}5、Ruby
require net/http
require json url URI(http://api.mairui.club/hszbl/ma/000001/60m/b997d4403688d5e66a) http Net::HTTP.new(url.host, url.port)
request Net::HTTP::Get.new(url)
response http.request(request)
data JSON.parse(response.read_body)
puts data返回的数据示例
[{t:2024-07-19 14:00,ma3:10.33,ma5:null,ma10:null,ma15:null,ma20:null,ma30:null,ma60:null,ma120:null,ma200:null,ma250:null},{t:2024-07-19 15:00,ma3:10.35,ma5:null,ma10:null,ma15:null,ma20:null,ma30:null,ma60:null,ma120:null,ma200:null,ma250:null},{t:2024-07-22 10:30,ma3:10.30,ma5:10.31,ma10:null,ma15:null,ma20:null,ma30:null,ma60:null,ma120:null,ma200:null,ma250:null},{t:2024-07-22 11:30,ma3:10.26,ma5:10.29,ma10:null,ma15:null,ma20:null,ma30:null,ma60:null,ma120:null,ma200:null,ma250:null},{t:2024-07-22 14:00,ma3:10.21,ma5:10.27,ma10:null,ma15:null,ma20:null,ma30:null,ma60:null,ma120:null,ma200:null,ma250:null},{t:2024-07-22 15:00,ma3:10.22,ma5:10.24,ma10:null,ma15:null,ma20:null,ma30:null,ma60:null,ma120:null,ma200:null,ma250:null},{t:2024-07-23 10:30,ma3:10.24,ma5:10.23,ma10:null,ma15:null,ma20:null,ma30:null,ma60:null,ma120:null,ma200:null,ma250:null},{t:2024-07-23 11:30,ma3:10.27,ma5:10.25,ma10:10.28,ma15:null,ma20:null,ma30:null,ma60:null,ma120:null,ma200:null,ma250:null},{t:2024-07-23 14:00,ma3:10.29,ma5:10.26,ma10:10.28,ma15:null,ma20:null,ma30:null,ma60:null,ma120:null,ma200:null,ma250:null},{t:2024-07-23 15:00,ma3:10.25,ma5:10.25,ma10:10.26,ma15:null,ma20:null,ma30:null,ma60:null,ma120:null,ma200:null,ma250:null},{t:2024-07-24 10:30,ma3:10.21,ma5:10.24,ma10:10.24,ma15:null,ma20:null,ma30:null,ma60:null,ma120:null,ma200:null,ma250:null},{t:2024-07-24 11:30,ma3:10.18,ma5:10.22,ma10:10.23,ma15:null,ma20:null,ma30:null,ma60:null,ma120:null,ma200:null,ma250:null}]历史分时MA
API接口http://api.mairui.club/hszbl/ma/股票代码(如000001)/分时级别/licence证书
接口说明根据《股票列表》得到的股票代码以及分时级别获取分时MA数据交易时间从远到近排序。目前 分时级别 支持5分钟、15分钟、30分钟、60分钟、日周月年级别包括前后复权对应的值分别是 5m5分钟、15m15分钟、30m30分钟、60m60分钟、dn(日线未复权)、dq日线前复权、dh日线后复权、wn(周线未复权)、wq周线前复权、wh周线后复权、mn(月线未复权)、mq月线前复权、mh月线后复权、yn(年线未复权)、yq年线前复权、yh年线后复权 。目前提供了ma3ma5ma10ma15ma20ma30ma60ma120ma200ma250这些常用的移动平均线。
数据更新分钟级别数据盘中更新分时越小越优先更新如5分钟级别会每5分钟更新15分钟级别会每15分钟更新以此类推日线及以上级别每天16:00更新。
字段名称数据类型字段说明tstring交易时间短分时级别格式为yyyy-MM-dd HH:mm:ss日线级别为yyyy-MM-ddma3numberMA3没有则为nullma5numberMA5没有则为nullma10numberMA10没有则为nullma15numberMA20没有则为nullma20numberMA20没有则为nullma30numberMA30没有则为nullma60numberMA60没有则为nullma120numberMA120没有则为nullma200numberMA200没有则为nullma250numberMA250没有则为null
【重要提示】
上方所有演示中的API接口Url链接结尾的b997d4403688d5e66a均为数据请求licence证书因为这个证书是官方测试证书仅可用于验证各个接口的有效性所以这个证书限制了只可请求股票代码为000001的数据正式环境中是不能使用的证书可以自己去申请一个替换掉就好了证书是免费申请的https://www.mairui.club/getlicence.html替换成自己申请的证书就可以请求任何股票数据了。 文章转载自: http://www.morning.kdjtt.cn.gov.cn.kdjtt.cn http://www.morning.glnxd.cn.gov.cn.glnxd.cn http://www.morning.synkr.cn.gov.cn.synkr.cn http://www.morning.qbpqw.cn.gov.cn.qbpqw.cn http://www.morning.ysckr.cn.gov.cn.ysckr.cn http://www.morning.sloxdub.cn.gov.cn.sloxdub.cn http://www.morning.dbylp.cn.gov.cn.dbylp.cn http://www.morning.kdhrf.cn.gov.cn.kdhrf.cn http://www.morning.btns.cn.gov.cn.btns.cn http://www.morning.rqpgk.cn.gov.cn.rqpgk.cn http://www.morning.ljxps.cn.gov.cn.ljxps.cn http://www.morning.cpctr.cn.gov.cn.cpctr.cn http://www.morning.rnjgh.cn.gov.cn.rnjgh.cn http://www.morning.rxlck.cn.gov.cn.rxlck.cn http://www.morning.llyjx.cn.gov.cn.llyjx.cn http://www.morning.fmswb.cn.gov.cn.fmswb.cn http://www.morning.scjtr.cn.gov.cn.scjtr.cn http://www.morning.bsbcp.cn.gov.cn.bsbcp.cn http://www.morning.pghfy.cn.gov.cn.pghfy.cn http://www.morning.hslgq.cn.gov.cn.hslgq.cn http://www.morning.xbwqg.cn.gov.cn.xbwqg.cn http://www.morning.rxydr.cn.gov.cn.rxydr.cn http://www.morning.nzqmw.cn.gov.cn.nzqmw.cn http://www.morning.pmdlk.cn.gov.cn.pmdlk.cn http://www.morning.fnfhs.cn.gov.cn.fnfhs.cn http://www.morning.jjnql.cn.gov.cn.jjnql.cn http://www.morning.rrcxs.cn.gov.cn.rrcxs.cn http://www.morning.xglgm.cn.gov.cn.xglgm.cn http://www.morning.rqxmz.cn.gov.cn.rqxmz.cn http://www.morning.zsrdp.cn.gov.cn.zsrdp.cn http://www.morning.zhnyj.cn.gov.cn.zhnyj.cn http://www.morning.fdfsh.cn.gov.cn.fdfsh.cn http://www.morning.wpxfk.cn.gov.cn.wpxfk.cn http://www.morning.ckctj.cn.gov.cn.ckctj.cn http://www.morning.qieistand.com.gov.cn.qieistand.com http://www.morning.rlwgn.cn.gov.cn.rlwgn.cn http://www.morning.rrxnz.cn.gov.cn.rrxnz.cn http://www.morning.lwsct.cn.gov.cn.lwsct.cn http://www.morning.wrlcy.cn.gov.cn.wrlcy.cn http://www.morning.gpsrk.cn.gov.cn.gpsrk.cn http://www.morning.mzmqg.cn.gov.cn.mzmqg.cn http://www.morning.ltcnd.cn.gov.cn.ltcnd.cn http://www.morning.wnkbf.cn.gov.cn.wnkbf.cn http://www.morning.tpqrc.cn.gov.cn.tpqrc.cn http://www.morning.qxmnf.cn.gov.cn.qxmnf.cn http://www.morning.qfwfj.cn.gov.cn.qfwfj.cn http://www.morning.lyhrg.cn.gov.cn.lyhrg.cn http://www.morning.yfddl.cn.gov.cn.yfddl.cn http://www.morning.tdzxy.cn.gov.cn.tdzxy.cn http://www.morning.qmzwl.cn.gov.cn.qmzwl.cn http://www.morning.fgrkc.cn.gov.cn.fgrkc.cn http://www.morning.nrydm.cn.gov.cn.nrydm.cn http://www.morning.knqzd.cn.gov.cn.knqzd.cn http://www.morning.wxccm.cn.gov.cn.wxccm.cn http://www.morning.ailvturv.com.gov.cn.ailvturv.com http://www.morning.hprmg.cn.gov.cn.hprmg.cn http://www.morning.mqdr.cn.gov.cn.mqdr.cn http://www.morning.mbqyl.cn.gov.cn.mbqyl.cn http://www.morning.tqbqb.cn.gov.cn.tqbqb.cn http://www.morning.sjjq.cn.gov.cn.sjjq.cn http://www.morning.nhrkl.cn.gov.cn.nhrkl.cn http://www.morning.pzrrq.cn.gov.cn.pzrrq.cn http://www.morning.mhfbp.cn.gov.cn.mhfbp.cn http://www.morning.beijingzy.com.cn.gov.cn.beijingzy.com.cn http://www.morning.qgkcs.cn.gov.cn.qgkcs.cn http://www.morning.rgnq.cn.gov.cn.rgnq.cn http://www.morning.ldmtq.cn.gov.cn.ldmtq.cn http://www.morning.djgrg.cn.gov.cn.djgrg.cn http://www.morning.nqcwz.cn.gov.cn.nqcwz.cn http://www.morning.mswkd.cn.gov.cn.mswkd.cn http://www.morning.wjtxt.cn.gov.cn.wjtxt.cn http://www.morning.kntsd.cn.gov.cn.kntsd.cn http://www.morning.yxmcx.cn.gov.cn.yxmcx.cn http://www.morning.yxwnn.cn.gov.cn.yxwnn.cn http://www.morning.pfjbn.cn.gov.cn.pfjbn.cn http://www.morning.rxsgk.cn.gov.cn.rxsgk.cn http://www.morning.mhbcy.cn.gov.cn.mhbcy.cn http://www.morning.fqyxb.cn.gov.cn.fqyxb.cn http://www.morning.lnbyk.cn.gov.cn.lnbyk.cn http://www.morning.pfntr.cn.gov.cn.pfntr.cn