Metadata-Version: 2.4
Name: mizan-sdk
Version: 0.5.2
Summary: Verify any AI trading agent's track record, or prove your own, with a zero-knowledge credential. Stdlib only.
Author-email: MIZAN <muavia@mizan.market>
License: MIT
Project-URL: Homepage, https://mizan.market
Project-URL: Studio, https://studio.mizan.market/app/
Project-URL: API, https://studio.mizan.market/app/api.html
Keywords: ai-agents,trading-bot,algorithmic-trading,backtest-overfitting,deflated-sharpe,proof-of-performance,zero-knowledge,zkvm,STARK,verification,mcp,erc-8004
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Topic :: Office/Business :: Financial :: Investment
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# mizan — prove the edge, never reveal the agent

```bash
pip install mizan-sdk        # or: pip install https://studio.mizan.market/app/mizan-sdk.zip
```

```python
import mizan

mizan.login(api_key="mzn_…")                               # agents: headless. Or email+password, or mizan.wallet_login(pk)
# mizan.check_before_you_pay(positions_df, ["btc_4h","eth_4h"])   # free verdict + exact price, nothing charged

cred = mizan.prove(positions_df, markets=["btc_4h", "eth_4h", "sol_4h"], alias="my-agent")
#   positions_df: one column per market (in that order), one row per bar-move,
#   values are leverages (1 = 100% long, -0.5 = 50% short, 0 = flat).
#   → free gate preview in seconds → real STARK on an H100 → bundle downloaded

mizan.verify(cred)                                         # the PUBLIC verifier, exit 0 = verified
print(cred.verdict, cred.metrics, cred.url)
```

What you get: a `.bundle` anyone can verify offline with the published era verifier,
a public page at `studio.mizan.market/credential/bb-<job>`, and a row on the registry.
What stays yours: the agent. The prover sees positions, never code; the credential
reveals neither.

`mizan.markets()` lists the catalogue (crypto 4h/daily, US ETFs, 639 US single names).
Markets in one book must share a calendar — `mizan.catalog()[key]["align_group"]`.

Import what you already have (the agent uploads nothing by hand):

```python
from mizan import importers as im
book = im.hyperliquid("0xYourAddress")                 # public fills + account value, no key
book = im.freqtrade("backtest-result.zip")             # or im.quantconnect(path, starting_cash=…)
book = im.tradingview("BTCUSDT_trades.csv", equity=…)  # Strategy Tester "List of Trades"; im.mt5(report.html, equity=…)
book.report                                            # active bars, unmapped symbols, honest limits
book.check_before_you_pay()                            # free verdict + exact price
book.prove(alias="MY-AGENT")                           # real credential
```
CLI: `python -m mizan prove result.zip --from freqtrade --check-only`.
Honest limit: the credential runs on the full catalogue window, so bars outside your record are flat and a short record is usually refused.

Verify any bundle, not just yours:

```python
mizan.verify("some.bundle", ["btc_4h"], aux="blackbox_parts.json", track="blackbox_track_head.json")
```

The verifier binary is downloaded once per OS and checked against the published
`SHA256SUMS.txt`; every canonical CSV is checked against the catalogue's sha256;
the current root allowlist is passed as `--roots` so books minted after your
binary was published still pin. A credential minted under an earlier engine era
is re-run with that era's verifier automatically (era law: it verifies forever).

Stdlib only. Honest limits: bar-resolution positions only; markets must be in the
catalogue; free during launch (3 mints per account per day).

## Signed responses, forensic refusals, rewards

Every MIZAN response carries a signed `provenance` block (VTR-1 clauses, live era and verifier hashes for three operating systems, live registry counts, attempts-ledger head, Ed25519 signature; key at `https://studio.mizan.market/.well-known/mizan-keys.json`). A refusal returns every pinned gate with threshold vs value and what would pass (`explain_refusal`, free). Agents that bring agents earn: every API key is a referral key, 20% of what a referred account pays for two years, then 10% for as long as it keeps paying, in USDC on Base, credited only on a real mint. Rule: `GET /api/rewards/program`.

## Carry it · require it · the log

```python
mizan.receipt("blackbox-fractional")["receipt"]       # signed EdDSA receipt for your agent card
mizan.status("blackbox-fractional")                    # good / revoked / superseded / unknown
mizan.log_proof("blackbox-fractional")                 # inclusion proof in the Bitcoin-anchored verdict log
from mizan.gate import require_credential              # the venue gate: PASS in good standing or refuse, fail closed
mizan.standing(); mizan.everything()                   # who you are talking to; every asset with hashes
from mizan.gate import allocate_check                  # before money moves: one signed ALLOW/REFUSE with every check (Agent Profile §06)
d = allocate_check("blackbox-fractional", amount=10_000, currency="USDC"); d.allow, d.status["token"]
```
