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
}

Builder Codes

Builder codes are optional commission fees for routed limit and market orders. Python order input uses builder_code; API JSON emits builderCode on orders and abc/rbc approval actions.

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 = signer.sign_approve_builder_code(builder_pubkey, fee=5, nonce=None)
signed = signer.sign_revoke_builder_code(builder_pubkey, 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.19.tar.gz (57.1 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.19-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (503.0 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.19-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (484.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.19-cp312-cp312-win_amd64.whl (356.5 kB view details)

Uploaded CPython 3.12Windows x86-64

bulk_keychain-0.1.19-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (502.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.19-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (483.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.19-cp312-cp312-macosx_11_0_arm64.whl (438.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

bulk_keychain-0.1.19-cp312-cp312-macosx_10_12_x86_64.whl (477.1 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

bulk_keychain-0.1.19-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (503.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.19-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (486.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.19-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (504.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.19-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (486.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.19-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (505.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.19-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (487.4 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

File details

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

File metadata

  • Download URL: bulk_keychain-0.1.19.tar.gz
  • Upload date:
  • Size: 57.1 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.19.tar.gz
Algorithm Hash digest
SHA256 01f3620fd31204a1c9257a8fd8f4b899a7c8cd116adaf8508d23dc57a7c7d20a
MD5 94b9d77af73b13a903fdfd7541d74771
BLAKE2b-256 77e6cf2c523d30054e6d612e8ba682f5982466b10f0823bf567e601a8caec8b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for bulk_keychain-0.1.19.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.19-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bulk_keychain-0.1.19-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 027eb48286e04c621281c799351b9e0360723d7034424e2de4fdb3504731d109
MD5 b827e2736fecd2e9600bd1e041d594d4
BLAKE2b-256 e683ee7098f2514e93b71a8af2c4ed0f1dd526b60ad186c40aac1b5e08aad9e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for bulk_keychain-0.1.19-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.19-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for bulk_keychain-0.1.19-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3a2170998619240b7e0bfe983dde0bf3dce7de39ecc0f772b205c975d90d5f59
MD5 44d486bac86794080cdb38957cf41f60
BLAKE2b-256 e3680a1338a024155f18c2c847dac626ca8c0831e07fb70dba86ed666495ac0d

See more details on using hashes here.

Provenance

The following attestation bundles were made for bulk_keychain-0.1.19-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.19-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for bulk_keychain-0.1.19-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 40c133704eb8a127e03a02be0388687bce3e6ec4af2606c3c8bb3bf0f0b4312e
MD5 32bd4882faa72b73a458ebc75a94f1f3
BLAKE2b-256 2503cb2f513364636ea9a1c419487e12c8b8784babde8c11620aca2c41adac1b

See more details on using hashes here.

Provenance

The following attestation bundles were made for bulk_keychain-0.1.19-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.19-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bulk_keychain-0.1.19-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 34d57a6cc603137b10fca56fea478b9db1c357513f0e8723a49d89203304cd11
MD5 103f0ef4a59e05fd4dd62f599b01a689
BLAKE2b-256 abb52275f8ac1045fbcef5e9dd3a5e71425fbd8038360e83f8e4314cb53872e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for bulk_keychain-0.1.19-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.19-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for bulk_keychain-0.1.19-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6bf3fe6fa9cac445d227f0a32a5122cb7de66a2a6cfc69cccbf8eeb47cf2f43c
MD5 ed299b669ebc1c238dd49fc0fdb96b5b
BLAKE2b-256 8f202b5bf56fcb7ee426096bf4495ca20c0b403006a51f1569af7550d4b3ff2b

See more details on using hashes here.

Provenance

The following attestation bundles were made for bulk_keychain-0.1.19-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.19-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for bulk_keychain-0.1.19-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b8a742bb6da9981c20dec0ec21a3f91cb753a590557519c222edbdfeaf7b9454
MD5 7df56151e37ce303d3f2a11b6466925d
BLAKE2b-256 771befc8dac56ba83725a32631fa9b66c07bb78aef6a1c15fabba29f40d1e142

See more details on using hashes here.

Provenance

The following attestation bundles were made for bulk_keychain-0.1.19-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.19-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for bulk_keychain-0.1.19-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 23197df689c3a9813a6443057c808718444ba427799356984b2fe7ac99507982
MD5 9e49fa1da46e8c18adfb0ddc69d754ab
BLAKE2b-256 f2c65708604d02b97e8d9a96348238da9fa0bae057e9b8aef5c40ad84ca2a403

See more details on using hashes here.

Provenance

The following attestation bundles were made for bulk_keychain-0.1.19-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.19-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bulk_keychain-0.1.19-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 82648e4ca0a8020ac3df45a901b8454347c359ab5e81985f66fc5f49b1930efc
MD5 9079164718d365c47c5b0935fe4326e7
BLAKE2b-256 4a7fa9652d0f7b1d4fe4823c2e6750faa9932d3077a5b89896b35b198ef171f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for bulk_keychain-0.1.19-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.19-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for bulk_keychain-0.1.19-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4f978822276958fd73c7bd0b88867b592bf9542b3e338d8a337074666a6ceee8
MD5 5e46fb591ddfa007be204b1915f9e5c3
BLAKE2b-256 99b409ebe2c50e8821042ee958f45cef337906b573ec950786afa1678c667863

See more details on using hashes here.

Provenance

The following attestation bundles were made for bulk_keychain-0.1.19-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.19-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bulk_keychain-0.1.19-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3573bb13018c210c9bc523c739c65042e21c97a952c1051183b4d622f67281e6
MD5 cc708ed8dc6341f0a771579f498ddbba
BLAKE2b-256 2f83e545575357a683fb93276caf1416ea6a77297e3d6bac98c21b985215a0b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for bulk_keychain-0.1.19-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.19-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for bulk_keychain-0.1.19-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6033c9cc65af3faa4bccc96b04926fa31dd0e822841a131ecc89217dfc0ec61e
MD5 e0954303a9cb904ca90c4718c734f0e0
BLAKE2b-256 e026a235346406ddfce351e386d2479eefd8b7aeea5062eb526b3de818ff85dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for bulk_keychain-0.1.19-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.19-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bulk_keychain-0.1.19-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 be4471a5f7f473a9df24ed5e4262fdb72276778c0946ff09658cae23e0f46b13
MD5 4e7f6135d4ec733fb89036603ac63e18
BLAKE2b-256 1314a8b6637270a354cea13612436a6c74ef9748050aa0ad67b68f19a5670817

See more details on using hashes here.

Provenance

The following attestation bundles were made for bulk_keychain-0.1.19-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.19-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for bulk_keychain-0.1.19-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2386c52099d9591a8d128a9f2d7181290ea30bba1fbfc8f93a086dc1f7f7a1b4
MD5 ffb92ac9163a859d152224d40f86b0ce
BLAKE2b-256 e89fe4d7739bcf29f0f00a50c79d0c54de59c098d87e480f985bf119386db630

See more details on using hashes here.

Provenance

The following attestation bundles were made for bulk_keychain-0.1.19-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