【02期】沪深A股《跌停股池》免费获取股票数据API:Python/Java等5种语言调用实例演示与接口API文档说明
·
近年来,股票量化分析凭借其科学性与系统性,逐渐成为金融市场的热门研究领域。而进入这一领域的首要任务,就是获取全面且精准的股票数据——无论是反映市场动态的实时交易数据、记录历史轨迹的过往交易记录,还是揭示企业内在价值的财务数据与基本面信息,都是量化分析不可或缺的核心资源。我们的核心目标,正是从这些海量数据中提炼有价值的信息,为投资决策提供坚实依据。
在数据获取的探索过程中,我曾尝试多种途径:包括自研爬虫(如网易股票、申万行业数据、同花顺问财)以及使用聚宽的免费数据API。然而实践表明,依赖爬虫作为主要数据源存在明显弊端——其稳定性不足,容易因网站结构调整、反爬机制升级等原因导致数据中断,给量化研究带来诸多不便。
在量化分析领域,实时、准确、稳定的数据接口是成功的基石。经过多次测试与验证,我筛选出一批可靠的数据接口,现分享给量化分析从业者,希望能为研究和投资提供帮助。接下来,我将通过 Python、JavaScript(Node.js)、Java、C# 和 Ruby 五种主流语言的代码示例,详细演示如何高效获取各类股票数据。
1、python
import requests
url = "https://api.biyingapi.com/hslt/dtgc/2024-01-10/biyinglicence"
response = requests.get(url)
data = response.json()
print(data)
2、JavaScript (Node.js)
const axios = require('axios');
const url = "https://api.biyingapi.com/hslt/dtgc/2024-01-10/biyinglicence";
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("https://api.biyingapi.com/hslt/dtgc/2024-01-10/biyinglicence"))
.build();
try {
HttpResponse<String> 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 = "https://api.biyingapi.com/hslt/dtgc/2024-01-10/biyinglicence";
HttpResponseMessage response = await client.GetAsync(url);
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
}
}
5、Ruby
require 'net/http'
require 'json'
url = URI("https://api.biyingapi.com/hslt/dtgc/2024-01-10/biyinglicence")
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
返回的数据示例:
[{"dm":"sh605208","mc":"永茂泰","p":8.28,"zf":-10.0,"cje":510572064.0,"lt":2731903200.0,"zsz":2731903200.0,"pe":57.0,"hs":18.48,"lbc":1,"lbt":"14:47:14","zj":5392341,"fba":2262200479.0,"zbc":17},{"dm":"sh603617","mc":"君禾股份","p":8.15,"zf":-9.94,"cje":979869728.0,"lt":3097662896.55,"zsz":3184052953.6,"pe":38.64,"hs":30.67,"lbc":1,"lbt":"14:44:33","zj":11057920,"fba":2756978217.0,"zbc":9},{"dm":"sh603001","mc":"奥康国际","p":6.37,"zf":-10.03,"cje":7575841.0,"lt":2554242600.0,"zsz":2554242600.0,"pe":-14.09,"hs":0.3,"lbc":1,"lbt":"09:25:01","zj":271788790,"fba":567237671.0,"zbc":0}]
跌停股池
API接口:http://api.biyingapi.com/hslt/dtgc/日期(如2020-01-15)/您的licence
接口说明:根据日期(格式yyyy-MM-dd,从2019-11-28开始到现在的每个交易日)作为参数,得到每天的跌停股票列表,根据封单资金升序。
数据更新:交易时间段每10分钟
| 字段名称 | 数据类型 | 字段说明 |
|---|---|---|
| dm | string | 代码 |
| mc | string | 名称 |
| p | number | 价格(元) |
| zf | number | 跌幅(%) |
| cje | number | 成交额(元) |
| lt | number | 流通市值(元) |
| zsz | number | 总市值(元) |
| pe | number | 动态市盈率 |
| hs | number | 换手率(%) |
| lbc | number | 连续跌停次数 |
| lbt | string | 最后封板时间(HH:mm:ss) |
| zj | number | 封单资金(元) |
| fba | number | 板上成交额(元) |
| zbc | number | 开板次数 |
更多推荐


所有评论(0)