Skip to main content

High-performance quantitative trading framework based on Rust and Python

Project description

AKQuant

PyPI Version Python Versions License AKShare

AKQuant

AKQuant 是一款专为量化投研设计的下一代高性能混合框架。核心引擎采用 Rust 编写以确保极致的执行效率,同时提供优雅的 Python 接口以维持灵活的策略开发体验。

🚀 核心亮点:

  • 极致性能:得益于 Rust 的零开销抽象与 Zero-Copy 数据架构,回测速度较传统纯 Python 框架(如 Backtrader)提升 X倍+
  • 原生 ML 支持:内置 Walk-forward Validation(滚动训练)框架,无缝集成 PyTorch/Scikit-learn,让 AI 策略开发从实验到回测一气呵成。
  • 专业级风控:内置完善的订单流管理与即时风控模块,支持多资产组合回测。

👉 阅读完整文档 | 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.19.tar.gz (242.9 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.19-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (856.0 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

akquant-0.1.19-cp310-abi3-win_amd64.whl (642.4 kB view details)

Uploaded CPython 3.10+Windows x86-64

akquant-0.1.19-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (860.0 kB view details)

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

akquant-0.1.19-cp310-abi3-macosx_11_0_arm64.whl (781.0 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: akquant-0.1.19.tar.gz
  • Upload date:
  • Size: 242.9 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.19.tar.gz
Algorithm Hash digest
SHA256 790470ff71aa6f75aa48660e7d3744514e8be9333e43eaa1eaa27000e283754e
MD5 b4944de10f64028062173e61107da35a
BLAKE2b-256 6ea5c626baafbd849a57e9f8bed63b0f632e5d27216b18a911b2c7d92e9089dc

See more details on using hashes here.

Provenance

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

Publisher: release.yml on akfamily/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.19-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for akquant-0.1.19-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ab66a24223a5b7904cd38b5b6af9d3441aaae8bcfc9b3e7f379a03d6516d4140
MD5 c882a4cb039701b2c0e955c5686bdc6d
BLAKE2b-256 d51cefaf56e2ddafcca8738db14f45f958a5833ef74673af9cae36d2d70a1fbc

See more details on using hashes here.

Provenance

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

Publisher: release.yml on akfamily/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.19-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: akquant-0.1.19-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 642.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.19-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 0afa6f82331b25e9037c9352269b12007f485f22f5d6a77f285f75fbd958f724
MD5 f2d209bb349e52f441220e38609061a4
BLAKE2b-256 bc484b77fce95b8369ddcdbb208873e70861a3651341125735a7c6b1b3da3e31

See more details on using hashes here.

Provenance

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

Publisher: release.yml on akfamily/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.19-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for akquant-0.1.19-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0d2e86a16af82eebd92c697a259eae1e23c1e1dfc0b5fc55a81905b795afe16f
MD5 f52c1b4377a16b6b65d99da3e7bf2cb5
BLAKE2b-256 a7d3a53953e2bcdf60580fafb51696c03dcc58269e305ce305737c57a1c4d27c

See more details on using hashes here.

Provenance

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

Publisher: release.yml on akfamily/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.19-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for akquant-0.1.19-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a0e843bc98435f96f88637caf659ecbd9e9e6c923bc5617fc9b6f3890f25989a
MD5 e860805d90567edb4605caeb468b75c2
BLAKE2b-256 fe303be65b8cac29a9a1bc31ab6fbca490e51a5443d88bd77d1c62926fa7e1e8

See more details on using hashes here.

Provenance

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

Publisher: release.yml on akfamily/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