Skip to main content

High-performance quantitative trading framework based on Rust and Python

Project description

AKQuant

PyPI Version Python Versions License

AKQuant

AKQuant 是一个基于 RustPython 构建的高性能量化投研框架。它结合了 Rust 的极致性能和 Python 的易用性,为量化交易者提供强大的回测、风控及机器学习支持。

相比传统框架(如 Backtrader),AKQuant 拥有 20倍+ 的回测性能提升,并原生支持 Walk-forward Validation(滚动训练)和 Zero-Copy 数据访问。

👉 阅读完整文档 | English Documentation

安装说明

AKQuant 已发布至 PyPI,无需安装 Rust 环境即可直接使用。

pip install akquant

快速开始

以下是一个简单的策略示例:

import akshare as ak
import akquant as aq
from akquant import Strategy

# 1. 准备数据
# 使用 akshare 获取 A 股历史数据 (需安装: pip install akshare)
df = ak.stock_zh_a_daily(symbol="sh600000", start_date="20230101", end_date="20231231")

class MyStrategy(Strategy):
    def on_bar(self, bar):
        # 简单策略示例:
        # 当收盘价 > 开盘价 (阳线) -> 买入
        # 当收盘价 < 开盘价 (阴线) -> 卖出

        # 获取当前持仓
        current_pos = self.get_position(bar.symbol)

        if current_pos == 0 and bar.close > bar.open:
            self.buy(bar.symbol, 100)
            print(f"[{bar.timestamp_str}] Buy 100 at {bar.close:.2f}")

        elif current_pos > 0 and bar.close < bar.open:
            self.close_position(bar.symbol)
            print(f"[{bar.timestamp_str}] Sell 100 at {bar.close:.2f}")

# 运行回测
result = aq.run_backtest(
    data=df,
    strategy=MyStrategy,
    symbol="sh600000"
)

# 打印回测结果
print("\n=== Backtest Result ===")
print(result.metrics_df)

运行结果示例:

=== Backtest Result ===
                            Backtest
total_return_pct           -0.056694
annualized_return          -0.000575
sharpe_ratio               -6.331191
sortino_ratio              -6.845218
max_drawdown_pct            0.056694
volatility                  0.000091
win_rate                    0.339286
end_market_value       999433.064610
initial_market_value  1000000.000000
total_return               -0.000567
max_drawdown                0.000567
ulcer_index                 0.000306
upi                        -1.878765
equity_r2                   0.981178
std_error                  22.986004

文档索引

License

MIT License

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

akquant-0.1.15.tar.gz (222.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

akquant-0.1.15-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (855.8 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

akquant-0.1.15-cp310-abi3-win_amd64.whl (641.4 kB view details)

Uploaded CPython 3.10+Windows x86-64

akquant-0.1.15-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (858.2 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

akquant-0.1.15-cp310-abi3-macosx_11_0_arm64.whl (779.6 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

Details for the file akquant-0.1.15.tar.gz.

File metadata

  • Download URL: akquant-0.1.15.tar.gz
  • Upload date:
  • Size: 222.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for akquant-0.1.15.tar.gz
Algorithm Hash digest
SHA256 818e79c46a8d2b5908f7ef6a6e9e0145c7d8d80830f9c0771b6d9591c800b743
MD5 c114648053b28495578de343a6b4fd6a
BLAKE2b-256 fa4035348a0b42ad2e9a715e9171e9e86f0c6f938ce08db6a9e13fbe8d2939f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for akquant-0.1.15.tar.gz:

Publisher: release.yml on albertandking/akquant

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file akquant-0.1.15-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for akquant-0.1.15-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 79173c6eb0fccc0c0b4691d6455c701866711313a09c4fa32854927b24877b82
MD5 306954bd5aa3f3d00011181d5c8048df
BLAKE2b-256 41862d7f610e585be316aba560d0f9064ef111032c3698854668004715d80a73

See more details on using hashes here.

Provenance

The following attestation bundles were made for akquant-0.1.15-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on albertandking/akquant

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file akquant-0.1.15-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: akquant-0.1.15-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 641.4 kB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for akquant-0.1.15-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 672b4176d2b2a61ca9f25cb7a409982eeb40fdf11c5d83d415d639215576a0c8
MD5 48ee655b3ebbb9dc477d1ac74c1cf9fd
BLAKE2b-256 8a1086f616105b2a5b4064be96034acd3e9825b16a543189d04b6d6bf7babaa1

See more details on using hashes here.

Provenance

The following attestation bundles were made for akquant-0.1.15-cp310-abi3-win_amd64.whl:

Publisher: release.yml on albertandking/akquant

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file akquant-0.1.15-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for akquant-0.1.15-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 608119b918c8b12eb101eb7e4400902c94adb79f7f25f4d60325bbaec68118fd
MD5 4384a021cb8bd6ad7cc975441f5177e8
BLAKE2b-256 7c2cb623a2e74fd4c649cccc14db76b4110a62fa803d92ac759fe8ab95915fd6

See more details on using hashes here.

Provenance

The following attestation bundles were made for akquant-0.1.15-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on albertandking/akquant

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file akquant-0.1.15-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for akquant-0.1.15-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a4ba7dc969242cad40ef637ee64592dd3495fc1aabd0a29ea1f4196492dc15f9
MD5 632d30acfb7f7f20e68ae471e036e154
BLAKE2b-256 cf848eda2d8ff87ff689b724729d6ed383a70556f996544459031ce51ae04e47

See more details on using hashes here.

Provenance

The following attestation bundles were made for akquant-0.1.15-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on albertandking/akquant

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page