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.18.tar.gz (52.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.18-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (490.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.18-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (471.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.18-cp312-cp312-win_amd64.whl (343.5 kB view details)

Uploaded CPython 3.12Windows x86-64

bulk_keychain-0.1.18-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (490.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.18-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (470.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.18-cp312-cp312-macosx_11_0_arm64.whl (427.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

bulk_keychain-0.1.18-cp312-cp312-macosx_10_12_x86_64.whl (462.4 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

bulk_keychain-0.1.18-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (492.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.18-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (475.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.18-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (492.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.18-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (475.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.18-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (493.2 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.18-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (476.3 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

File details

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

File metadata

  • Download URL: bulk_keychain-0.1.18.tar.gz
  • Upload date:
  • Size: 52.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.18.tar.gz
Algorithm Hash digest
SHA256 afe7c3417acae297d3f9d4dbf82a356144ee960a7b8aad57054afc1ae3e6fac0
MD5 88d4cd29ba52c6d742929a5b9fb4a1e7
BLAKE2b-256 c86af39137f6eb2ac6f52adf3bf72e33624dc32810c002992e8f341b032b4bb2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.18-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 45fc105325d29cc7ec3c41b6f3e7c00b6a2a96c9fe61882410e4bcaae60f6542
MD5 aed982eee2df477ca92d8d93ab4418f0
BLAKE2b-256 9c0b11f966c92d1d4f1db0d96ab416a4dcf92097949e74bb95684884491c9ac5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.18-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f4dde00b077356ec43433de8c7fb80b537aef203a2c017d4c834c210675bb3e1
MD5 c0e5fc5165502c24bdaf3b39fd75c963
BLAKE2b-256 a47e31fdc71201f7f960f150caa65794887fbcf74ee3d40d34192229d7693612

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.18-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 71ef42821244757895462e0470ae1e8aac1c46e847c22995fef0fdb7c666e405
MD5 20eb18a4b534327b9f3b409ea9c9b96b
BLAKE2b-256 208438857c522c2f3b0bc07883226a7dd41e7790c69366e564f377f25fe7ef8d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.18-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 78f28acf91ddaad0450b2cee5012dd8735162c5f3fe0c50698e8c4571f12bf6e
MD5 8453b8fae80dbd7e1dd58ce127e2982d
BLAKE2b-256 2b70ffef3ab316d94da1eff789e1bf4b54e872b960e0a71f02f07c62766a54b0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.18-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a50de51071e523e3c4aa04252669a495f960ef78760896f1aed63c8863271fa5
MD5 06bd9034f6baec3af6335f3c6da9438d
BLAKE2b-256 f0a43ed6f1ab65d22b8047afa26ecad9adb5b7799cf5b8dc698e1ddf50aad210

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.18-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c23971d42d3c434ba68bef22f4235cf0aa617f49db57baff1d5a4da244e10f65
MD5 05acc64a8a7bb20af26c0a62684a047d
BLAKE2b-256 7e9d782cf8b069508e476d6a5c91081b7a99ba6d23ae6ffbb9d1119a1bd31f45

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.18-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c62ba87c387b1019d7ce4af9205e5fb2424b66fb9692e9fea9d8ba81b4436efd
MD5 41505ac4921432041f61d24f122b4572
BLAKE2b-256 38f15bf5ca4aeb7fcdea491f5f402f9513df63a8557f1c2220992969a83ec226

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.18-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b39123e2073198c40e021322840f4d8772aa7012a6c93fb15f122f03bbacedfd
MD5 d6dc0c5a6fe2081badf353ee9f3c91d1
BLAKE2b-256 34ab382eaa8ebfcb59e960341cb31de6f4db5b6fd5f8a01f2579fa1ddb4dacf1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.18-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 49baf00381071fa403a2ff2ec8fc3b42e02c43b6358b6a658704e5df3b110acb
MD5 a626f0155f90dc40f14b9945d7f1f4f6
BLAKE2b-256 7dd0df8f1da48e992a6daadf25cad47d5a9de22f497ec3823c893416ce00696e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.18-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 15e85379ac649660da7f5b8c73478a5f245a0c1ce2a2503ce7fb91d482f88860
MD5 4586b07c3e58167aa91390f20763f32b
BLAKE2b-256 985e9529138d845e9d2bff462e63e0d9c0b836f49dbf94b077d585cf3fa99443

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.18-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3ab0de46a2c223474332537756b7eb1fa0c81b054aa61185522ed9d087fd5c5e
MD5 8aed2b36b074938646863ad81b3026fa
BLAKE2b-256 027592a7dcee506b39ba06f7b0b67ee7cd9860d1f6dbffa5b0b2138cbf11eea9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.18-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6eaea45d670462e1126178de9a7a2611a110f04aae6b6e792f4f4c1106ff12b0
MD5 f8110c4c102ce3a2b65a0a09f377be78
BLAKE2b-256 529e085ea9999b04d945a186decd2c9d582410c5e553f39a507ab8a1f2f71eed

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.18-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 09efd97ab3a3c098f5555e69de2e7b31a3cd2ca17f735fad067b8fe099f1dfb0
MD5 97ec5e0bde2b317779578e5bec627725
BLAKE2b-256 9c56c95e08e50fdbeeab3ba4cdfbbb09d8102790264109eb1ac935c70863ae1c

See more details on using hashes here.

Provenance

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