Package: aktools
《AKShare-初阶-使用教学》视频课程已经上线，本课程手把手讲解 AKShare 和 AKTools 的环境配置和安装使用，还包含了众多衍生知识，详情点击链接! Tips：加入 AKShare VIP 答疑群可以免费获取该视频课程。AKToolsAKTools is a package of HTTP API for AKShare! It depends on AKShare, FastAPI and Typer.AKTools是一款用于快速搭建AKShareHTTP API 的工具，通过AKTools可以利用一行命令来启动 HTTP 服务，从而让原本专属服务于 Python 用户的开源财经数据接口库AKShare的使用
突破编程语言的限制。无论您使用的是 C/C++、Java、Go、Rust、Ruby、PHP、JavaScript、R、Matlab、Stata 等编程语言或软件都可以快速、轻松获取财经数据，助力您更好地展开研究和开发工作。AKTools 中文文档InstallationpipinstallaktoolsUpgradepipinstallaktools--upgrade-ihttps://pypi.org/simple# AKTools's version should great than 0.0.70AKSharePlease visit AKShare's DocumentationFastAPIPlease visit FastAPI's DocumentationTyperPlease visit Typer's DocumentationFast Runjust type the cmd/bash command:python -m aktoolsthen typehttp://127.0.0.1:8080/in your Chrome and you can fetch your homepage and more informationif you just want to test data api, you can typehttp://127.0.0.1:8080/api/public/stock_zh_a_histin your Chromeif you want to set parameter for API, then you just type likehttp://127.0.0.1:8080/api/public/stock_zh_a_hist?symbol=600000HomepageAKTools set a simple homepage for user to provide simple reference information. When you set up your
environment and deploy your local application, then you can typehttp:127.0.0.1:8080in your browser.
We are developing more functions now, please pay more attention!DemoTest-PostmanTest-RR-Programlibrary(RCurl)  # 需要先安装该包
library(jsonlite)  # 需要先安装该包
options (warn = -1)  # 该行有助于在无参数请求时去掉 warning 信息

temp_df <-
  getForm(
    uri = 'http://127.0.0.1:8080/api/public/stock_zh_a_hist',  # 此处的 http://127.0.0.1:8080 需要替换为您定义的地址和端口
    symbol = '000001',
    period = 'daily',
    start_date = '20211109',
    end_date = '20211209',
    adjust = 'hfq',
    .encoding = "utf-8"
  )
