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.16.tar.gz (51.3 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.16-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (508.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.16-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (487.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.16-cp312-cp312-win_amd64.whl (359.9 kB view details)

Uploaded CPython 3.12Windows x86-64

bulk_keychain-0.1.16-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.16-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (486.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

bulk_keychain-0.1.16-cp312-cp312-macosx_10_12_x86_64.whl (478.4 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

bulk_keychain-0.1.16-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (509.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.16-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (489.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.16-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (510.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.16-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (489.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.16-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.16-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (491.0 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

File details

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

File metadata

  • Download URL: bulk_keychain-0.1.16.tar.gz
  • Upload date:
  • Size: 51.3 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.16.tar.gz
Algorithm Hash digest
SHA256 2b4921cd277178814f670830d9c44ed3311acbb9ed473f776cde3a81f4b653f6
MD5 bdee8c841c16d34a7e935420d9a19443
BLAKE2b-256 4e54db6333c98207397fc3dc59da3b59c3ed436bae545a6e3efbf419bc47b6da

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.16-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9f009a11330972fea7f11bbfd9b7f229ba482eda5e95840fcc64989d91af9866
MD5 51d3d31a80414386391119ce47c54c70
BLAKE2b-256 920131d3e40a1c32455d154ce84ae63b56fe7816a7af3cf31cb149bad8716d16

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.16-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 47730fd048c13b9a1c807a1b8f6f0b6ce4dc4e0869faf07bc13450907b8c21d1
MD5 f660da60719f0f7d8ba15774263a21e8
BLAKE2b-256 6d8f10a93bf5126c415c6ed229053128d7043a96d8fc7be936063bad21e05727

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.16-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 cf00990457cdc23f06b7b54a5c110ef5a03e70480e7d3b5d1a583028c939f109
MD5 d766dc4819d6104e7417ccfdf2564784
BLAKE2b-256 13f381e23e7dd3249342996cd9f8f17f796d289b102cb18707bcc126e083075a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.16-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 580b953b68d1a2b3cb7e669362f0f9ad492d999543861716cfa9c4f96c900360
MD5 fe7d3bc09643a1e418ae8fe6ddeb0416
BLAKE2b-256 4c587d80d5b7eb84a02cbc56c54200f8cc625b3fcb8e088a5d9180bbdc6aa4ec

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.16-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6974247cb77d767dde6dc75d47aa39d3d07797256c3608a75e69ae047f804c44
MD5 3f69062ac54955d13f3d121e04cb57b0
BLAKE2b-256 a3870e1391862941d8529c5ff3207c5fc48798ddc4926e59979f122da605f96e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.16-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ac33e08d0649440de4733ba53036cabe4bc39f65a84bb12e30e0a9de6e1efadc
MD5 ead1535fb760926ca16880f0d7da678f
BLAKE2b-256 7209328fcc93dd415a86ea9323e1af344d9aaac6a762f1856a5182ca453ccebe

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.16-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 bcb25bf07b96a84e3bd029618282482bac68efb8fc7884ce790829f5e00cbcc7
MD5 98987edd9e38725b19d131b8b1d950d0
BLAKE2b-256 a829693e23c643a0281d5d89870fa11e57549169133069ce63bfdda6ff8e03a2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.16-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b8719ff461d93d15af87eae3f57f6826e2b25e1fd11f758437c78d5f1ddbc5e3
MD5 ab2a111b0d2b533ee240a8cc7d196526
BLAKE2b-256 81976166484344b1c60bbc75ea3c61d00dff8f3dc499ae6a623b9ecf05afa9d6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.16-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d0db277b12ff1685d7acf889d2b5346aa331c07da6a61fbeeb059e78b76921fd
MD5 74003f358b0562da82c571c7f8fd0bc5
BLAKE2b-256 aa2088d993562b2a13c95d243cadffef1e0c5b266ce8cdde2ca576e0b6b247fc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.16-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c061c4ce5c9a149ab67a1c66c54eb435d9188910711bcd27f1fa4dc64f0c98e3
MD5 b1168646744e02448d4f2dec9508f73a
BLAKE2b-256 1c25b59d9e58beb38210daa3425a00326d0d90a307b7800db2d84c63386166c3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.16-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5e4cdeefd253d9f8fc95cdb8b0cbe893f064ba6a480114e827c5ef5a71894ec3
MD5 501864e5658b8bcc04d40ba4878bdc1c
BLAKE2b-256 858781761d55c15cbc7bc44971eb2ac8019625fe33fe00f0a9c94384bf91bb86

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.16-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b3dde09cdadd5857e8087ab632f6e0f85b84e034b2a5c522bae4ab64563c8f0c
MD5 7d0d3334df1332b8d741f186874322a2
BLAKE2b-256 05c1655b65ea62de2dbf85432fc98704560274af9a5b39120de73914c1313aa4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.16-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8d25abc8a36870c14487dbe2953471aaa3df07b1bfe624c15cafa97a24e9b2db
MD5 61145dcd0ea07ca63ec9c24f27b9dc94
BLAKE2b-256 7c9add9ef1703a85d8f002b68281f6c6cc2491be161ad3c585cca1e0f9a8572d

See more details on using hashes here.

Provenance

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