Skip to main content

A simple high perf signing lib for BULK txns

Project description

bulk-keychain

A simple high perf signing lib for BULK txns - Python bindings.

Installation

pip install bulk-keychain

Quick Start

from bulk_keychain import Keypair, Signer

# Generate a new keypair
keypair = Keypair()
print(f"Public key: {keypair.pubkey}")

# Or import from base58
# keypair = Keypair.from_base58("your-secret-key...")

# Create a signer
signer = Signer(keypair)

# Sign a limit order
signed = signer.sign({
    "type": "order",
    "symbol": "BTC-USD",
    "is_buy": True,
    "price": 100000.0,
    "size": 0.1,
    "order_type": {"type": "limit", "tif": "GTC"}
})

# Submit to API
import requests
response = requests.post(
    "https://api.bulk.exchange/api/v1/order",
    json={
        "actions": signed["actions"],
        "nonce": signed["nonce"],
        "account": signed["account"],
        "signer": signed["signer"],
        "signature": signed["signature"],
    }
)

Order Types

Limit Order

{
    "type": "order",
    "symbol": "BTC-USD",
    "is_buy": True,
    "price": 100000.0,
    "size": 0.1,
    "order_type": {"type": "limit", "tif": "GTC"}  # GTC, IOC, or ALO
}

Market Order

{
    "type": "order",
    "symbol": "BTC-USD",
    "is_buy": True,
    "price": 0.0,
    "size": 0.1,
    "order_type": {"type": "market", "is_market": True, "trigger_px": 0.0}
}

Cancel Order

{
    "type": "cancel",
    "symbol": "BTC-USD",
    "order_id": "order-id-base58"
}

Cancel All Orders

{
    "type": "cancel_all",
    "symbols": ["BTC-USD"]  # or [] for all symbols
}

Batch Signing

For high-frequency trading, sign many transactions in parallel:

# Sign all at once - each order becomes one transaction
signed_txs = signer.sign_all(orders)

For multi-order atomic transactions, batch order_ids are optional:

signer.set_compute_batch_order_ids(True)  # default False for max performance
grouped = signer.sign_group([entry_order, stop_loss, take_profit])
print(grouped.get("order_ids"))

API Reference

Keypair

# Generate new keypair
keypair = Keypair()

# Import from base58
keypair = Keypair.from_base58("secret-key-base58")

# Import from bytes (32 or 64 bytes)
keypair = Keypair.from_bytes(bytes_data)

# Properties and methods
keypair.pubkey          # Public key as base58 string
keypair.to_base58()     # Full keypair as base58 (64 bytes)
keypair.to_bytes()      # Full keypair as bytes
keypair.secret_key()    # Secret key as bytes (32 bytes)

Signer

# Create signer
signer = Signer(keypair)
signer = Signer.from_base58("secret-key-base58")

# With nonce management 
signer = Signer.with_nonce_manager(keypair, "timestamp")     # Use timestamp
signer = Signer.with_nonce_manager(keypair, "counter")       # Use counter
signer = Signer.with_nonce_manager(keypair, "high_frequency") # Timestamp + counter

# Optional ID computation controls
signer.set_compute_order_id(True)            # default True
signer.set_compute_batch_order_ids(False)    # default False
signer.computes_order_id()
signer.computes_batch_order_ids()

# Sign operations
signed = signer.sign(order, nonce=None)
signed = signer.sign_group([order1, order2], nonce=None)
signed = signer.sign_faucet(nonce=None)
signed = signer.sign_agent_wallet(agent_pubkey, delete=False, nonce=None)
signed = signer.sign_user_settings(max_leverage=[("BTC-USD", 5.0)], nonce=None)
signed = signer.sign_oracle_prices([(1704067200000000000, "BTC-USD", 102500.0)], nonce=None)
signed = signer.sign_pyth_oracle([(1704067200000000000, 1, 10250000000000, -8)], nonce=None)
signed = signer.sign_whitelist_faucet(target_pubkey, whitelist=True, nonce=None)
signed_list = signer.sign_all(orders, base_nonce=None)

Tuple formats:

  • sign_oracle_prices: (timestamp, asset, price)
  • sign_pyth_oracle: (timestamp, feed_index, price, exponent)

Utilities

from bulk_keychain import random_hash, current_timestamp, validate_pubkey, validate_hash

# Generate random hash for client order IDs
client_id = random_hash()

# Get current timestamp in milliseconds
ts = current_timestamp()

# Validate base58 strings
is_valid = validate_pubkey("pubkey-base58")
is_valid = validate_hash("hash-base58")

Compute order ID without a signer/private key:

from bulk_keychain import compute_order_id_from_order

