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.12.tar.gz (45.2 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.12-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (486.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.12-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (467.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.12-cp312-cp312-win_amd64.whl (342.2 kB view details)

Uploaded CPython 3.12Windows x86-64

bulk_keychain-0.1.12-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (486.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.12-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (466.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.12-cp312-cp312-macosx_11_0_arm64.whl (421.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

bulk_keychain-0.1.12-cp312-cp312-macosx_10_12_x86_64.whl (454.8 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

bulk_keychain-0.1.12-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (488.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.12-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.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (488.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.12-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (471.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.12-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (489.4 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.12-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (472.0 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

File details

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

File metadata

  • Download URL: bulk_keychain-0.1.12.tar.gz
  • Upload date:
  • Size: 45.2 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.12.tar.gz
Algorithm Hash digest
SHA256 55659143f203e2541f4e9a5d836403e3eadc7606b90604199dc33f4a581b0dda
MD5 2f29f9795c2c506028106633ee826c54
BLAKE2b-256 385a87c7af8cb36aa6c488540109268e19c46d4df2592780ec79fc21bfe7f3f5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.12-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fa3a59a3ddf4b0bb543027799d3eda29054642c5dbad7277b16bf7df6d594bdb
MD5 3b78c0995704f268904e7fb929c64ee7
BLAKE2b-256 57994e9effa0e2a2a572eb20ac2a09910e9724c72a69c54d06d0e9dbd75b2bb0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.12-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 62a0eafffcba2fcac654f5e5a632abf0d27314bfa8288b979eae98cd27c0bdbb
MD5 137d2e85697b9aae2ede659aac69d160
BLAKE2b-256 c0fd44ae512be4351187fb64721cd532fe9437c233b22007ebbab8930d1cc969

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.12-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 cf0c04799387abbedffde91ed78d3c0190e8d0fc08b06eaa15058d88131a914c
MD5 323996264f72878e3eaaa26c4c1dd3ae
BLAKE2b-256 00d3a7e48e42e6478b646f0950aaa83acce55af18c420931ea9e8ac8afa19d13

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.12-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c0683c51fb5b6be678bcf6c2210168d2c107d9b7fc4ca992583303c4e9a64180
MD5 33ba4515cae228f6c58e5775ab6c50a0
BLAKE2b-256 14c286c6a5191688eff89a2e4ca309962c678f01dab893d2e64bc12023cc7257

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.12-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 20f63788ce0fd52cb285d86d97992ac04b24873fe93d1c10ef2f21895e6b0259
MD5 0ff60b76f8e6aef984f3dde9b1b84bb3
BLAKE2b-256 ff87a5ab52e4a1b73ab4f01202b6f7830632340a37bc100e43285e6e19fa84ec

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.12-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 242c015b07a9e6bc86f35c87cada48e173c541b05cbaa06725e4e295fded41f1
MD5 f66db84d957f89b1dc3cf4c04b6f04f6
BLAKE2b-256 491f9df0d56fb26f64cca8e70a8c08d73a7aa5090fa46cdb31e78d43c6c402b4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.12-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 878ebde8c81b8e951732a6064a8bb6333dbd1258bd3795f2b733be30aea813eb
MD5 91854a2174104c5de0b2b16deddf91dd
BLAKE2b-256 e0b26b71ce79964dbcfc773708b54fdb1dfed2817641d9b23342cbc08dccfc82

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.12-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b714b24607286180be45b751b318f9c2d02911ef97d7365bc3b537fd5390eefe
MD5 ea647e4debbae97d6872fd391d1355a7
BLAKE2b-256 5f20f7a0b371568978e20a0c1e78ba75b7376be5ac9c14eab3ac9b07430f9b32

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.12-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3c6b4a7929d8799a305d27979b3645132b33362fdb89ed85519dd95acbdc9a5b
MD5 9529d5db56de8967306c88f7b459cbbe
BLAKE2b-256 98bcb3885475354bb82dc49c78206919e44724a791ab0f4b2ddd82d924123294

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a2819dc44f96a7fdea4a0bf016cc51a6e5591caaf1feb7b2e8404130d09dbdd9
MD5 472b99e7b4ecfcfa44e49782a2d6a477
BLAKE2b-256 9c2b70cdc14d086e8233c063c33390d9b3a794f54b7da1eb50f73994197cb329

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.12-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 95eaff14df4f38525c496c13b766b2d640712e2bf51f1f735f8c78985ad95fb9
MD5 0f5428ec088d9b81f0a1ed27075ca9f6
BLAKE2b-256 9eece7b5a87011aff4eaebd84ea56d01f9fd59127c20e3079862ea45fe651e3b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.12-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 585003bb51efa0ffb75abce9c9ed55f2a7ec57dd6fde4a80d82c5f716966a914
MD5 2a51ec68d45b21c76f35af51016d8b6e
BLAKE2b-256 5b45fb03751070ee9706ccb2432de7b41e7468c651d0218d7f2cb1b81deb18d6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.12-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 bf2566d0c66f8c4f77a05f11c56485d54c25ddf4205ceac562b8a28aea1aca9c
MD5 8a8b1719c239214a091b737c46bf9d76
BLAKE2b-256 d9fc2e5f599ee5944827f04665446cf2eabeadefe6a4cc77b450b3a4833a6ae8

See more details on using hashes here.

Provenance

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