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.9.tar.gz (45.6 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.9-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (484.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.9-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (463.5 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.9-cp312-cp312-win_amd64.whl (338.1 kB view details)

Uploaded CPython 3.12Windows x86-64

bulk_keychain-0.1.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (484.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.9-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (463.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.9-cp312-cp312-macosx_11_0_arm64.whl (419.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

bulk_keychain-0.1.9-cp312-cp312-macosx_10_12_x86_64.whl (450.8 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

bulk_keychain-0.1.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (484.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.9-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (465.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (485.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.9-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (466.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (485.4 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.9-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (466.8 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

File details

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

File metadata

  • Download URL: bulk_keychain-0.1.9.tar.gz
  • Upload date:
  • Size: 45.6 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.9.tar.gz
Algorithm Hash digest
SHA256 3575840aed7a373b77c6a958dd3e9cae80b266530292708a65924a1e8d6536f6
MD5 a18df15a7825f159457daf4531f30b69
BLAKE2b-256 5b00bc60e30b786da6beed645548ed7bb5cf644928602338cb195792f17d5d2d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.9-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6ea264447289106e40b36b47584a08804969e724b261738f9ee4ebc5b0f1abaf
MD5 baa1fa2f0dfdacacb2588b338af06436
BLAKE2b-256 0a8048da5d9753396192956af401dc63aebee4ee8be2ec5a5868cc9fc5fbc783

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.9-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f39f31e95a9207b0ecd6cdac96ef9a1d2970fe4f9e513df9d3d78fa01e3d8a7b
MD5 34658fb35da36e57e557e8a9d426ba55
BLAKE2b-256 7d40f8ab2627f8a3d6ac080966d217997f8779d6e24754e8952da7db8a95ee87

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.9-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6f13b8b88d186622b828c4c6f37674bb643f7cea1c53bc89f09b3d03dba1610a
MD5 8d5060c4528cab97d32901cf2b6b8f9d
BLAKE2b-256 4348ba574c3df095b1883ba346f57449de4a5e56d842de082b550cc7feb55fb8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 52c65892faa3a2bdc58725499bb7e3b07589e07bdc60379faf89de9e67b82e9f
MD5 fadbb6004bce51ffcdf9494f0773a947
BLAKE2b-256 ae39a4364e299d083018351772b96c1935011c7f4180733b63b34eacc9ec1a13

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.9-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7b5f240273f82ac6f491eefbcea47117e4950488da828524d844416271e5cc33
MD5 5dfcafce3b23759271da7240f58c953d
BLAKE2b-256 3592dbc0a44ab32a3a11b21c4b23790f3e6ab5c645ea324a896fe22b6a4ceee0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.9-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bdf87f323a93c4cd9663a209420181d14db109208f13aa3369fa94fff4985f2c
MD5 730f9e02e46a780988c4e7bd875d8e50
BLAKE2b-256 377ac7d917fda754f7aa21ea748e75af812b099ca2853cbaa98783c6baa8d60c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.9-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 05ed858bece3e4279ae272ef56b8cd1b6526128a863c4b1863abcf598b8b1e16
MD5 8f07eab3a0080179355dd9ddaeadb4a9
BLAKE2b-256 c8c6366bb33e2bc53196866aceff06c4635d846018e62b7c835fcf0f1b74bca0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6c04328548237133819cdf0f3b4505e0c4adcf85e522b661a6d88f86c6f92ae2
MD5 f98e7c734b3ae8fa72b8924aa95b77b1
BLAKE2b-256 17e62ca0231f2e6ea337289fb76fee108bcd9e19a120a1dd5194be5f4328823c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.9-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 75c8557d8b87b313aa53b485ec9cb1da412eeec090208fa020d36df1d22d5505
MD5 00f288d9093fd9c18f5800fbf54ac0bc
BLAKE2b-256 b644824ac252b453fa84d02a6cafa8f6602c6bbb1e437752164849811eb72106

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4224750b38da4d9192435ba31e46e17ff3e7fcfe7b1aeb0cd3754aadb2461da7
MD5 e54ae8a035d18d0b4aef6e0022a741b7
BLAKE2b-256 de3e922a37e687045428cbe80f558b29f56863d05389836608b28af70178dfcf

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.9-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 dafa00dbb1fcc1144ca7eba39e274baf7b59fb21a40ec30ccda1134322c74976
MD5 9950a70a16182292ad1de60eb38aa097
BLAKE2b-256 d7f693616b90183c39c82b7f44cdaf04c45c08dfb600b5e5963d765bc80a3bdf

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9615f92b893276679ac3b4f644cb94fca2e3d00ae80b354312e40e5b75482794
MD5 3fee1cae1d33c050512bc96da6a4dbb2
BLAKE2b-256 5c2e0d0cbf00bd957d7c4e8e8e59ea82c54e72567dd461d75d2b3937cb0b0321

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.9-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f7ea47e34929abbf47ac8170188ed4e9a3f139d1ec3f949d9c75dd3374aca318
MD5 4365fa018eb4d2fceb1b5385a1fd3f82
BLAKE2b-256 24a5789017fb2ac31c527516a07b6a8fd5582689b7c388f4ada90548fc76257d

See more details on using hashes here.

Provenance

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