order_id = compute_order_id_from_order(
    {"type": "order", "symbol": "BTC-USD", "is_buy": True, "price": 100000.0, "size": 0.1},
    nonce=1704067200000,
    account="your-account-pubkey",
)

# Compact API order JSON is also supported:
order_id_compact = compute_order_id_from_order(
    {"l": {"c": "BTC-USD", "b": True, "px": 100000.0, "sz": 0.1, "r": False, "tif": "GTC"}},
    nonce=1704067200000,
    account="your-account-pubkey",
)

Project details


Download files

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

Source Distribution

bulk_keychain-0.1.17.tar.gz (51.4 kB view details)

Uploaded Source

Built Distributions

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

bulk_keychain-0.1.17-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (501.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.17-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (480.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.17-cp312-cp312-win_amd64.whl (356.4 kB view details)

Uploaded CPython 3.12Windows x86-64

bulk_keychain-0.1.17-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (501.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.17-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (480.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.17-cp312-cp312-macosx_11_0_arm64.whl (436.8 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

bulk_keychain-0.1.17-cp312-cp312-macosx_10_12_x86_64.whl (469.2 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

bulk_keychain-0.1.17-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (503.3 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.17-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (482.3 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.17-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (503.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.17-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (482.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.17-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (504.6 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.17-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (483.3 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

File details

Details for the file bulk_keychain-0.1.17.tar.gz.

File metadata

  • Download URL: bulk_keychain-0.1.17.tar.gz
  • Upload date:
  • Size: 51.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for bulk_keychain-0.1.17.tar.gz
Algorithm Hash digest
SHA256 890485605c4c3f7bca4817ff6aeb9db629aaa331cd56518941c636c8f756396a
MD5 28df7aa49f5e4a06a5ce6578349bc5c6
BLAKE2b-256 5dd38aa62a1234424fa7fd2f06cfac2273663250426d190d00c0653bff2b49fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for bulk_keychain-0.1.17.tar.gz:

Publisher: release.yml on Bulk-trade/bulk-keychain

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

File details

Details for the file bulk_keychain-0.1.17-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bulk_keychain-0.1.17-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 369c56cb9f0dbd9c0da03399f8884c5b6c2a54e7280c6be0603bb00554562341
MD5 bb67be5ce0c7d35b4489b50243d9b849
BLAKE2b-256 198a3f45697383b863da0aa0829053509728dc8dcd8df8e9be5f654426105371

See more details on using hashes here.

Provenance

The following attestation bundles were made for bulk_keychain-0.1.17-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on Bulk-trade/bulk-keychain

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

File details

Details for the file bulk_keychain-0.1.17-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for bulk_keychain-0.1.17-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6f107ceb07ad5153ce0118e730155e626132f5f0c4686828462f37d4ce14140c
MD5 4f8706135da80aca5e3b903cde4a17bc
BLAKE2b-256 9d03d13ae94b4d915c1132bfc4fc7bb22000a04febc8158746af4461a98ea644

See more details on using hashes here.

Provenance

The following attestation bundles were made for bulk_keychain-0.1.17-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on Bulk-trade/bulk-keychain

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

File details

Details for the file bulk_keychain-0.1.17-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for bulk_keychain-0.1.17-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 38bec878f71ef0de9bca13f77a04443dda69d1ef29642f3d7f4fc2ad74e453df
MD5 994a594ad345c6c4bbf0c1f6827a39e5
BLAKE2b-256 f50d2fc415b979c184bac87de3f4f70c623756cfb0530a35e2dce8ea4015f7de

See more details on using hashes here.

Provenance

The following attestation bundles were made for bulk_keychain-0.1.17-cp312-cp312-win_amd64.whl:

Publisher: release.yml on Bulk-trade/bulk-keychain

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

File details

Details for the file bulk_keychain-0.1.17-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bulk_keychain-0.1.17-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c9ba49bd4037894760262a65bdb9a49ae490ebacf2e002434395373ca51830ca
MD5 6f64c75eb4fd16f94089cf10982d46fb
BLAKE2b-256 f5892995e877def56cd56e6f0160582461a43d643b533eb70544a982fa2467da

See more details on using hashes here.

Provenance

The following attestation bundles were made for bulk_keychain-0.1.17-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on Bulk-trade/bulk-keychain

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

File details

Details for the file bulk_keychain-0.1.17-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for bulk_keychain-0.1.17-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 749310113de6bee1afab6dadd8ee1cae467f2633697e497c57e921888d830ec5
MD5 8bcabd121942ee099a5f371a8423a602
BLAKE2b-256 ee32d6bc83cf7690a268d027fa95dc2210ded228ebade5f6f97c0e1dd06e6798

See more details on using hashes here.

Provenance

The following attestation bundles were made for bulk_keychain-0.1.17-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on Bulk-trade/bulk-keychain

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

File details

Details for the file bulk_keychain-0.1.17-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for bulk_keychain-0.1.17-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 826f25daf100c40284bd7c7b5a72c649ed10dfaec1673c671f223ebb5ead4157
MD5 f4c80e0d4aaf0d546fffbe225fad8f57
BLAKE2b-256 d51cdba62fddf06d1429872ee6ae883bb57d9c5cbd0d58c0be4de6c69cd67877

See more details on using hashes here.

Provenance

The following attestation bundles were made for bulk_keychain-0.1.17-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on Bulk-trade/bulk-keychain

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

File details

Details for the file bulk_keychain-0.1.17-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for bulk_keychain-0.1.17-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f50f41cfe99ee78ad0fed7466b729a5ce921462321c7961a4d96bb0fc4647fd0
MD5 5f83acc25c7522bcd50f512fcd545afb
BLAKE2b-256 7180a9950836b0baf5bfea5d10ad953d68da7df8963a5c7809a420ff1e0939cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for bulk_keychain-0.1.17-cp312-cp312-macosx_10_12_x86_64.whl:

Publisher: release.yml on Bulk-trade/bulk-keychain

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

File details

Details for the file bulk_keychain-0.1.17-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bulk_keychain-0.1.17-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2312807340310976e8d05fe1ec9542efd7a90a23205f7f0e46026f1a88ef6148
MD5 6172176ab982aef322c766a990ff46cb
BLAKE2b-256 54951e0b45d65b552183d88c618e62cb514ab59035c256859d015cfd885f68cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for bulk_keychain-0.1.17-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on Bulk-trade/bulk-keychain

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

File details

Details for the file bulk_keychain-0.1.17-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for bulk_keychain-0.1.17-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 fe574be5ed8691f5cb9f55bd6d1fd80176c224663fbaa67510398ad6a6229652
MD5 fbcb148c7e8f7fd5bfe2585800a872e3
BLAKE2b-256 27f791cede475cc9c35188b391b6256bc3e04a6c4afb321b1beab1f424ce4c6d

See more details on using hashes here.

Provenance

The following attestation bundles were made for bulk_keychain-0.1.17-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on Bulk-trade/bulk-keychain

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

File details

Details for the file bulk_keychain-0.1.17-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bulk_keychain-0.1.17-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6237bafa9656406c5544faae531d20473b1cb872fff23247b2c9a52a924539bd
MD5 9c5ddb17260e46b39cca75cb8d21f942
BLAKE2b-256 cba7bc4f3a3c02fb434e92fc9b092a5983d14f50150a9ee5b40a1fcd7fe09c2a

See more details on using hashes here.

Provenance

The following attestation bundles were made for bulk_keychain-0.1.17-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on Bulk-trade/bulk-keychain

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

File details

Details for the file bulk_keychain-0.1.17-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for bulk_keychain-0.1.17-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d987a610f30075d2c0cb9b15a335be7d0800c37a4b2e5924de707211d53a8f08
MD5 6f7df50ac62ec5c8424bebde52aaeb2a
BLAKE2b-256 2b3684efc72d954f150bdb379905db4cc89aa9dc0b122c427aee35ba608ff832

See more details on using hashes here.

Provenance

The following attestation bundles were made for bulk_keychain-0.1.17-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on Bulk-trade/bulk-keychain

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

File details

Details for the file bulk_keychain-0.1.17-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bulk_keychain-0.1.17-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b1478fcc13f8334f5b966064276f66937fccfa4efedf2021a2c5d014ebc9ad9e
MD5 7b78f5844a676cf3b7be33d46aef2789
BLAKE2b-256 63bd100927957cf72b3d45d37ffb57b5309e8302493b0833251472a5ea9fe489

See more details on using hashes here.

Provenance

The following attestation bundles were made for bulk_keychain-0.1.17-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on Bulk-trade/bulk-keychain

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

File details

Details for the file bulk_keychain-0.1.17-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for bulk_keychain-0.1.17-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 882eb1e0f2f7d6891abbd7bec32ec3cf3d3a09079a96a8d136a34c6a407c4a48
MD5 eea718587820c59ba5050f79d6f3d63f
BLAKE2b-256 2e33dad573bd668738272af9eaded4fa6c3017683b32ae04e2d9b46515f8740f

See more details on using hashes here.

Provenance

The following attestation bundles were made for bulk_keychain-0.1.17-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on Bulk-trade/bulk-keychain

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