Skip to main content

banzhuan

Python SDK for BanZhuan.AI Builder, AI Chat, backtests, research, drafts, and strategy publishing on:

  • https://hype.banzhuan.ai (Hyperliquid perps)
  • https://edge.banzhuan.ai (EdgeX perps)
  • https://poly.banzhuan.ai (Polymarket prediction markets)
  • https://afp.banzhuan.ai (Autonity AFP)

This package is designed for automation and agent workflows. It uses the same production session token model as the website.

Installation

pip install banzhuan

Authentication

  1. Open https://banzhuan.ai/credits
  2. Connect your wallet and sign in
  3. Copy your session token from the "Session Token (CLI)" card
  4. Pass that token to the SDK or store it with the CLI

The package does not perform wallet signing. It assumes you already have a valid session token.

banzhuan auth set <your-session-token>

Or use an environment variable:

export BANZHUAN_SESSION_TOKEN=<your-session-token>

Quick Start

from banzhuan import BanzhuanClient, build_perps_risk_config

# exchange can be "hype", "edge", "poly", or "afp"
client = BanzhuanClient(exchange="hype", session_token="your-session-token")

reply = client.builder_chat(
    "Build a trend-following strategy for ETH-USD with a stop loss and cooldown",
    current_graph=None,
    conversation_history=[],
    async_mode=True,
    builder_run_config={
        "market": "ETH-USD",
        "lookbackDays": 14,
        "initialCapital": 10_000,
    },
)

job = client.wait_for_builder_job(reply["jobId"])
result = job["result"]
graph = client.apply_builder_result(None, result)

backtest = client.create_backtest(
    strategy_graph=graph,
    start_ms=client.days_ago_ms(14),
    end_ms=client.now_ms(),
    initial_capital=10_000,
    risk_config=build_perps_risk_config(10_000, "ETH-USD"),
)

final_backtest = client.wait_for_backtest(backtest["jobId"], include="result")
print(final_backtest["result"]["summary"])

What The SDK Covers

  • Builder AI chat: POST /builder-chat
  • Builder async job polling: GET /builder-chat/jobs/:jobId
  • Chat session persistence: POST/GET/DELETE /builder-chat/sessions
  • Strategy drafts: POST/GET/DELETE /strategies/drafts
  • Strategy publishing and versioning: POST /strategies, POST /strategies/:id/versions
  • Backtests: POST /backtests, GET /backtests/:id, GET /backtests
  • Factor-ledger research:
    • POST /research/factors/generate-preview
    • POST /research/factors
    • POST /research/factors/evaluate
    • POST /research/factors/evaluate-all
    • GET /research/jobs/:jobId
    • GET /research/:id
  • Market insights: GET /market-insights, POST /market-insights/generate

Builder Graphs

Builder AI chat returns command deltas, not a fully materialized graph. This package includes a Python port of the production graph mutation logic so you can:

  • send a prompt
  • receive Builder commands
  • apply them locally
  • save the graph
  • backtest or publish the graph later

CLI

The CLI is intentionally small and focused on session-token workflows.

Save a session token

banzhuan auth set <your-session-token>

Run a Builder prompt against a graph file

banzhuan builder-chat \
  --exchange hype \
  --message "Create a funding mean-reversion strategy for HYPE-USD" \
  --graph-out graph.json

Backtest a graph file

banzhuan backtest \
  --exchange hype \
  --graph graph.json \
  --market HYPE-USD \
  --days 14 \
  --capital 10000 \
  --out backtest.json

Publish a Builder graph

banzhuan publish \
  --exchange hype \
  --graph graph.json \
  --name "ETH Trend" \
  --market ETH-USD \
  --visibility private

Notes

  • A valid session token authenticates you as the wallet that created it.
  • Credits and invite-key checks still apply on production endpoints.
  • Research uses the current factor-ledger workflow. The legacy sweep-style /research/run path is not used.
  • Builder AI Chat (builder_chat(), wait_for_builder_job(), apply_builder_result()) works across all four exchanges.
  • Backtest and strategy publishing methods use perps-specific formats on HYPE/EDGE. For POLY and AFP, use the Python API with exchange-specific payloads or the web UI.
  • Live session deployment can still be completed in the web app.

License

MIT

Metadata

Release files for banzhuan 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for banzhuan 0.2.0
File Size Uploaded Provenance Actions
banzhuan-0.2.0.tar.gz 14.6 kB Without provenance Details for banzhuan-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for banzhuan 0.2.0
File Interpreter ABI Platform Actions
banzhuan-0.2.0-py3-none-any.whl Python 3 none any Details for banzhuan-0.2.0-py3-none-any.whl

Total release size: 28.7 kB

Release files / banzhuan-0.2.0.tar.gz

Download URL banzhuan-0.2.0.tar.gz
Size 14.6 kB
Tags Source
SHA-256 checksum
How to use checksums
393c8e993fd840f4034753f59c6f85095d03ad03f7328035bf46f13f19b73d64
BLAKE2b-256 checksum
How to use checksums
57cbe9d9b159115e30c14ec5e272cafa7708ad796fdb8acf6dd79c108e6e5ea2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / banzhuan-0.2.0-py3-none-any.whl

Download URL banzhuan-0.2.0-py3-none-any.whl
Size 14.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2b8e7a3dce70ee367421c84e903011dd9d5307c1b0e067880b852851d40b5987
BLAKE2b-256 checksum
How to use checksums
63af8ed50e0297782f06edd18455d65e8579aad12d494f1b8745295e2b9ff99e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Security for banzhuan 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page