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 and optional signer are supported too:
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",
    signer="optional-agent-or-wallet-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.6.tar.gz (40.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.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (464.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.6-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (447.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.6-cp312-cp312-win_amd64.whl (320.9 kB view details)

Uploaded CPython 3.12Windows x86-64

bulk_keychain-0.1.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (463.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.6-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (447.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.6-cp312-cp312-macosx_11_0_arm64.whl (402.5 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

bulk_keychain-0.1.6-cp312-cp312-macosx_10_12_x86_64.whl (431.5 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

bulk_keychain-0.1.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (463.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.6-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (450.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (464.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.6-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (450.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (464.7 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.6-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (451.2 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

File details

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

File metadata

  • Download URL: bulk_keychain-0.1.6.tar.gz
  • Upload date:
  • Size: 40.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.6.tar.gz
Algorithm Hash digest
SHA256 d621d2b641034a730b70957c982ede9737ce8ea18cefa2ef95e9aefcc0763ee3
MD5 44a648da80eb121c0f82403fe94b4580
BLAKE2b-256 6353042922de870594ac85c038518824a9e6c15d627c370441d77a2407f8663d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e903b2a6657c815832a2e5f3f3b459a4c507d0ca41de7d26449b3b2f03967011
MD5 c06b52ec829a82a6da821a036e6927a6
BLAKE2b-256 626b7608c6ed6e58aa3cf7dbb10d3a5d4e52b76c503dfea824aa6108e18fb799

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.6-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e08354f0405a8831862570a7cb9b7e3c1d30544f1249476c7315097c6847faff
MD5 e8c2c45321c9d6cdc3fbf6f9ac5727fa
BLAKE2b-256 b5cf4d792fc57cafcd001f4e2ce96381f85ae43315a8862f669fde52b060bcb0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 194cbeb74fab2183a9f728b7c3f650d0bc02dc36f6c70d2c3e6bbdc39ff05dec
MD5 948a945d0cb7eaaf9501d038373b1671
BLAKE2b-256 5f8eb39c8033c4c4a78b05365f0694061feba17c78c95e9a21d0acf31b7d1704

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 171b2d6d30f43f284af39c8f0332fec12efed32571c9a6445b884432aecc0121
MD5 db2a5104e183ed9ec6d9a8519e6f8b2c
BLAKE2b-256 15b0c4db1e137954d7d9d36bfc4063ad890de22009bb0d2006ef1d50a2372ecf

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.6-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2f8a6c1fc033c06d3a5772ef5d3ef3e73e47a9085a291141e6a3a226b8e398f8
MD5 3565f2f5a0219e46c1ddbf6f101d127f
BLAKE2b-256 710a4f3ec26ace57c58dd16fd5172cfdebb09e2d4de2cd90efbc1900c1737af6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ac0d63b5a548b8970eb03b7a173b5e6ce37688f22ac17ad3c7e9946c292029bc
MD5 be438e7ac6737dfd84035976e6866e39
BLAKE2b-256 2bbb4cf94c8586315b82acd8081d129bf43acbf4f36a1693d1683394f34ea746

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.6-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 dce5b4b1482dd6d8d5265044dcd9d55cca5e82bd65a5e92b09a53cbcac8c4595
MD5 858acbeaa95a2bd229b14c83f8236d50
BLAKE2b-256 e5313806f8705c143ebb43bcf53df2d65318b5f25680b258b36948676da2b729

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 230172067f74b6d2e68c6a3b3bb26efdcd6df68c315374864f2a9d7d0a8c17c7
MD5 8bbf0f77da309dcd57f6a033eab35c67
BLAKE2b-256 2f402c9a478f385e79dd8060b29b87edc0767be75d9eca7ca33c8236fbfd7636

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.6-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c8adc12097213f5174f0ccd6198a522febc59f1288d086ca58469c9a6dbb8ec6
MD5 8684fe08ad978fee4d9eeff25ea64c60
BLAKE2b-256 0e1aa0390c6f0b1f2ad2ef884effb8fe3708cf8591d43eb4b5806ab35dbe8b0c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 36aa6fd2324204618c487511c3b92b4bef215b62c7e3f07ee8a10448e5fa1b0b
MD5 a132c5190af93d8af986650f88efdc65
BLAKE2b-256 0f4d9faaaf417a4b78196342785a84a0c1e4df7a6a629b2e8bded0f0fb69e72e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.6-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6ae19b8151776825b66cbcf5612e127e572a265bd602ee1909b593df8993f78e
MD5 9daab578db7f293d036d52f2c56384ff
BLAKE2b-256 edce87a947aa18ac3b8a4f244530654b9eb5d63526d3b21534145a2bafaf0254

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dcf543675018e07440a91b737163f014166dbd42f63d40f1858a6ebdbb6d39cf
MD5 b9948924c36bc23bd70a3036181269ea
BLAKE2b-256 1f536199549e65e3951431b924dbf520a102a90b08055932b600282300b0b785

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.6-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 be31d134800e9e92e2d80d0406f174561fe22fa84685055b16a95e21f333bd81
MD5 291e296d2160c02a2fe858bdcb82e6b5
BLAKE2b-256 e5501d8b89fbd943ae8b2e7ae9f8e6b3626b045d0e9f8a7058f0e080fe0425fe

See more details on using hashes here.

Provenance

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