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.13.tar.gz (48.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.13-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (501.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.13-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (479.5 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.13-cp312-cp312-win_amd64.whl (353.9 kB view details)

Uploaded CPython 3.12Windows x86-64

bulk_keychain-0.1.13-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (500.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.13-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (479.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.13-cp312-cp312-macosx_11_0_arm64.whl (435.8 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

bulk_keychain-0.1.13-cp312-cp312-macosx_10_12_x86_64.whl (468.2 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

bulk_keychain-0.1.13-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (502.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.13-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (481.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.13-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (502.8 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.13-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (481.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.13-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (503.7 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.13-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (482.2 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

File details

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

File metadata

  • Download URL: bulk_keychain-0.1.13.tar.gz
  • Upload date:
  • Size: 48.7 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.13.tar.gz
Algorithm Hash digest
SHA256 335c28e75029ca9474d7324eb28329cf2cde93e5fe94460008a773ee020461fe
MD5 d34e1fd9601a4a76e8cbcb36a2f896d9
BLAKE2b-256 588bd28e09879c16f8fb42bb9b06e94ffe34c24436d2b7d578c7d9edf24f3440

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.13-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a53d25e9f4924b806159219bc80da3a22a36005a9bf94ada56550c3b44ba5969
MD5 d93f9dcf079bf12383653694a815e975
BLAKE2b-256 6656259d8bfb1e4a08dab835ab03e37dba75907017e4d37ceaf1c22fc693cdfe

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.13-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6edad753ee37f74052f8493f16833d0e292e359d45cc72814982721c9f30589a
MD5 5266bb2bb4758ca664642cb83ffc5217
BLAKE2b-256 5902b87d12ef88c176254dc832003963e8f54073b6b62c31188d6f07bec66e4f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.13-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 7292d0611d6930051b358bba08ff17aae4d11d3f98a660bf3de35e181962ff9b
MD5 ebbf4559cf64ca5ad746aaf068f389d4
BLAKE2b-256 041e4196f367654d0de28686ef5d1ab1f39d8d352fe7a285df21771fc1584444

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.13-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 30275d36c367d8a47adc4e05d5e57c735a3f830f09650412b7059f8d2ed3f220
MD5 5ed9bff772365f4a745c356fc148dfce
BLAKE2b-256 6d369066374ebc5dd964caefe3e735f2526cd72ccf22299e2b4b17353df25a9a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.13-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a105cdcb8f1c92839fdb84a54967f16eb3d5854f48c230a6d8059f870673561c
MD5 8ec72e4c4677a6fe30fb08ce7de6f24f
BLAKE2b-256 232cff72f0be25839a0450c6fd20137fa04ff5871c8535d7c170d1f52d08932c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.13-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2cabc8bd5c25e0a0d7feee2467e96b809cfeee60e52485b67f9a3b09ad2c8485
MD5 4f4a99a8cce0e6a38a42521e192fab13
BLAKE2b-256 8fc1e3a199819e9a01153074db63bbbb3664fa2f67dae961ce188f09dc9148fe

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.13-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0cab980530d6173e183b696caf54ee0d2b27171aa4d63dd4ce5bc1106c30495e
MD5 8463c981f5f94aebbe62f03c0dbc55f8
BLAKE2b-256 fe4d5589ca229afdcd22eed02eb5be8742cffbcbeefcc7311443561e88a92c51

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.13-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3157f2751e4d7c119b6b689782ca78c4aca6b755e3eed6eba64f3de3b8d85c97
MD5 3c5e8f8aed0d4c9df606eb0c5b24dee0
BLAKE2b-256 1dadcf63466776cade488ba155b51c88e05c1d58027f35d4a8cf1e0563417f6d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.13-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b5a77633de8178ed6b87f29fb2d64d1ed893f71dd9eaf6e2c432e4d4b500df79
MD5 813702937d3487a0e5343bbfe849518e
BLAKE2b-256 bcefee991d433d379aa8a60b44b396670af4c1477e0c21763525f0dd79a1b093

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.13-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5ae3af3521db1cc08b698de5bf7dcd8158a25bacc3ee0e7925f0920c2436a1a1
MD5 6356773aed087ad2c0056c1ba18ed9f4
BLAKE2b-256 ced3bb2442f5f7a69451903e3b8ace009d92785d35a288d2cde97e5dbf1216f5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.13-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b954231dd17b072d20828e93a146761fe9e1ad78fe88024f91b9cba71c9c1402
MD5 d670f0e45ceb89d3d03b3ff62ea0045c
BLAKE2b-256 60a6bad9bbffecd4c850d358b7b385da79bf10b7b230916307234672a7af9897

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.13-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 99d0c349acb41b7384cf6e95ac438c8f6ba54bbaed76c7b849e6ca88c1248292
MD5 e8076163f15c1677f6df1e15450a6f1d
BLAKE2b-256 a7ee41673dfda14bd7bc8db1c291aaf4febfc643f015620b92746cb32cd61e08

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.13-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d9c73621048723d84de360c92e79209397162a5779d2606129a49d106503bd19
MD5 54e58fef66d3743580892753eef1dca4
BLAKE2b-256 817644134ab4a6e0fd25a8b35b600a77b2d6f7ea08e7f57f212450215bb17381

See more details on using hashes here.

Provenance

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