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.7.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.7-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.7-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (452.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.7-cp312-cp312-win_amd64.whl (324.9 kB view details)

Uploaded CPython 3.12Windows x86-64

bulk_keychain-0.1.7-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.7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (451.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

bulk_keychain-0.1.7-cp312-cp312-macosx_10_12_x86_64.whl (435.2 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

bulk_keychain-0.1.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (468.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (454.3 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (469.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (454.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (469.7 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.7-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (455.2 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

File details

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

File metadata

  • Download URL: bulk_keychain-0.1.7.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.7.tar.gz
Algorithm Hash digest
SHA256 52e655750c5f8a1a8284444ceda133aeaec7b137fa0b9b6f79293969e55265d4
MD5 12c7c864d0ff73477040d10a9aba56b0
BLAKE2b-256 4c93a554516df771f19d7c88f321c11db26fe5f7737dc66c87552f52916e1c94

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 28c58c7b14b44ee1b7cd1cdff6f24372fb48469920698d2a905a8305cbe1640c
MD5 5db04166f849067cd06a39b910a93eeb
BLAKE2b-256 5a2c29d59bec080394cd957ab45d3360cd6c1ea9b6a5e9c16b68187787946259

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.7-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0891a81327d5886a59b0033dc04839a4e988dd84453dce1cba1ade66c7f36784
MD5 49dffb0f7eb6a007bf0d7970e136a4c4
BLAKE2b-256 d1999819821c321d423d720363788890c3f4d9038f96d6f8fdae8f521161c330

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 bb98abdd091972384b591ad802d38c52f270392cfc1a7d56026241c4899c6d77
MD5 d886bacf5b86d3a45eb407858b5466ec
BLAKE2b-256 0a383a0ac3dfba6c677bc1c8d39087fb14f375987c414edfc0037d45f8eecee2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a9b3a5c99edbc3eb5188f2e5621362135fb6d4dc0a50b4fdf9107379d04ffe6a
MD5 17cc81ad14d8cbcf59eeedaa9fef336e
BLAKE2b-256 5863c2f44dca19c3c6dff73405b3f3aa7a34143f6750429ac85bbb02993b5670

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9d1453991aa4f0f1423ee8e074446f0bbdb4528919fadb4bb1a90d4f552e5472
MD5 a2399fb76f40c38d6300cfd8f0f8e5ef
BLAKE2b-256 b5f6801e34c01996881064642d3ca6ba8573eb7b7af33f6db69a92d974350c03

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5b4d31d9003bc658ebb3c9575a00b4ff641591a12e6db167310dae2d9ae24bff
MD5 7e50ee3321885892f81ca6962ad9fb7d
BLAKE2b-256 268d32bdeb38d198b17cc5777865bbc353c2273568813444a3e9abd4c82c6b6a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.7-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a3c894dd0cb5b157fa4bab943491e9dd18ea60ed41c6c39c2eba06ac037914d9
MD5 de7c5df9104edc00e7c6143bad77a378
BLAKE2b-256 1f3f3200c228e6a03c92ca230e336cebbc1570b6699a9f5a0ff0cc970525cfeb

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 595797f9f24f5ffa3e1dd61d8cae628700d3c418918a8f8a63a1824e1e6acb4c
MD5 b69e8a0ce3cc5f5cb4c7d5cb3b9a243a
BLAKE2b-256 ab58befc535368f00ab0e963ad563567b31ba1e184eeac372ac9cdd975b2816e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f65bbe05dac72138197e94d18dc11bdb837c63720dc8c44e5499ab1580ac52df
MD5 284f2cc2f985701db08dcafa2761e51a
BLAKE2b-256 628fa154c8abc8dfd2579f209df6dde43e8398fba527896a46ba275cc22e3e52

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 476774df544c1c576b94c6023d6522868a2f66f13b0a16db95e95e8df404fac3
MD5 0bff7af52fbba49d6ef4e3398c9e2466
BLAKE2b-256 61d8361794cd6748223b8fc96a84988b6ddbba960232d72ffc5ee69a03ea2571

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d84c3bea10ef47b8507885d882929cb9b8dc3f74e7472b6dfd8f1d9a9e511287
MD5 0c74f090b9218e27b01bb8154aba807d
BLAKE2b-256 48bb4c2eab02b51f17477edfa26d7714f0880746d181da98df9e2f8dc44713c1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9d7e1d9793e1736cae3182dfce232de991bfb4edc4b08c1e48fde33ee97c66a3
MD5 cf6d6a35df2fa43edd80bcb4fb16bdff
BLAKE2b-256 5363d8402148c915f83c04445e48daf4a94051a0b74ddd93e256dceb479c53ed

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.7-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 43d16988b2381161676c0a297275088759aeee74378cff80881e3d17a35ab6b1
MD5 08d4c3f6a057d1d67c314fe8d403d244
BLAKE2b-256 dd853ec99d3b02aab79a9bd61f362c100ef4333b027c91ee94bd74071e44d0b8

See more details on using hashes here.

Provenance

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