Blast Futures Exchange
  • Get Started
    • 👋Introduction
      • What Is Blast?
    • What are Perpetual Futures?
    • Bridging to Blast
    • Blast Points & Gold
      • Blast Gold Liquidity Program
    • BFX Points
      • Staking $RBX
      • Staking $RBX LP
    • USDB Native Yield
    • Referral Program
    • Index Price
    • Funding Rate
    • Deposit & Withdrawal
    • Trading Fees
    • BFX OTC Service
    • Dynamic Market Maker (DMM)
      • Dynamic Router
    • Profit / Loss Calculation
    • Margin Calculation
    • Insurance Fund
    • Liquidations
  • API DOCUMENTATION
    • Introduction
    • Generate Your API Keys
    • Signing with API Key
    • Public Endpoints
      • Market Info
      • Trades
      • Orderbook
      • Funding Rate
      • Candles
    • Private Endpoints
      • Account Operations
      • Authentication
      • Orders
      • Fills
      • Positions
      • Profile
      • Balance History
      • Deadman Switch
    • Websocket
      • Trades
      • Orderbook
      • Market Info
      • Account
    • Responses Data Structure
    • Vault Setup
  • Frequently Asked Questions
  • Contracts
  • Telegram
  • Discord
  • Audits
Powered by GitBook
On this page
  1. API DOCUMENTATION

Private Endpoints

PreviousCandlesNextAccount Operations

Last updated 9 months ago

Security

For onboarding with private keys, we suggest using AWS KMS service or Secrets Manager.

The Secrets Manager is a service that helps protect access to your applications, services, and IT resources. This protection does not require an upfront investment or on-going maintenance costs. Unlike AWS KMS, Secrets Manager is designed to protect text blobs.

To learn more about AWS KMS or Secrets Manager, refer to the official AWS documentation.

KMS

Secrets Manager

Examples

cd examples
python rest.py
python ws.py

Example Scripts

from bfx import const
from bfx.client import Client, CandlePeriod, OrderSide, OrderType

if __name__ == '__main__':
    private_key = '<YOUR PRIVATE KEY>'
    client = Client(api_url=const.DEV_URL, private_key=private_key)

    markets = client.markets.list()
    print('available markets:\n', markets)

    orderbook = client.orderbook.get('BTC-USD')
    print('orderbook for BTC-USD:\n', orderbook)

    client.onboarding.onboarding()

    order_1 = client.orders.create(
        'BTC-USD',
        19000,
        OrderSide.LONG,
        1,
        OrderType.LIMIT,
    )
    print('\n\n\norder creation:\n', order_1)

    order_2 = client.orders.create(
        'BTC-USD',
        19000,
        OrderSide.SHORT,
        1,
        OrderType.LIMIT,
    )

    client.orders.amend(order_1['id'], 19000, 2, OrderType.MARKET)
    client.orders.cancel(order_1['id'])

    orders = client.orders.list(client.current_timestamp - 10, client.current_timestamp + 10)
    print('\n\n\nget order list:\n', orders)

    account = client.account.get()
    print('\n\n\naccount:\n', orders)

    # check jwt is valid (for stage env)
    client.account.validate(client._jwt)

    new_leverage = client.account.set_leverage('BTC-USD', 10)
    print('\n\n\nnew leverage:\n', new_leverage)

    candles = client.candles.list(
        'BTC-USD',
        client.current_timestamp - 10,
        client.current_timestamp + 10,
        CandlePeriod.M1,
    )
    print('\n\n\ncandles:\n', candles)

    new_jwt = client.jwt.update()
    print('\n\n\nnew jwt:\n', candles)

    fills = client.fills.list(
        client.current_timestamp - 10,
        client.current_timestamp + 10,
        0,
        100,
        ['BTC-USD', 'SOL-USD'],
    )
    print('\n\n\nfills:\n', candles)
https://docs.aws.amazon.com/kms/latest/developerguide/getting-started.html
https://docs.aws.amazon.com/secretsmanager/latest/userguide/create_secret.html