Skip to main content

mishmar (Python)

The Python client for Mishmar: build a proposal, sign it with the agent's key, send it to the engine, read the decision.

from datetime import timedelta
from mishmar import AgentKey, Client, Proposal

key = AgentKey.parse("msk_…")           # shown once when the engine issued the key
client = Client("http://localhost:8080/v1", key, key_id="key_…")

decision = client.propose(Proposal(
    trading_account_id="ta_…", symbol="BTC", side="buy", size="0.25",
    order_type="market", valid_for=timedelta(minutes=5),
))
print(decision["verdict"])              # allow | require_approval | block

# Pull a resting order this agent placed through Mishmar: a cancel names the
# order by the clientOrderId its decision carries, and has no side or size.
client.propose(Proposal(
    trading_account_id="ta_…", symbol="BTC", kind="cancel",
    target_client_order_id=decision["proposal"]["clientOrderId"],
))

Sizes, prices and leverage are decimal strings and are signed exactly as written: "0.5" and "0.50" are the same quantity but different signatures. Never pass a float.

A call the engine did nothing with goes again by itself: 503 unavailable while the engine restarts and 429 rate_limited (after its Retry-After), for up to 45 s, then the last answer is raised as EngineError. Nothing else is retried. Client(..., retries=None) turns that off; retries=Retries(budget=90) tunes it.

Run the tests, which include the cross-language vectors in ../spec/vectors:

pip install -e ".[test]"
python -m pytest

The signer as a child process

With the mishmar binary installed (or fetched with download_binary), Signer runs it as a child process and the bot holds no secret: the child has the agent's key and shares, signs each proposal, and sends it one-shot where it can. Reads go through the child too.

from mishmar import Signer

with Signer() as s:                                   # ~/.mishmar/agent.json
    d = s.order("ta_…", "BTC", "buy", "0.001", price="79500")
    if d["verdict"] == "require_approval":
        d = s.wait(d["id"])
    s.cancel("ta_…", "BTC", d["proposal"]["clientOrderId"])

The child stops when this process ends, however it ends: it runs with --exit-on-stdin-close and a pipe on its stdin. To share one signer among several processes, or keep it connected across restarts, run it on its own (mishmar signer run --local unix:/run/mishmar/signer.sock) and attach with Signer.connect("unix:/run/mishmar/signer.sock"); stop() then leaves it running. One signer runs per config, so a second Signer() on a config in use fails and names the process that holds it.

Metadata

Release files for mishmar 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 mishmar 0.2.0
File Size Uploaded Provenance Actions
mishmar-0.2.0.tar.gz 31.5 kB Without provenance Details for mishmar-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 55.5 kB

Release files / mishmar-0.2.0.tar.gz

Download URL mishmar-0.2.0.tar.gz
Size 31.5 kB
Tags Source
SHA-256 checksum
How to use checksums
cec1748994d3ed12f445f5246d0d2008d1265be89bd3a6bd4abd0ff0b50cda96
BLAKE2b-256 checksum
How to use checksums
6662bad298da33546d796e8df8c0f2db4cecf206de103109cc96da7f50512148
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.13

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

Download URL mishmar-0.2.0-py3-none-any.whl
Size 24.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b674fee80373f5d6ef7ffd87d044c7f9e56c7576ee368b676769d65dbb3c0e7
BLAKE2b-256 checksum
How to use checksums
00e51a9cac811d6c01c1b8abfaf3e9c0b71139bca8d0d99a0863475427a087bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.13

Security for mishmar 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.

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