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.14.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.14-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (508.5 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.14-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (487.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.14-cp312-cp312-win_amd64.whl (358.3 kB view details)

Uploaded CPython 3.12Windows x86-64

bulk_keychain-0.1.14-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (507.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.14-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (486.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.14-cp312-cp312-macosx_11_0_arm64.whl (441.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

bulk_keychain-0.1.14-cp312-cp312-macosx_10_12_x86_64.whl (477.8 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

bulk_keychain-0.1.14-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (509.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.14-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (489.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.14-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (510.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.14-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (489.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.14-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (510.9 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.14-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (490.7 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

File details

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

File metadata

  • Download URL: bulk_keychain-0.1.14.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.14.tar.gz
Algorithm Hash digest
SHA256 89f2df6c3507c29ca70ac29cf09258844ac32fa0c46ea60d9f595c30b3278b54
MD5 627b6391b9a41bdda9fcbed5cbc7ee65
BLAKE2b-256 eab0a6b753ded7c7e6c1bf214e64c6bc787612efb1d1f6f7c0dda644f5602e94

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.14-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 feab5d735ad17ed5dc762bd674471c26d110bce1f52e38bcd370978c6fd6b87b
MD5 935f3bfa7c77d72a2eb2290a0aa52d31
BLAKE2b-256 9a18bc8446db8436dbfb15b166253aac339d7934a3bb8be99cf68f04bb11e3c0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.14-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 fdc2e01d4c0aff3fd1c5ff0776b1fab9aaa3e69f632cf93d84a1164e4727f37a
MD5 e9cf86ac11ca8bc9d281615b8fb41725
BLAKE2b-256 42316d9992534d30386838a2e30c11bbe635ba72c6f7dce388a4aac2e3269995

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.14-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3c83ad4772e3cb43d7f3b4892aadac1d6c46552752b2bb78615a9b8c08203a4b
MD5 bb653bb0bf398dd8cc2d5533ee120afb
BLAKE2b-256 efad9d0849fa07edd9c046889bf464b1f7b46ae0a3ffc41941404ce6814ea17c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.14-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b37175b9e95430ceea4cb023c32b45aec88f8c260787c6c76c82391891ad983e
MD5 8b5cfac4eee97b1218d0f504b70e480e
BLAKE2b-256 a59c8cc7d63d6fe95ead57fe749debfad3c6382aab58486696610b92e79eed55

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.14-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5cfe3d1fe1ae12d668bfa0963646a8eb54764ababbefcb4e54472480f33a157f
MD5 e247eb1c15913988ef5aa8cf6a02441e
BLAKE2b-256 afe0f9c9d099c14222d8ea606a60ff09b84d8224507ab14146542e4521d1372a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.14-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 29b77d3871be205ec85070c3686384dc191cb34ad277cd3775e0fdbcd5d11b0f
MD5 feda2fb3d47c617d3dcf82e646c67cd3
BLAKE2b-256 7c2e88d51b59533e609643fe92c2410d12061e9baab1f246065474c089143a92

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.14-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e58810213bda567e1368ea99dcf6292b7c045bb3e463d54f79d8a36d5d451414
MD5 03182855c45ef0d75c98bfe545ec9cff
BLAKE2b-256 c21db91dc761c5803c23737793da655118b65bce67190f60edabcabf140079fc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.14-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 16c56c1214078f4416ac2b5864a3dfc13fe259200f237b68865dcfe4f135014c
MD5 2cca6a4f43b98c111535bace5994e150
BLAKE2b-256 251dac148a7dfb3feafee071d9c00fae53bfb8f1670f8ef2d51e62228df27e16

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.14-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 83a0ee8727c98f199e7a1e797ec7d0f350cc6caea8ff68f3f2ca6efeb7a0cf3e
MD5 6d8c14be464f10e7b8209a6f941b6b3d
BLAKE2b-256 3224c4968b6222bf48484dd152f26534f9a83fad38afa0bc25c679e8c6b5fa92

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.14-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a0f16941ddf92f8a2ae0dcc2c7fe0fadad55bad49b70ac189dab9d64ef705b08
MD5 33949e234a4b6f6622fa79323b404e13
BLAKE2b-256 bcb423b6258d204e8579ac8fbadd813ff16d9e36594b6581590ddd52bb68ccb4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.14-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e1876aea243d13897fb4ce7acb3418851c3b444ce9a0a8a0c45537136d3bc4c2
MD5 8065c5873983b82d5c7215fecd281b96
BLAKE2b-256 d2853671376e2f4680e23234e2c46ad2e40d94c853d0fbf935b177390b3bd4dc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.14-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9bf823112c46263ac64a57e09fdb23f9ae56b9722ae48e2badc3d626884a2865
MD5 4aebb18fd2b88c661c3d0b24c9178681
BLAKE2b-256 84ac9bb270699e3833d025e089225150147d24a3563ad8673abeb3c75a85f564

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.14-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a9ac209a70a14f101d6a0be4ff124551e7a816bfcf264e1d9b55faed850ce994
MD5 afb957f1db354575a4afe6e412fb1ad0
BLAKE2b-256 f28f94b2497e84ae8a123ffccfc9e808d6dab9271e610dff3be415f7887b52d2

See more details on using hashes here.

Provenance

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