inner_df <- fromJSON(temp_df)
inner_dfR-Result日期开盘收盘最高最低成交量成交额振幅涨跌幅涨跌额换手率12021-11-093009.833017.963037.462974.07124057321631931202.110.6017.880.6422021-11-103006.582996.833008.202957.82122085121097351521.67-0.70-21.130.6332021-11-112988.703151.233164.232983.82208472937524138566.025.15154.401.0742021-11-123144.733138.233196.743112.2295754617530727202.68-0.41-13.000.4952021-11-153151.233164.233196.743126.8565509012037640962.230.8326.000.3462021-11-163152.853130.103182.113121.9760111010991134081.90-1.08-34.130.3172021-11-173118.723112.223143.103091.0966464012038591841.66-0.57-17.880.3482021-11-183108.973061.843113.853050.4679984414300583042.04-1.62-50.380.4192021-11-193061.843118.723133.353045.5878637214145063842.871.8656.880.41102021-11-223099.223113.853134.973078.0973861813377681761.82-0.16-4.870.38112021-11-233112.223074.843151.233042.33123597822138175843.50-1.25-39.010.64122021-11-243056.963073.213086.223039.0874131113167744001.53-0.05-1.630.38132021-11-253052.093042.333060.213034.2160353310682213120.85-1.00-30.880.31142021-11-263032.583026.083040.713016.3369450012199373120.80-0.53-16.250.36152021-11-292998.453014.703024.462990.335125958951059841.13-0.38-11.380.26162021-11-303019.583003.333042.332988.7073361612803845601.78-0.38-11.370.38172021-12-013001.703035.833056.962991.9570692512436668482.161.0832.500.36182021-12-023032.583027.713063.462991.9599479817491645602.36-0.27-8.120.51192021-12-033035.833037.463045.582998.4570760012423750561.560.329.750.36202021-12-063069.963110.603185.363061.84214562538963851684.072.4173.141.11212021-12-073143.103169.113203.243118.72161644429799689762.721.8858.510.83222021-12-083167.483170.733183.733120.3598028117986910562.000.051.620.51232021-12-093173.983208.113266.623154.48145588727266634403.541.1837.380.75Test-MATLABMATLAB-Programapi = 'http://127.0.0.1:8080/api/public/';
url = [api 'stock_zh_a_hist'];
options = weboptions('ContentType','json', 'CharacterEncoding', 'utf-8');
data = webread(url, options, symbol = '000001', period = 'daily', start_date = '20211109', end_date = '20211209', adjust = 'hfq');
data % 由于 MATLAB 无法显示中文字段名，请自行修改为英文字段，参考链接：http://iso2mesh.sourceforge.net/cgi-bin/index.cgi?jsonlab/Doc/ExamplesMATLAB-Result'2021-11-09'3009.830000000003017.960000000003037.460000000002974.0700000000012405732163193120.000002.110000000000000.60000000000000017.88000000000000.640000000000000'2021-11-10'3006.580000000002996.830000000003008.200000000002957.8200000000012208512109735152.000001.67000000000000-0.700000000000000-21.13000000000000.630000000000000'2021-11-11'2988.700000000003151.230000000003164.230000000002983.8200000000020847293752413856.000006.020000000000005.15000000000000154.4000000000001.07000000000000'2021-11-12'3144.730000000003138.230000000003196.740000000003112.220000000009575461753072720.000002.68000000000000-0.410000000000000-130.490000000000000'2021-11-15'3151.230000000003164.230000000003196.740000000003126.850000000006550901203764096.000002.230000000000000.830000000000000260.340000000000000'2021-11-16'3152.850000000003130.100000000003182.110000000003121.970000000006011101099113408.000001.90000000000000-1.08000000000000-34.13000000000000.310000000000000'2021-11-17'3118.720000000003112.220000000003143.100000000003091.090000000006646401203859184.000001.66000000000000-0.570000000000000-17.88000000000000.340000000000000'2021-11-18'3108.970000000003061.840000000003113.850000000003050.460000000007998441430058304.000002.04000000000000-1.62000000000000-50.38000000000000.410000000000000'2021-11-19'3061.840000000003118.720000000003133.350000000003045.580000000007863721414506384.000002.870000000000001.8600000000000056.88000000000000.410000000000000'2021-11-22'3099.220000000003113.850000000003134.970000000003078.090000000007386181337768176.000001.82000000000000-0.160000000000000-4.870000000000000.380000000000000'2021-11-23'3112.220000000003074.840000000003151.230000000003042.3300000000012359782213817584.000003.50000000000000-1.25000000000000-39.01000000000000.640000000000000'2021-11-24'3056.960000000003073.210000000003086.220000000003039.080000000007413111316774400.000001.53000000000000-0.0500000000000000-1.630000000000000.380000000000000'2021-11-25'3052.090000000003042.330000000003060.210000000003034.210000000006035331068221312.000000.850000000000000-1-30.88000000000000.310000000000000'2021-11-26'3032.580000000003026.080000000003040.710000000003016.330000000006945001219937312.000000.800000000000000-0.530000000000000-16.25000000000000.360000000000000'2021-11-29'2998.450000000003014.700000000003024.460000000002990.330000000005125958951059841.13000000000000-0.380000000000000-11.38000000000000.260000000000000'2021-11-30'3019.580000000003003.330000000003042.330000000002988.700000000007336161280384560.000001.78000000000000-0.380000000000000-11.37000000000000.380000000000000'2021-12-01'3001.700000000003035.830000000003056.960000000002991.950000000007069251243666848.000002.160000000000001.0800000000000032.50000000000000.360000000000000'2021-12-02'3032.580000000003027.710000000003063.460000000002991.950000000009947981749164560.000002.36000000000000-0.270000000000000-8.120000000000000.510000000000000'2021-12-03'3035.830000000003037.460000000003045.580000000002998.450000000007076001242375056.000001.560000000000000.3200000000000009.750000000000000.360000000000000'2021-12-06'3069.960000000003110.600000000003185.360000000003061.8400000000021456253896385168.000004.070000000000002.4100000000000073.14000000000001.11000000000000'2021-12-07'3143.100000000003169.110000000003203.240000000003118.7200000000016164442979968976.000002.720000000000001.8800000000000058.51000000000000.830000000000000'2021-12-08'3167.480000000003170.730000000003183.730000000003120.350000000009802811798691056.0000020.05000000000000001.620000000000000.510000000000000'2021-12-09'3173.980000000003208.110000000003266.620000000003154.4800000000014558872726663440.000003.540000000000001.1800000000000037.38000000000000.750000000000000Test-RustRust-Programusereqwest::blocking;useserde_json::Value;usestd::collections::HashMap;// 定义常量，用于存储API的URL。constURL:&str="http://127.0.0.1:8080/api/public";/// 获取股票数据的函数。////// # 参数/// * `symbol` - 股票代码。/// * `period` - 时间周期。/// * `start_date` - 开始日期。/// * `end_date` - 结束日期。/// * `adjust` - 复权类型。////// # 返回值/// 返回一个Result，如果成功返回空的Ok，如果失败返回错误。fnget_data(endpoint:&str,symbol:&str,period:&str,start_date:&str,end_date:&str,adjust:&str,)->Result<(),Box<dynstd::error::Error>>{// 初始化查询参数，使用提供的函数参数。letparams=HashMap::from([("symbol",symbol),("period",period),("start_date",start_date),("end_date",end_date),("adjust",adjust),]);// 创建一个阻塞的HTTP客户端。letclient=blocking::Client::new();// 构建HTTP GET请求，并将查询参数附加到请求上。letfull_url=format!("{}/{}",URL,endpoint);letresp=client.get(full_url).query(&params).send()?;// 检查响应状态码是否表示成功。ifresp.status().is_success(){// 解析响应体为JSON并打印。letstock_data_list:Value=resp.json()?;println!("{:#?}",stock_data_list);}else{// 如果响应不是成功的，则打印错误信息。eprintln!("请求失败，状态码为: {}",resp.status());}Ok(())}fnmain(){// 调用`get_data`函数，并传递股票参数。// 如果出现错误，则打印错误信息。ifletErr(e)=get_data("stock_zh_a_hist","000001","daily","20240125","20240127",""){eprintln!("发生错误: {}",e);}}MATLAB-ResultArray[Object{"开盘":Number(9.33),"成交量":Number(2162514),"成交额":Number(2037648413.07),"振幅":Number(2.89),"换手率":Number(1.11),"收盘":Number(9.5),"日期":String("2024-01-25T00:00:00.000"),"最低":Number(9.27),"最高":Number(9.54),"涨跌幅":Number(1.82),"涨跌额":Number(0.17),},Object{"开盘":Number(9.47),"成交量":Number(2272287),"成交额":Number(2172799799.01),"振幅":Number(2.42),"换手率":Number(1.17),"收盘":Number(9.62),"日期":String("2024-01-26T00:00:00.000"),"最低":Number(9.44),"最高":Number(9.67),"涨跌幅":Number(1.26),"涨跌额":Number(0.12),},]