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.8.tar.gz (43.7 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.8-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (468.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.8-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (452.7 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.8-cp312-cp312-win_amd64.whl (324.4 kB view details)

Uploaded CPython 3.12Windows x86-64

bulk_keychain-0.1.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (468.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.8-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (451.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.8-cp312-cp312-macosx_11_0_arm64.whl (405.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

bulk_keychain-0.1.8-cp312-cp312-macosx_10_12_x86_64.whl (435.1 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

bulk_keychain-0.1.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (469.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.8-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (454.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (469.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.8-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (454.8 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (469.9 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.8-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (455.5 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

File details

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

File metadata

  • Download URL: bulk_keychain-0.1.8.tar.gz
  • Upload date:
  • Size: 43.7 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.8.tar.gz
Algorithm Hash digest
SHA256 542a83742e039bdfdd80a00d94555a517a6f76af49c7c3209a099fe311eb6e45
MD5 4f4e4d7e4d1ac58857e4058e1c26ba10
BLAKE2b-256 520aa6209d6ec13a153f8c0026408dd833cb7d33990ab233ed7eba86e42a2add

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.8-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ff64d95cf30a53b8adabf793b90ac49cf769825b10e5edd8d350faf427440dae
MD5 09fe9266c212e3b101f74f80d2f6da46
BLAKE2b-256 d89103bb2c743084b453009c7cdeb8bf09e006bb8c34ab95055f6e15434056cd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.8-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f53e0ef9acf3d31a89b2be1a648aebbb0a67dce6bd780d8332015946550430ce
MD5 868c428a9d62d8c80fc666fa0d2de22e
BLAKE2b-256 02a452c28eda209b6c551df650f65c5f62d6e1d4c59011f3ebc9922e7d81dcfe

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.8-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9b52f230b92033a7dd37912252a6f634cdbeaf8a6227bd153ccbc3870549abcb
MD5 dee43ee842469ecf2e1c234e9e100ed0
BLAKE2b-256 d73064dd8ea8a881ebe5562b63c25e202903b43f7a10842d6bb4d64b7a39cc0a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e8317203920916a9378213f8d0e467e905b975fcbe9b4b54fc3bf867d8dc9c33
MD5 3da710ffaa005de39438932868bbea72
BLAKE2b-256 131b9679f9fd03884b8cdcc1da4d336dfcc9c78a85682dcd156b2009985f087a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.8-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1fbcb1d9690027ff865f52dc5e0295a426da0528cd8f06bed8dfad7d307aec74
MD5 e684ca72cb7c2edcb58c588856a6d947
BLAKE2b-256 bd9609e80eef729341ef423d1ed419563463507b23396b8d887e232a10c2c4b0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.8-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2f46a90f18faa075b3989a2d4fb636a3ba56b5f9a8f4745d0d9855c89b766190
MD5 f642bf458f436b8a34aa6b929e748b2d
BLAKE2b-256 8e3ce89ef056b0fcd25180b5de5f5f40c8af2f457c7b6a9c026780c2bc1b44d7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.8-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 da56a333b5ddfe6dae6303a18d208dbb6f442498cccac95e54a38ce5b5a9f6df
MD5 1ecf9d95ca7c1e40514e1d1e69cd4a01
BLAKE2b-256 f6c1e7fb4f39fbdec9fef7aa97a64413bc4e522dcedb8ecfcd641f3495346936

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7b522d5f9fbcb648a652c9217a47e7137786036e6d2ab8e8c26903b1a3fe1f90
MD5 5e9c4e71500b97841783d9ce89f93dc2
BLAKE2b-256 d89b829d49ee3a5b2f73d53571b2a395fd08bf097f20218e378ac265deadc96d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.8-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 50c1d4e74c4426cf38e1f41f6af7b04588c524906a84f99cb16c2c73cd165f0d
MD5 cd2507809257a3591b84667aec2e0a57
BLAKE2b-256 d8a85031f0f5b34fce1d3269b05713e44b7f643a388684fa52feb8fab53ffc9f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 749b188184eb86bebd345730664da032f7f0a28d6d6c313b6a3f69f610f31f35
MD5 e8775d035612fbb9a161d3e003c89bcf
BLAKE2b-256 a07899ac3755a1a226c1711d84c65bbca8c17a084e1104735d35f899ac10df39

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.8-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7fdc65fb17ab69c4c7cc0a3c3beb616b068b8754ccc0fbc50c3e1733ba036664
MD5 f7fad1c805fed4e84e96c94525d3f7d0
BLAKE2b-256 2ae29f239b0fe1aa765330297b91bda17c1415dcb9959e54b296544ab7237c98

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a109f2630e8be4dbf345b49490377085b9939e5300876551a2d1e066769d8906
MD5 6708613942d114ac25f3f47701a208c0
BLAKE2b-256 ab85d1e586772c5521cc440ff9679f63444f1e24a3a19725666d03e4aa392a22

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.8-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b4a70a01942ef2174fdec5fdb53693a735d77aec70f6eefbc550888678f83648
MD5 067d07fa4e75cdb88407fb1f6fb14220
BLAKE2b-256 67374655afd222e85f6829c785df9551f4b0b00310378cd0eb45cdc401f984cb

See more details on using hashes here.

Provenance

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