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)  # -> {"updateUserSettings": {"m": {"BTC-USD": 5.0}}}
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.10.tar.gz (46.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.10-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (486.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.10-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (467.5 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.10-cp312-cp312-win_amd64.whl (336.3 kB view details)

Uploaded CPython 3.12Windows x86-64

bulk_keychain-0.1.10-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.10-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (466.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.10-cp312-cp312-macosx_11_0_arm64.whl (420.7 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

bulk_keychain-0.1.10-cp312-cp312-macosx_10_12_x86_64.whl (453.2 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

bulk_keychain-0.1.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (486.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.10-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (469.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (486.8 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.10-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (469.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (487.4 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.10-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (470.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

File details

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

File metadata

  • Download URL: bulk_keychain-0.1.10.tar.gz
  • Upload date:
  • Size: 46.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.10.tar.gz
Algorithm Hash digest
SHA256 72d51166a6697ad5ceee359f17f4b5d00475544a5952c9e3633e8ac4de48a068
MD5 b671ea7b337b57df8e9351294a8f8e0b
BLAKE2b-256 7b4e15f9efd8c35c819e3272eb1e0c35a86773aafa7ae848ef72e5fa80c69b3c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.10-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d3432e466aeb5106294b3cacfab1e942ff7d27d0752a8c310fd37236f471dd5d
MD5 6a570d13315ebaad489654a916ef7b81
BLAKE2b-256 e3c5504d11a212690bb3a717db31b272a356557e2922e23c2602848803fd45de

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.10-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b22ce06cda054899d6f582b55b9ae57e6e0a77eb5ddf77c2a4f2a0c40c721fb1
MD5 e1abc3ada702369673d9b553798856ab
BLAKE2b-256 6f4ff9ad2ca495b27eca2ce447a091178a88e6bf58035d25a069715d022d7ff7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.10-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f9e862605bf3a72543aec569b7f26f70b9572af0d298551cdf69a462b88e3ab2
MD5 34da93f647f08c30567ecddcb646c383
BLAKE2b-256 e2b8b850cff4d69f02362c6b25deb08308b347a0319f34b15fa16b9b3d526423

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a696f4a7bee982ea5787cbbcb7d776bc860d295f8be48746c8f713740029c8d8
MD5 9c45b5a4fee097ddb861cfea5b2b336f
BLAKE2b-256 e100c33f3ad83bdc0e59f85d612ef8f0e0ddc9ab43b9a81d4a71f640c6db7df5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.10-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d5316c4207408169fec14745c53f7f33f7bf48600dd15e6d6b7f0d2d04ec9e92
MD5 8b52830c1dd703b7f1a781625ebae073
BLAKE2b-256 854e560c0249690be04625ffadec24a01a328d6131f064c7abbb9c56852ee817

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.10-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 58547a58104c8260e7371406196a353ab403565362029e0404af0f9ff06e3b48
MD5 8bfc5367895df5414119e55e747849a2
BLAKE2b-256 b0f7f63e109628a043c63836153ef80791c3194219f5323eb3e84086b7c3cea7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.10-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d4ca74df8dbd7a6ab4f9eee4f78eb6086a349f39e9475a27f42ffb95f1ec0a0c
MD5 617240670ae85f93718ed00e6868ded3
BLAKE2b-256 65b7a0733d5ef3124b5c657b497a05ceae6754c3f512621856d411654f78b8c3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6bc4b5bc75be3ae7961450d31e801d2691c433b2247790735210afd2fcf220ae
MD5 1f174f6b0fe1dfd32bea3e1a9d4c1989
BLAKE2b-256 c6346e542f62b2618ee56a4d441c6ece785e5ee658e9a54c5a40d2ea13fbde19

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.10-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 50b58d554bda2d084334963d536689a44f76616f7b0d312be498438fc231343e
MD5 f7dbfc7ed4539d781e3b382c1082adda
BLAKE2b-256 311adbfd2fbe22f0ca6b0d0c0dad5df7723aaf365cb80a6eb33d8ec92ef261cc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8e2b2704e2e69623bfb733ba40f53f4e12121a1ccb80a02ce2d62b8ec2b38304
MD5 93486f131e63695d494f7796c75ab73b
BLAKE2b-256 9d7557ad123421a5f5f21fc9218afc6e93efda7454491579fe78d9b5d20ba76b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.10-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 678e4fc410224a213f041995a6d6e748d3b92a704a21376fd6b87f350c23d22b
MD5 11a4e45e1e676c21f2725f1b5c290a4d
BLAKE2b-256 60429cfaace03b14bc036e4b7e13b7cfb7188ee2645f313cfca4decd70b29aaa

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 35434ae67ead1b88e646bc172142ffb0bbcef35aa3440bbe1c220e4717d49c2c
MD5 224bdb8fec4c95f96f4beaf8be20f497
BLAKE2b-256 264d733d3d7eeffab7119139c08e33c5a426ffd81d8f7a50aa1a95f39ddae62b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.10-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 dfd9287ffc2803db461f5bc2055af838cc1bcaf6b9ad31275818b97dc2e012a7
MD5 7cd06b26b167d9e3a884a9ccba0da724
BLAKE2b-256 786733ebd20888d542ab32f3cd4a79f1d4dae61ad268c2e339b8293e51c4941a

See more details on using hashes here.

Provenance

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