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.11.tar.gz (47.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.11-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (488.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.11-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (468.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.11-cp312-cp312-win_amd64.whl (342.6 kB view details)

Uploaded CPython 3.12Windows x86-64

bulk_keychain-0.1.11-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (487.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.11-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (468.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.11-cp312-cp312-macosx_11_0_arm64.whl (421.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

bulk_keychain-0.1.11-cp312-cp312-macosx_10_12_x86_64.whl (455.5 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

bulk_keychain-0.1.11-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (488.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.11-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (470.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.11-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (488.8 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.11-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (470.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.11-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (489.6 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.11-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (471.9 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

File details

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

File metadata

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

File hashes

Hashes for bulk_keychain-0.1.11.tar.gz
Algorithm Hash digest
SHA256 8bf9c76a6f012ff1f23e12b90eadbe20e84672f530ffc59fd01dd8e24773237d
MD5 68702d0d88e57377d374e94bfbdf038a
BLAKE2b-256 35d59e30b404d9b0e73f5219b0e10bb3375f9700ace62cdd443d6ad31780b69a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.11-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ff42658d9118bf9c207d85ca264f7edec584f9da2476a4d8fc758ec2da44e367
MD5 3885e198e3fa68fd51e04deb2ec5f17d
BLAKE2b-256 b65bdb7648f9e92833b31a3b64766fef944aa2f727e747b5582363f6a27a1766

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.11-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d24b540e05c414bb372c7b995fc8fcaec6bde2352182ed1a6f071182f1118d1a
MD5 672c943d22eb068bf3059c25d6988678
BLAKE2b-256 8fc0941d6340797b42f719d2b84b362189cef3940b7981161d96871f779c99c5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.11-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 52cb7b0ff7de4eda1dba21b1b74b0830f263a04b6e7e0000efb4ccb1944069c1
MD5 2146a522434e4953c871fa026f275fe8
BLAKE2b-256 433d2e34c045f80f186449099ec066df93e89cbcd0ecea1c19f9b7b7f78726d6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.11-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2435674c7e3db46877617f287d97d899ed7d2b53087c6499bb86e9022dadf9e5
MD5 bf1783f8fbf945d9782e249849711923
BLAKE2b-256 4adeca708d2ab371a5bfbf1f8de93b5e390ba3364acf6cb387bfbc4875fa9b82

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.11-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6eefa4a45ea2a396b72b9028c489e1864422ee720821c9f51e7d0857a376d74a
MD5 4cbd715ffe5df5c5b721b9d944921523
BLAKE2b-256 b9c60b26f1a6636a2230bb29ad53590421666aebd1cb9aeeb18726688e3b8084

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.11-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b9d4f92384bced8eb8ce3bde4411a793d5875c97535c4feeb4160786b667c27f
MD5 dd8ed034d01fd70dc7173be7c8c39758
BLAKE2b-256 21940331cc78f80374d456030a8132beeed8b53f15dce867bad0ab99643cbcc1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.11-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6540cd96900e290cc3f7e2ec0f725e585331a97e15de2926e5768f89cebfca6a
MD5 ef655bc3a8116bdbb28c3032a9d4010c
BLAKE2b-256 6a4bfe7926dfb770735c658e0c68b1ec8a8e92ea43fec5fe9a7d772c09dda418

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.11-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5762a34181c266565560612dc378663834204b3cf8290c88be2d46401e34795d
MD5 8a70859c215ec0d8fa5540e40602fc51
BLAKE2b-256 7983fc8c03d45b7f4f00b7f2e4d82502f0537bf17aa6069548e17550f6dac00b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.11-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5a0cadc6c9baef5ec7746e7605011aa60a13dc83fe5fbbe6c3a28c41f0b830c1
MD5 39920580446359a256b4a18c45cff4e7
BLAKE2b-256 377b63a7c16fc8abc8295f7db0f5ea17143390689ed4074f3eef1b8a0165e65a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.11-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 03a8940531a9bd4454b8f83a0b589099f5b06218e557697d1ddef5f252c6463d
MD5 a7d240fb2182f6bc76b59c637a90cc62
BLAKE2b-256 afc73c3e248d450ed1681c124db6ab07202641c3c461712b0c5c5721316659fb

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.11-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 510589dd90c52c615f159cb416c49a6879409b89df33738875a81df2cf28ebd7
MD5 a11d5ef7251f0fab49a7211456cd202a
BLAKE2b-256 51e2dbc73193a04d35619a852b61b1c34e82212b3daf23d77450bb37fe8fb2f5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.11-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ac9bdcd2584567e2dc1672e8e218b199a2790d35b1edde1e135869ab9fecfc23
MD5 743182ffe83400af3477f0613d9686f3
BLAKE2b-256 8305e5daf6fae30decf6c435b9a6dd7283dc1ca0df08af32aac2887943f35c64

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.11-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 deac0cca3e890ef13280894d5cb91ed143671c4d1a4ca9d30884039c4a922286
MD5 fc898d6e62697a9871ac238ac1c72aa9
BLAKE2b-256 291d40e409719c49e09b7ff3cc566502713fcfbde5e3d65c6903a3e625391897

See more details on using hashes here.

Provenance

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