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.15.tar.gz (51.3 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.15-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (508.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.15-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (487.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.15-cp312-cp312-win_amd64.whl (358.8 kB view details)

Uploaded CPython 3.12Windows x86-64

bulk_keychain-0.1.15-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (508.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.15-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (486.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.15-cp312-cp312-macosx_11_0_arm64.whl (441.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

bulk_keychain-0.1.15-cp312-cp312-macosx_10_12_x86_64.whl (477.3 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

bulk_keychain-0.1.15-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (510.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.15-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (489.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.15-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (510.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.15-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (489.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

bulk_keychain-0.1.15-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (511.4 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

bulk_keychain-0.1.15-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (490.9 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

File details

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

File metadata

  • Download URL: bulk_keychain-0.1.15.tar.gz
  • Upload date:
  • Size: 51.3 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.15.tar.gz
Algorithm Hash digest
SHA256 4758ed99ac902091388b8e7284913523b12010bf39d8601c15d4df2c3bc266f9
MD5 7b4b043ad5a89701c22a85f54cfae44c
BLAKE2b-256 129f5b01d04cfdd22b0e915c683938b7e3722d8194f624369d5b4bf3034bae43

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.15-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 32cb5e8c4d170e46af08aa942120fd1714dfef9dafc4be25e0a3ef7e2a4f93cb
MD5 e4fc304adc2381d203dc624f679d7780
BLAKE2b-256 6e347cbd808508fdee82f4b6ee831b6c3ee0772327184c6830c081f902c0d718

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.15-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 83cac47cfaf2c3abd5cacb546e7bddb589fd506d68535a93c8df78b228da883d
MD5 e2f3b072f029c950aa09eacc4bcb86a4
BLAKE2b-256 6545059d6c76116c85f4562d0eec461cb9fcb6dbcb12456b508cb3fa1b50f49d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.15-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f7ca89423a6afd4428004d9c97ad057c594730b9fa5ed7fb1864d2d20a96854f
MD5 1cdaabce15875806e47b880313592bb0
BLAKE2b-256 cafc668c0466db924e1f56df6ead5fbc0dda9f573068cb11eecd832a691ebbbd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.15-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c92e9e27de7c0744ffb4a2fff13217eb822e148d75d3cd29cee960c511122b44
MD5 a5e7cf09294da7ac95be548c74a386b4
BLAKE2b-256 675eaf27f7f356fde9341cefc6c997cfdf468c5668a4e536e1beabfecf29edfa

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.15-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b3cac9738508e36357616e5ae3e5a95bb0b4ab9afcb86230b9876b2795360519
MD5 3815d5a8216533958ec2c760d7be77db
BLAKE2b-256 34968daec7c4685d6bb82ef29c90642c211b2225c40a887dac066e6bae736b85

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.15-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e05a97aa27685ba02a73cd6d66d3903d63e5a7ae12038b4880ec4695d90346af
MD5 5a6db80ff0ba2a4ec8a2531a02feb2bf
BLAKE2b-256 5d4eac48bfb2ca699d570b5d2b5ebff3c219bd362738f8d7fb606f06986be389

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.15-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 adc4e2f7c44b552c72a35591f654bddc7a13c29129368b9e96e11d9ccb3e72af
MD5 1916102ec19395ffa7e5f68bc16da89e
BLAKE2b-256 f1b7bcdb10376e19e96d3ff945baf6ff2e94b2974bd331f9c9b2ae3abf04bc4c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.15-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0fe84f105ee452bd3715a1bb73330054613cb71ac5a2a47670ee462f3d41d1d3
MD5 448dfe041867713f309fe014c940c67f
BLAKE2b-256 78af32b63fee348aa3a916d297f0f37bdffeca2f45d5bb88680b2c3722464cac

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.15-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 371c0daf5344fc1177bbfccc33fc3379739751d5249033e2f262d48feffa2044
MD5 32a2a58284de942522a0b786f302eeb6
BLAKE2b-256 826b87f1b0b62748a3f6182be9dd86df989c390bed228b93a713646841491384

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.15-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0fdb1ce76f2246be212a647397413260a65117b6021fea24aeff531d611a15d0
MD5 3e2aad587552bb9194301f9058a674a4
BLAKE2b-256 4aa740a3cdb204fe947ddfaed271f917cf4cca28e0343623b358a9222628c633

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.15-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 133a52cde414fc53def39671553f78d7ca2b228c99c31a25db3bbc1ff3baf217
MD5 6b1c2fc4e65f97a09dbb3e594ec2e1cf
BLAKE2b-256 b1fb5bec41c3e360858a14c67e506086558a541e43c4860b49f0307204d522c6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.15-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 254c78a21aba2d66611a1b3df0e0600eaebcbb0269ec835bea039e933a513c83
MD5 722f0de4e1b80e57829a7015a29582de
BLAKE2b-256 9724632cdb4e1d05c238752b9c24efa6c94c3bdb4a77e5e8874203f73bde0ac8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for bulk_keychain-0.1.15-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 10a08eeecc3656517194da7d0a42482df7ae3b5a8cf24355e1e6291fc251a2eb
MD5 687be8da931ed6c6f34149e734438334
BLAKE2b-256 0006ad5dca95c113a634ea28941cd33f0a1a2bf725d25eff1a7bfd86d895595d

See more details on using hashes here.

Provenance

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