aktools


Nameaktools JSON
Version 0.0.89 PyPI version JSON
download
home_pagehttps://github.com/akfamily/aktools
SummaryAKTools is a tool for AKShare HTTP API!
upload_time2024-12-12 10:23:20
maintainerNone
docs_urlNone
authorAKFamily
requires_python>=3.8
licenseMIT
keywords stock option futures bond index air others finance spider quant quantitative investment trading algotrading
VCS
bugtrack_url
requirements akshare fastapi uvicorn python-multipart jinja2 typer pydantic alembic SQLAlchemy python-dotenv
Travis-CI No Travis.
coveralls test coverage No coveralls.
            **《AKShare-初阶-使用教学》视频课程已经上线,本课程手把手讲解 AKShare 和 AKTools 的环境配置和安装使用,还包含了众多衍生知识,[详情点击链接](https://zmj.xet.tech/s/wck86)!
Tips:加入 AKShare VIP 答疑群可以免费获取该视频课程。**

[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/akshare.svg)](https://pypi.org/project/akshare/)
[![PyPI](https://img.shields.io/pypi/v/aktools.svg)](https://pypi.org/project/aktools/)
[![Downloads](https://pepy.tech/badge/aktools)](https://pepy.tech/project/aktools)
[![Documentation Status](https://readthedocs.org/projects/aktools/badge/)](https://aktools.akfamily.xyz/)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![aktools](https://img.shields.io/badge/Data%20Science-AKShare-green)](https://github.com/akfamily/aktools)
[![Actions Status](https://github.com/akfamily/aktools/workflows/build/badge.svg)](https://github.com/akfamily/aktools/actions)
[![MIT Licence](https://img.shields.io/badge/license-MIT-blue)](https://github.com/akfamily/aktools/blob/master/LICENSE)
[![](https://img.shields.io/github/forks/akfamily/aktools)](https://github.com/akfamily/aktools)
[![](https://img.shields.io/github/stars/akfamily/aktools)](https://github.com/akfamily/aktools)
[![](https://img.shields.io/github/issues/akfamily/aktools)](https://github.com/akfamily/aktools)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

# AKTools

AKTools is a package of HTTP API for AKShare! It depends on AKShare, FastAPI and Typer.

[AKTools](https://github.com/akfamily/aktools) 是一款用于快速搭建 [AKShare](https://github.com/akfamily/akshare) HTTP API 的工具,通过 [AKTools](https://github.com/akfamily/aktools)
可以利用一行命令来启动 HTTP 服务,从而让原本专属服务于 Python 用户的开源财经数据接口库 [AKShare](https://github.com/akfamily/akshare) 的使用
突破编程语言的限制。无论您使用的是 C/C++、Java、Go、Rust、Ruby、PHP、JavaScript、R、Matlab、Stata 等编程语言或软件都可以快速、轻松获取财经数据,助力您更好地展开研究和开发工作。

**[AKTools 中文文档](https://aktools.readthedocs.io/)**

## Installation

```shell
pip install aktools
```

## Upgrade

```shell
pip install aktools --upgrade -i https://pypi.org/simple  # AKTools's version should great than 0.0.70
```

## AKShare

[Please visit AKShare's Documentation](https://akshare.akfamily.xyz/)

## FastAPI

[Please visit FastAPI's Documentation](https://fastapi.tiangolo.com/)

## Typer

[Please visit Typer's Documentation](https://typer.tiangolo.com/)

## Fast Run

1. just type the cmd/bash command: `python -m aktools`
2. then type `http://127.0.0.1:8080/` in your Chrome and you can fetch your homepage and more information
3. if you just want to test data api, you can type `http://127.0.0.1:8080/api/public/stock_zh_a_hist` in your Chrome
4. if you want to set parameter for API, then you just type like `http://127.0.0.1:8080/api/public/stock_zh_a_hist?symbol=600000`

## Homepage

AKTools 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 type `http:127.0.0.1:8080` in your browser.
We are developing more functions now, please pay more attention!

## Demo

### Test-Postman

![](https://dss-1252952517.cos.ap-chengdu.myqcloud.com/image-20211209235248006.png)

### Test-R

R-Program

```
library(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_df
```

R-Result

```shell
         日期    开盘    收盘    最高    最低      成交量     成交额    振幅  涨跌幅  涨跌额 换手率
1  2021-11-09 3009.83 3017.96 3037.46 2974.07 1240573 2163193120 2.11   0.60  17.88   0.64
2  2021-11-10 3006.58 2996.83 3008.20 2957.82 1220851 2109735152 1.67  -0.70 -21.13   0.63
3  2021-11-11 2988.70 3151.23 3164.23 2983.82 2084729 3752413856 6.02   5.15 154.40   1.07
4  2021-11-12 3144.73 3138.23 3196.74 3112.22  957546 1753072720 2.68  -0.41 -13.00   0.49
5  2021-11-15 3151.23 3164.23 3196.74 3126.85  655090 1203764096 2.23   0.83  26.00   0.34
6  2021-11-16 3152.85 3130.10 3182.11 3121.97  601110 1099113408 1.90  -1.08 -34.13   0.31
7  2021-11-17 3118.72 3112.22 3143.10 3091.09  664640 1203859184 1.66  -0.57 -17.88   0.34
8  2021-11-18 3108.97 3061.84 3113.85 3050.46  799844 1430058304 2.04  -1.62 -50.38   0.41
9  2021-11-19 3061.84 3118.72 3133.35 3045.58  786372 1414506384 2.87   1.86  56.88   0.41
10 2021-11-22 3099.22 3113.85 3134.97 3078.09  738618 1337768176 1.82  -0.16  -4.87   0.38
11 2021-11-23 3112.22 3074.84 3151.23 3042.33 1235978 2213817584 3.50  -1.25 -39.01   0.64
12 2021-11-24 3056.96 3073.21 3086.22 3039.08  741311 1316774400 1.53  -0.05  -1.63   0.38
13 2021-11-25 3052.09 3042.33 3060.21 3034.21  603533 1068221312 0.85  -1.00 -30.88   0.31
14 2021-11-26 3032.58 3026.08 3040.71 3016.33  694500 1219937312 0.80  -0.53 -16.25   0.36
15 2021-11-29 2998.45 3014.70 3024.46 2990.33  512595  895105984 1.13  -0.38 -11.38   0.26
16 2021-11-30 3019.58 3003.33 3042.33 2988.70  733616 1280384560 1.78  -0.38 -11.37   0.38
17 2021-12-01 3001.70 3035.83 3056.96 2991.95  706925 1243666848 2.16   1.08  32.50   0.36
18 2021-12-02 3032.58 3027.71 3063.46 2991.95  994798 1749164560 2.36  -0.27  -8.12   0.51
19 2021-12-03 3035.83 3037.46 3045.58 2998.45  707600 1242375056 1.56   0.32   9.75   0.36
20 2021-12-06 3069.96 3110.60 3185.36 3061.84 2145625 3896385168 4.07   2.41  73.14   1.11
21 2021-12-07 3143.10 3169.11 3203.24 3118.72 1616444 2979968976 2.72   1.88  58.51   0.83
22 2021-12-08 3167.48 3170.73 3183.73 3120.35  980281 1798691056 2.00   0.05   1.62   0.51
23 2021-12-09 3173.98 3208.11 3266.62 3154.48 1455887 2726663440 3.54   1.18  37.38   0.75
```

### Test-MATLAB

MATLAB-Program

```
api = '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 无法显示中文字段名,请自行修改为英文字段,参考链接:https://iso2mesh.sourceforge.net/cgi-bin/index.cgi?jsonlab/Doc/Examples
```

MATLAB-Result

```shell
'2021-11-09'	3009.83000000000	3017.96000000000	3037.46000000000	2974.07000000000	1240573	2163193120.00000	2.11000000000000	0.600000000000000	17.8800000000000	0.640000000000000
'2021-11-10'	3006.58000000000	2996.83000000000	3008.20000000000	2957.82000000000	1220851	2109735152.00000	1.67000000000000	-0.700000000000000	-21.1300000000000	0.630000000000000
'2021-11-11'	2988.70000000000	3151.23000000000	3164.23000000000	2983.82000000000	2084729	3752413856.00000	6.02000000000000	5.15000000000000	154.400000000000	1.07000000000000
'2021-11-12'	3144.73000000000	3138.23000000000	3196.74000000000	3112.22000000000	957546	1753072720.00000	2.68000000000000	-0.410000000000000	-13	0.490000000000000
'2021-11-15'	3151.23000000000	3164.23000000000	3196.74000000000	3126.85000000000	655090	1203764096.00000	2.23000000000000	0.830000000000000	26	0.340000000000000
'2021-11-16'	3152.85000000000	3130.10000000000	3182.11000000000	3121.97000000000	601110	1099113408.00000	1.90000000000000	-1.08000000000000	-34.1300000000000	0.310000000000000
'2021-11-17'	3118.72000000000	3112.22000000000	3143.10000000000	3091.09000000000	664640	1203859184.00000	1.66000000000000	-0.570000000000000	-17.8800000000000	0.340000000000000
'2021-11-18'	3108.97000000000	3061.84000000000	3113.85000000000	3050.46000000000	799844	1430058304.00000	2.04000000000000	-1.62000000000000	-50.3800000000000	0.410000000000000
'2021-11-19'	3061.84000000000	3118.72000000000	3133.35000000000	3045.58000000000	786372	1414506384.00000	2.87000000000000	1.86000000000000	56.8800000000000	0.410000000000000
'2021-11-22'	3099.22000000000	3113.85000000000	3134.97000000000	3078.09000000000	738618	1337768176.00000	1.82000000000000	-0.160000000000000	-4.87000000000000	0.380000000000000
'2021-11-23'	3112.22000000000	3074.84000000000	3151.23000000000	3042.33000000000	1235978	2213817584.00000	3.50000000000000	-1.25000000000000	-39.0100000000000	0.640000000000000
'2021-11-24'	3056.96000000000	3073.21000000000	3086.22000000000	3039.08000000000	741311	1316774400.00000	1.53000000000000	-0.0500000000000000	-1.63000000000000	0.380000000000000
'2021-11-25'	3052.09000000000	3042.33000000000	3060.21000000000	3034.21000000000	603533	1068221312.00000	0.850000000000000	-1	-30.8800000000000	0.310000000000000
'2021-11-26'	3032.58000000000	3026.08000000000	3040.71000000000	3016.33000000000	694500	1219937312.00000	0.800000000000000	-0.530000000000000	-16.2500000000000	0.360000000000000
'2021-11-29'	2998.45000000000	3014.70000000000	3024.46000000000	2990.33000000000	512595	895105984	1.13000000000000	-0.380000000000000	-11.3800000000000	0.260000000000000
'2021-11-30'	3019.58000000000	3003.33000000000	3042.33000000000	2988.70000000000	733616	1280384560.00000	1.78000000000000	-0.380000000000000	-11.3700000000000	0.380000000000000
'2021-12-01'	3001.70000000000	3035.83000000000	3056.96000000000	2991.95000000000	706925	1243666848.00000	2.16000000000000	1.08000000000000	32.5000000000000	0.360000000000000
'2021-12-02'	3032.58000000000	3027.71000000000	3063.46000000000	2991.95000000000	994798	1749164560.00000	2.36000000000000	-0.270000000000000	-8.12000000000000	0.510000000000000
'2021-12-03'	3035.83000000000	3037.46000000000	3045.58000000000	2998.45000000000	707600	1242375056.00000	1.56000000000000	0.320000000000000	9.75000000000000	0.360000000000000
'2021-12-06'	3069.96000000000	3110.60000000000	3185.36000000000	3061.84000000000	2145625	3896385168.00000	4.07000000000000	2.41000000000000	73.1400000000000	1.11000000000000
'2021-12-07'	3143.10000000000	3169.11000000000	3203.24000000000	3118.72000000000	1616444	2979968976.00000	2.72000000000000	1.88000000000000	58.5100000000000	0.830000000000000
'2021-12-08'	3167.48000000000	3170.73000000000	3183.73000000000	3120.35000000000	980281	1798691056.00000	2	0.0500000000000000	1.62000000000000	0.510000000000000
'2021-12-09'	3173.98000000000	3208.11000000000	3266.62000000000	3154.48000000000	1455887	2726663440.00000	3.54000000000000	1.18000000000000	37.3800000000000	0.750000000000000
```

### Test-Rust

Rust-Program

```rust
use reqwest::blocking;
use serde_json::Value;
use std::collections::HashMap;

// 定义常量,用于存储API的URL。
const URL: &str = "http://127.0.0.1:8080/api/public";

/// 获取股票数据的函数。
///
/// # 参数
/// * `symbol` - 股票代码。
/// * `period` - 时间周期。
/// * `start_date` - 开始日期。
/// * `end_date` - 结束日期。
/// * `adjust` - 复权类型。
///
/// # 返回值
/// 返回一个Result,如果成功返回空的Ok,如果失败返回错误。
fn get_data(
    endpoint: &str,
    symbol: &str,
    period: &str,
    start_date: &str,
    end_date: &str,
    adjust: &str,
) -> Result<(), Box<dyn std::error::Error>> {
    // 初始化查询参数,使用提供的函数参数。
    let params = HashMap::from([
        ("symbol", symbol),
        ("period", period),
        ("start_date", start_date),
        ("end_date", end_date),
        ("adjust", adjust),
    ]);

    // 创建一个阻塞的HTTP客户端。
    let client = blocking::Client::new();
    // 构建HTTP GET请求,并将查询参数附加到请求上。
    let full_url = format!("{}/{}", URL, endpoint);
    let resp = client.get(full_url).query(&params).send()?;

    // 检查响应状态码是否表示成功。
    if resp.status().is_success() {
        // 解析响应体为JSON并打印。
        let stock_data_list: Value = resp.json()?;
        println!("{:#?}", stock_data_list);
    } else {
        // 如果响应不是成功的,则打印错误信息。
        eprintln!("请求失败,状态码为: {}", resp.status());
    }

    Ok(())
}

fn main() {
    // 调用`get_data`函数,并传递股票参数。
    // 如果出现错误,则打印错误信息。
    if let Err(e) = get_data("stock_zh_a_hist", "000001", "daily", "20240125", "20240127", "") {
        eprintln!("发生错误: {}", e);
    }
}
```

Rust-Result

```shell
Array [
    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),
    },
]
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/akfamily/aktools",
    "name": "aktools",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "stock, option, futures, bond, index, air, others, finance, spider, quant, quantitative, investment, trading, algotrading",
    "author": "AKFamily",
    "author_email": "albertandking@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/3b/20/f326ae76cc424216bc10824f3d6eb85354839a54862fd890ca6f7add51e5/aktools-0.0.89.tar.gz",
    "platform": null,
    "description": "**\u300aAKShare-\u521d\u9636-\u4f7f\u7528\u6559\u5b66\u300b\u89c6\u9891\u8bfe\u7a0b\u5df2\u7ecf\u4e0a\u7ebf\uff0c\u672c\u8bfe\u7a0b\u624b\u628a\u624b\u8bb2\u89e3 AKShare \u548c AKTools \u7684\u73af\u5883\u914d\u7f6e\u548c\u5b89\u88c5\u4f7f\u7528\uff0c\u8fd8\u5305\u542b\u4e86\u4f17\u591a\u884d\u751f\u77e5\u8bc6\uff0c[\u8be6\u60c5\u70b9\u51fb\u94fe\u63a5](https://zmj.xet.tech/s/wck86)!\nTips\uff1a\u52a0\u5165 AKShare VIP \u7b54\u7591\u7fa4\u53ef\u4ee5\u514d\u8d39\u83b7\u53d6\u8be5\u89c6\u9891\u8bfe\u7a0b\u3002**\n\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/akshare.svg)](https://pypi.org/project/akshare/)\n[![PyPI](https://img.shields.io/pypi/v/aktools.svg)](https://pypi.org/project/aktools/)\n[![Downloads](https://pepy.tech/badge/aktools)](https://pepy.tech/project/aktools)\n[![Documentation Status](https://readthedocs.org/projects/aktools/badge/)](https://aktools.akfamily.xyz/)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n[![aktools](https://img.shields.io/badge/Data%20Science-AKShare-green)](https://github.com/akfamily/aktools)\n[![Actions Status](https://github.com/akfamily/aktools/workflows/build/badge.svg)](https://github.com/akfamily/aktools/actions)\n[![MIT Licence](https://img.shields.io/badge/license-MIT-blue)](https://github.com/akfamily/aktools/blob/master/LICENSE)\n[![](https://img.shields.io/github/forks/akfamily/aktools)](https://github.com/akfamily/aktools)\n[![](https://img.shields.io/github/stars/akfamily/aktools)](https://github.com/akfamily/aktools)\n[![](https://img.shields.io/github/issues/akfamily/aktools)](https://github.com/akfamily/aktools)\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)\n\n# AKTools\n\nAKTools is a package of HTTP API for AKShare! It depends on AKShare, FastAPI and Typer.\n\n[AKTools](https://github.com/akfamily/aktools) \u662f\u4e00\u6b3e\u7528\u4e8e\u5feb\u901f\u642d\u5efa [AKShare](https://github.com/akfamily/akshare) HTTP API \u7684\u5de5\u5177\uff0c\u901a\u8fc7 [AKTools](https://github.com/akfamily/aktools)\n\u53ef\u4ee5\u5229\u7528\u4e00\u884c\u547d\u4ee4\u6765\u542f\u52a8 HTTP \u670d\u52a1\uff0c\u4ece\u800c\u8ba9\u539f\u672c\u4e13\u5c5e\u670d\u52a1\u4e8e Python \u7528\u6237\u7684\u5f00\u6e90\u8d22\u7ecf\u6570\u636e\u63a5\u53e3\u5e93 [AKShare](https://github.com/akfamily/akshare) \u7684\u4f7f\u7528\n\u7a81\u7834\u7f16\u7a0b\u8bed\u8a00\u7684\u9650\u5236\u3002\u65e0\u8bba\u60a8\u4f7f\u7528\u7684\u662f C/C++\u3001Java\u3001Go\u3001Rust\u3001Ruby\u3001PHP\u3001JavaScript\u3001R\u3001Matlab\u3001Stata \u7b49\u7f16\u7a0b\u8bed\u8a00\u6216\u8f6f\u4ef6\u90fd\u53ef\u4ee5\u5feb\u901f\u3001\u8f7b\u677e\u83b7\u53d6\u8d22\u7ecf\u6570\u636e\uff0c\u52a9\u529b\u60a8\u66f4\u597d\u5730\u5c55\u5f00\u7814\u7a76\u548c\u5f00\u53d1\u5de5\u4f5c\u3002\n\n**[AKTools \u4e2d\u6587\u6587\u6863](https://aktools.readthedocs.io/)**\n\n## Installation\n\n```shell\npip install aktools\n```\n\n## Upgrade\n\n```shell\npip install aktools --upgrade -i https://pypi.org/simple  # AKTools's version should great than 0.0.70\n```\n\n## AKShare\n\n[Please visit AKShare's Documentation](https://akshare.akfamily.xyz/)\n\n## FastAPI\n\n[Please visit FastAPI's Documentation](https://fastapi.tiangolo.com/)\n\n## Typer\n\n[Please visit Typer's Documentation](https://typer.tiangolo.com/)\n\n## Fast Run\n\n1. just type the cmd/bash command: `python -m aktools`\n2. then type `http://127.0.0.1:8080/` in your Chrome and you can fetch your homepage and more information\n3. if you just want to test data api, you can type `http://127.0.0.1:8080/api/public/stock_zh_a_hist` in your Chrome\n4. if you want to set parameter for API, then you just type like `http://127.0.0.1:8080/api/public/stock_zh_a_hist?symbol=600000`\n\n## Homepage\n\nAKTools set a simple homepage for user to provide simple reference information. When you set up your\nenvironment and deploy your local application, then you can type `http:127.0.0.1:8080` in your browser.\nWe are developing more functions now, please pay more attention!\n\n## Demo\n\n### Test-Postman\n\n![](https://dss-1252952517.cos.ap-chengdu.myqcloud.com/image-20211209235248006.png)\n\n### Test-R\n\nR-Program\n\n```\nlibrary(RCurl)  # \u9700\u8981\u5148\u5b89\u88c5\u8be5\u5305\nlibrary(jsonlite)  # \u9700\u8981\u5148\u5b89\u88c5\u8be5\u5305\noptions (warn = -1)  # \u8be5\u884c\u6709\u52a9\u4e8e\u5728\u65e0\u53c2\u6570\u8bf7\u6c42\u65f6\u53bb\u6389 warning \u4fe1\u606f\n\ntemp_df <-\n  getForm(\n    uri = 'http://127.0.0.1:8080/api/public/stock_zh_a_hist',  # \u6b64\u5904\u7684 http://127.0.0.1:8080 \u9700\u8981\u66ff\u6362\u4e3a\u60a8\u5b9a\u4e49\u7684\u5730\u5740\u548c\u7aef\u53e3\n    symbol = '000001',\n    period = 'daily',\n    start_date = '20211109',\n    end_date = '20211209',\n    adjust = 'hfq',\n    .encoding = \"utf-8\"\n  )\ninner_df <- fromJSON(temp_df)\ninner_df\n```\n\nR-Result\n\n```shell\n         \u65e5\u671f    \u5f00\u76d8    \u6536\u76d8    \u6700\u9ad8    \u6700\u4f4e      \u6210\u4ea4\u91cf     \u6210\u4ea4\u989d    \u632f\u5e45  \u6da8\u8dcc\u5e45  \u6da8\u8dcc\u989d \u6362\u624b\u7387\n1  2021-11-09 3009.83 3017.96 3037.46 2974.07 1240573 2163193120 2.11   0.60  17.88   0.64\n2  2021-11-10 3006.58 2996.83 3008.20 2957.82 1220851 2109735152 1.67  -0.70 -21.13   0.63\n3  2021-11-11 2988.70 3151.23 3164.23 2983.82 2084729 3752413856 6.02   5.15 154.40   1.07\n4  2021-11-12 3144.73 3138.23 3196.74 3112.22  957546 1753072720 2.68  -0.41 -13.00   0.49\n5  2021-11-15 3151.23 3164.23 3196.74 3126.85  655090 1203764096 2.23   0.83  26.00   0.34\n6  2021-11-16 3152.85 3130.10 3182.11 3121.97  601110 1099113408 1.90  -1.08 -34.13   0.31\n7  2021-11-17 3118.72 3112.22 3143.10 3091.09  664640 1203859184 1.66  -0.57 -17.88   0.34\n8  2021-11-18 3108.97 3061.84 3113.85 3050.46  799844 1430058304 2.04  -1.62 -50.38   0.41\n9  2021-11-19 3061.84 3118.72 3133.35 3045.58  786372 1414506384 2.87   1.86  56.88   0.41\n10 2021-11-22 3099.22 3113.85 3134.97 3078.09  738618 1337768176 1.82  -0.16  -4.87   0.38\n11 2021-11-23 3112.22 3074.84 3151.23 3042.33 1235978 2213817584 3.50  -1.25 -39.01   0.64\n12 2021-11-24 3056.96 3073.21 3086.22 3039.08  741311 1316774400 1.53  -0.05  -1.63   0.38\n13 2021-11-25 3052.09 3042.33 3060.21 3034.21  603533 1068221312 0.85  -1.00 -30.88   0.31\n14 2021-11-26 3032.58 3026.08 3040.71 3016.33  694500 1219937312 0.80  -0.53 -16.25   0.36\n15 2021-11-29 2998.45 3014.70 3024.46 2990.33  512595  895105984 1.13  -0.38 -11.38   0.26\n16 2021-11-30 3019.58 3003.33 3042.33 2988.70  733616 1280384560 1.78  -0.38 -11.37   0.38\n17 2021-12-01 3001.70 3035.83 3056.96 2991.95  706925 1243666848 2.16   1.08  32.50   0.36\n18 2021-12-02 3032.58 3027.71 3063.46 2991.95  994798 1749164560 2.36  -0.27  -8.12   0.51\n19 2021-12-03 3035.83 3037.46 3045.58 2998.45  707600 1242375056 1.56   0.32   9.75   0.36\n20 2021-12-06 3069.96 3110.60 3185.36 3061.84 2145625 3896385168 4.07   2.41  73.14   1.11\n21 2021-12-07 3143.10 3169.11 3203.24 3118.72 1616444 2979968976 2.72   1.88  58.51   0.83\n22 2021-12-08 3167.48 3170.73 3183.73 3120.35  980281 1798691056 2.00   0.05   1.62   0.51\n23 2021-12-09 3173.98 3208.11 3266.62 3154.48 1455887 2726663440 3.54   1.18  37.38   0.75\n```\n\n### Test-MATLAB\n\nMATLAB-Program\n\n```\napi = 'http://127.0.0.1:8080/api/public/';\nurl = [api 'stock_zh_a_hist'];\noptions = weboptions('ContentType','json', 'CharacterEncoding', 'utf-8');\ndata = webread(url, options, symbol = '000001', period = 'daily', start_date = '20211109', end_date = '20211209', adjust = 'hfq');\ndata % \u7531\u4e8e MATLAB \u65e0\u6cd5\u663e\u793a\u4e2d\u6587\u5b57\u6bb5\u540d\uff0c\u8bf7\u81ea\u884c\u4fee\u6539\u4e3a\u82f1\u6587\u5b57\u6bb5\uff0c\u53c2\u8003\u94fe\u63a5\uff1ahttps://iso2mesh.sourceforge.net/cgi-bin/index.cgi?jsonlab/Doc/Examples\n```\n\nMATLAB-Result\n\n```shell\n'2021-11-09'\t3009.83000000000\t3017.96000000000\t3037.46000000000\t2974.07000000000\t1240573\t2163193120.00000\t2.11000000000000\t0.600000000000000\t17.8800000000000\t0.640000000000000\n'2021-11-10'\t3006.58000000000\t2996.83000000000\t3008.20000000000\t2957.82000000000\t1220851\t2109735152.00000\t1.67000000000000\t-0.700000000000000\t-21.1300000000000\t0.630000000000000\n'2021-11-11'\t2988.70000000000\t3151.23000000000\t3164.23000000000\t2983.82000000000\t2084729\t3752413856.00000\t6.02000000000000\t5.15000000000000\t154.400000000000\t1.07000000000000\n'2021-11-12'\t3144.73000000000\t3138.23000000000\t3196.74000000000\t3112.22000000000\t957546\t1753072720.00000\t2.68000000000000\t-0.410000000000000\t-13\t0.490000000000000\n'2021-11-15'\t3151.23000000000\t3164.23000000000\t3196.74000000000\t3126.85000000000\t655090\t1203764096.00000\t2.23000000000000\t0.830000000000000\t26\t0.340000000000000\n'2021-11-16'\t3152.85000000000\t3130.10000000000\t3182.11000000000\t3121.97000000000\t601110\t1099113408.00000\t1.90000000000000\t-1.08000000000000\t-34.1300000000000\t0.310000000000000\n'2021-11-17'\t3118.72000000000\t3112.22000000000\t3143.10000000000\t3091.09000000000\t664640\t1203859184.00000\t1.66000000000000\t-0.570000000000000\t-17.8800000000000\t0.340000000000000\n'2021-11-18'\t3108.97000000000\t3061.84000000000\t3113.85000000000\t3050.46000000000\t799844\t1430058304.00000\t2.04000000000000\t-1.62000000000000\t-50.3800000000000\t0.410000000000000\n'2021-11-19'\t3061.84000000000\t3118.72000000000\t3133.35000000000\t3045.58000000000\t786372\t1414506384.00000\t2.87000000000000\t1.86000000000000\t56.8800000000000\t0.410000000000000\n'2021-11-22'\t3099.22000000000\t3113.85000000000\t3134.97000000000\t3078.09000000000\t738618\t1337768176.00000\t1.82000000000000\t-0.160000000000000\t-4.87000000000000\t0.380000000000000\n'2021-11-23'\t3112.22000000000\t3074.84000000000\t3151.23000000000\t3042.33000000000\t1235978\t2213817584.00000\t3.50000000000000\t-1.25000000000000\t-39.0100000000000\t0.640000000000000\n'2021-11-24'\t3056.96000000000\t3073.21000000000\t3086.22000000000\t3039.08000000000\t741311\t1316774400.00000\t1.53000000000000\t-0.0500000000000000\t-1.63000000000000\t0.380000000000000\n'2021-11-25'\t3052.09000000000\t3042.33000000000\t3060.21000000000\t3034.21000000000\t603533\t1068221312.00000\t0.850000000000000\t-1\t-30.8800000000000\t0.310000000000000\n'2021-11-26'\t3032.58000000000\t3026.08000000000\t3040.71000000000\t3016.33000000000\t694500\t1219937312.00000\t0.800000000000000\t-0.530000000000000\t-16.2500000000000\t0.360000000000000\n'2021-11-29'\t2998.45000000000\t3014.70000000000\t3024.46000000000\t2990.33000000000\t512595\t895105984\t1.13000000000000\t-0.380000000000000\t-11.3800000000000\t0.260000000000000\n'2021-11-30'\t3019.58000000000\t3003.33000000000\t3042.33000000000\t2988.70000000000\t733616\t1280384560.00000\t1.78000000000000\t-0.380000000000000\t-11.3700000000000\t0.380000000000000\n'2021-12-01'\t3001.70000000000\t3035.83000000000\t3056.96000000000\t2991.95000000000\t706925\t1243666848.00000\t2.16000000000000\t1.08000000000000\t32.5000000000000\t0.360000000000000\n'2021-12-02'\t3032.58000000000\t3027.71000000000\t3063.46000000000\t2991.95000000000\t994798\t1749164560.00000\t2.36000000000000\t-0.270000000000000\t-8.12000000000000\t0.510000000000000\n'2021-12-03'\t3035.83000000000\t3037.46000000000\t3045.58000000000\t2998.45000000000\t707600\t1242375056.00000\t1.56000000000000\t0.320000000000000\t9.75000000000000\t0.360000000000000\n'2021-12-06'\t3069.96000000000\t3110.60000000000\t3185.36000000000\t3061.84000000000\t2145625\t3896385168.00000\t4.07000000000000\t2.41000000000000\t73.1400000000000\t1.11000000000000\n'2021-12-07'\t3143.10000000000\t3169.11000000000\t3203.24000000000\t3118.72000000000\t1616444\t2979968976.00000\t2.72000000000000\t1.88000000000000\t58.5100000000000\t0.830000000000000\n'2021-12-08'\t3167.48000000000\t3170.73000000000\t3183.73000000000\t3120.35000000000\t980281\t1798691056.00000\t2\t0.0500000000000000\t1.62000000000000\t0.510000000000000\n'2021-12-09'\t3173.98000000000\t3208.11000000000\t3266.62000000000\t3154.48000000000\t1455887\t2726663440.00000\t3.54000000000000\t1.18000000000000\t37.3800000000000\t0.750000000000000\n```\n\n### Test-Rust\n\nRust-Program\n\n```rust\nuse reqwest::blocking;\nuse serde_json::Value;\nuse std::collections::HashMap;\n\n// \u5b9a\u4e49\u5e38\u91cf\uff0c\u7528\u4e8e\u5b58\u50a8API\u7684URL\u3002\nconst URL: &str = \"http://127.0.0.1:8080/api/public\";\n\n/// \u83b7\u53d6\u80a1\u7968\u6570\u636e\u7684\u51fd\u6570\u3002\n///\n/// # \u53c2\u6570\n/// * `symbol` - \u80a1\u7968\u4ee3\u7801\u3002\n/// * `period` - \u65f6\u95f4\u5468\u671f\u3002\n/// * `start_date` - \u5f00\u59cb\u65e5\u671f\u3002\n/// * `end_date` - \u7ed3\u675f\u65e5\u671f\u3002\n/// * `adjust` - \u590d\u6743\u7c7b\u578b\u3002\n///\n/// # \u8fd4\u56de\u503c\n/// \u8fd4\u56de\u4e00\u4e2aResult\uff0c\u5982\u679c\u6210\u529f\u8fd4\u56de\u7a7a\u7684Ok\uff0c\u5982\u679c\u5931\u8d25\u8fd4\u56de\u9519\u8bef\u3002\nfn get_data(\n    endpoint: &str,\n    symbol: &str,\n    period: &str,\n    start_date: &str,\n    end_date: &str,\n    adjust: &str,\n) -> Result<(), Box<dyn std::error::Error>> {\n    // \u521d\u59cb\u5316\u67e5\u8be2\u53c2\u6570\uff0c\u4f7f\u7528\u63d0\u4f9b\u7684\u51fd\u6570\u53c2\u6570\u3002\n    let params = HashMap::from([\n        (\"symbol\", symbol),\n        (\"period\", period),\n        (\"start_date\", start_date),\n        (\"end_date\", end_date),\n        (\"adjust\", adjust),\n    ]);\n\n    // \u521b\u5efa\u4e00\u4e2a\u963b\u585e\u7684HTTP\u5ba2\u6237\u7aef\u3002\n    let client = blocking::Client::new();\n    // \u6784\u5efaHTTP GET\u8bf7\u6c42\uff0c\u5e76\u5c06\u67e5\u8be2\u53c2\u6570\u9644\u52a0\u5230\u8bf7\u6c42\u4e0a\u3002\n    let full_url = format!(\"{}/{}\", URL, endpoint);\n    let resp = client.get(full_url).query(&params).send()?;\n\n    // \u68c0\u67e5\u54cd\u5e94\u72b6\u6001\u7801\u662f\u5426\u8868\u793a\u6210\u529f\u3002\n    if resp.status().is_success() {\n        // \u89e3\u6790\u54cd\u5e94\u4f53\u4e3aJSON\u5e76\u6253\u5370\u3002\n        let stock_data_list: Value = resp.json()?;\n        println!(\"{:#?}\", stock_data_list);\n    } else {\n        // \u5982\u679c\u54cd\u5e94\u4e0d\u662f\u6210\u529f\u7684\uff0c\u5219\u6253\u5370\u9519\u8bef\u4fe1\u606f\u3002\n        eprintln!(\"\u8bf7\u6c42\u5931\u8d25\uff0c\u72b6\u6001\u7801\u4e3a: {}\", resp.status());\n    }\n\n    Ok(())\n}\n\nfn main() {\n    // \u8c03\u7528`get_data`\u51fd\u6570\uff0c\u5e76\u4f20\u9012\u80a1\u7968\u53c2\u6570\u3002\n    // \u5982\u679c\u51fa\u73b0\u9519\u8bef\uff0c\u5219\u6253\u5370\u9519\u8bef\u4fe1\u606f\u3002\n    if let Err(e) = get_data(\"stock_zh_a_hist\", \"000001\", \"daily\", \"20240125\", \"20240127\", \"\") {\n        eprintln!(\"\u53d1\u751f\u9519\u8bef: {}\", e);\n    }\n}\n```\n\nRust-Result\n\n```shell\nArray [\n    Object {\n        \"\u5f00\u76d8\": Number(9.33),\n        \"\u6210\u4ea4\u91cf\": Number(2162514),\n        \"\u6210\u4ea4\u989d\": Number(2037648413.07),\n        \"\u632f\u5e45\": Number(2.89),\n        \"\u6362\u624b\u7387\": Number(1.11),\n        \"\u6536\u76d8\": Number(9.5),\n        \"\u65e5\u671f\": String(\"2024-01-25T00:00:00.000\"),\n        \"\u6700\u4f4e\": Number(9.27),\n        \"\u6700\u9ad8\": Number(9.54),\n        \"\u6da8\u8dcc\u5e45\": Number(1.82),\n        \"\u6da8\u8dcc\u989d\": Number(0.17),\n    },\n    Object {\n        \"\u5f00\u76d8\": Number(9.47),\n        \"\u6210\u4ea4\u91cf\": Number(2272287),\n        \"\u6210\u4ea4\u989d\": Number(2172799799.01),\n        \"\u632f\u5e45\": Number(2.42),\n        \"\u6362\u624b\u7387\": Number(1.17),\n        \"\u6536\u76d8\": Number(9.62),\n        \"\u65e5\u671f\": String(\"2024-01-26T00:00:00.000\"),\n        \"\u6700\u4f4e\": Number(9.44),\n        \"\u6700\u9ad8\": Number(9.67),\n        \"\u6da8\u8dcc\u5e45\": Number(1.26),\n        \"\u6da8\u8dcc\u989d\": Number(0.12),\n    },\n]\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "AKTools is a tool for AKShare HTTP API!",
    "version": "0.0.89",
    "project_urls": {
        "Homepage": "https://github.com/akfamily/aktools"
    },
    "split_keywords": [
        "stock",
        " option",
        " futures",
        " bond",
        " index",
        " air",
        " others",
        " finance",
        " spider",
        " quant",
        " quantitative",
        " investment",
        " trading",
        " algotrading"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cd64fd338fc95ebd2137a159310e08a940e657a700d17c9a04925bdea4475e36",
                "md5": "210bf07ea9b873fc6f683786519911ea",
                "sha256": "f555d2e128c6d11dad267a449f57b03244b6c05895fd389d46dd6a6df7761182"
            },
            "downloads": -1,
            "filename": "aktools-0.0.89-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "210bf07ea9b873fc6f683786519911ea",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 24554,
            "upload_time": "2024-12-12T10:23:17",
            "upload_time_iso_8601": "2024-12-12T10:23:17.896630Z",
            "url": "https://files.pythonhosted.org/packages/cd/64/fd338fc95ebd2137a159310e08a940e657a700d17c9a04925bdea4475e36/aktools-0.0.89-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3b20f326ae76cc424216bc10824f3d6eb85354839a54862fd890ca6f7add51e5",
                "md5": "20335951f236bc7624911768d3f91c10",
                "sha256": "e7eb82ccf12f80eeea8bd20fd8c6042f36ebca210eaa0d106842b12006334fc1"
            },
            "downloads": -1,
            "filename": "aktools-0.0.89.tar.gz",
            "has_sig": false,
            "md5_digest": "20335951f236bc7624911768d3f91c10",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 26044,
            "upload_time": "2024-12-12T10:23:20",
            "upload_time_iso_8601": "2024-12-12T10:23:20.212359Z",
            "url": "https://files.pythonhosted.org/packages/3b/20/f326ae76cc424216bc10824f3d6eb85354839a54862fd890ca6f7add51e5/aktools-0.0.89.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-12 10:23:20",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "akfamily",
    "github_project": "aktools",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "akshare",
            "specs": [
                [
                    ">=",
                    "1.15.25"
                ]
            ]
        },
        {
            "name": "fastapi",
            "specs": [
                [
                    ">=",
                    "0.115.5"
                ]
            ]
        },
        {
            "name": "uvicorn",
            "specs": [
                [
                    ">=",
                    "0.16.0"
                ]
            ]
        },
        {
            "name": "python-multipart",
            "specs": [
                [
                    ">=",
                    "0.0.9"
                ]
            ]
        },
        {
            "name": "jinja2",
            "specs": [
                [
                    ">=",
                    "3.1.2"
                ]
            ]
        },
        {
            "name": "typer",
            "specs": [
                [
                    ">=",
                    "0.6.1"
                ]
            ]
        },
        {
            "name": "pydantic",
            "specs": [
                [
                    ">=",
                    "1.10.2"
                ]
            ]
        },
        {
            "name": "alembic",
            "specs": [
                [
                    ">=",
                    "1.8.1"
                ]
            ]
        },
        {
            "name": "SQLAlchemy",
            "specs": [
                [
                    ">=",
                    "1.4.41"
                ]
            ]
        },
        {
            "name": "python-dotenv",
            "specs": [
                [
                    ">=",
                    "0.21.0"
                ]
            ]
        }
    ],
    "lcname": "aktools"
}
        
Elapsed time: 0.38258s