API Reference
Detailed API Reference for BSX Exchange SDK.
bsx_py.instance
- class bsx_py.instance.Environment(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum- TESTNET = 'https://api.testnet.bsx.exchange'
- MAINNET = 'https://api.bsx.exchange'
- class bsx_py.instance.BSXInstance(env, wallet, signer)[source]
Bases:
objectThe client interface to interact with BSX Exchange
BSXInstance will handle signing, authenticating, API key renewal internally.
Each BSXInstance works with only one wallet. If you want to use multiple wallets, just create multiple instances.
- static from_api_key(api_key, api_secret, signer, env)[source]
Initialize a new BSXInstance object using an active API key.
The BSXInstance returned by this method will not be able to submit withdrawal requests
- Return type:
- Attributes:
api_key (str): BSX API key
api_secret (str): BSX secret
signer (LocalAccount): signer wallet used to sign requests
env (Environment|str): environment to use (Testnet or mainnet) or the domain in plain text
- Raises:
BSXRequestException: If the response status is not “success”.
- static from_smart_contract(env, contract_address, signature, nonce, signer)[source]
Initialize a new BSXInstance object using main wallet’s private key
- Return type:
- Attributes:
env (Environment|str): environment to use (Testnet or mainnet) or the domain in plain text
contract_address (str): multi sig wallet address
signature (str): signature to use. Please read https://api-docs.bsx.exchange/reference/sign-messages for how to generate the signature
signer (LocalAccount): signer wallet used to sign requests
- Raises:
BSXRequestException: If the response status is not “success”.
- __init__(env, wallet, signer)[source]
Initialize a new BSXInstance object using main wallet’s private key
- Attributes:
env (Environment|str): environment to use (Testnet or mainnet) or the domain in plain text
wallet (LocalAccount): main wallet
signer (LocalAccount): signer wallet used to sign requests
- Raises:
BSXRequestException: If the response status is not “success”.
- create_order(params)[source]
Create a new order
- Return type:
- Attributes:
params (CreateOrderParams): object that contains data required to create an order
- Return:
Order: created order
- Raises:
BSXRequestException: If the response status is not “success”.
- create_order_async(params)[source]
Create a new order
- Return type:
- Attributes:
params (CreateOrderParams): object that contains data required to create an order
- Return:
Order: created order
- Raises:
BSXRequestException: If the response status is not “success”.
- cancel_order(order_id)[source]
Cancel an order by id
- Return type:
- Attributes:
order_id (str): order_id that need to be cancelled
- Return:
CancelOrderResult: cancel result
- Raises:
BSXRequestException: If the response status is not “success”.
- cancel_order_async(order_id)[source]
Cancel an order by id
- Return type:
- Attributes:
order_id (str): order_id that need to be cancelled
- Return:
CancelOrderResult: cancel result
- Raises:
BSXRequestException: If the response status is not “success”.
- cancel_bulk_orders(order_ids)[source]
Cancel multiple orders by ids
- Return type:
- Attributes:
order_ids (list[str]): order_ids that need to be cancelled
- Return:
CancelMultipleOrdersResult: cancel result
- Raises:
BSXRequestException: If the response status is not “success”.
- cancel_bulk_orders_async(order_ids)[source]
Cancel multiple orders by ids
- Return type:
- Attributes:
order_ids (list[str]): order_ids that need to be cancelled
- Return:
CancelMultipleOrdersResult: cancel result
- Raises:
BSXRequestException: If the response status is not “success”.
- cancel_all_orders(product_id)[source]
Cancel all open orders of a given product
- Return type:
- Attributes:
product_id (str): the product that it’s orders need to be cancelled
- Return:
CancelMultipleOrdersResult: cancel result
- Raises:
BSXRequestException: If the response status is not “success”.
- cancel_all_orders_async(product_id)[source]
Cancel all open orders of a given product
- Return type:
- Attributes:
product_id (str): the product that it’s orders need to be cancelled
- Return:
CancelMultipleOrdersResult: cancel result
- Raises:
BSXRequestException: If the response status is not “success”.
- get_all_open_orders(product_id)[source]
Get all open orders of a given product
- Return type:
- Attributes:
product_id (str): the product id
- Return:
CancelMultipleOrdersResult: contains a list of open orders
- Raises:
BSXRequestException: If the response status is not “success”.
- get_all_open_orders_async(product_id)[source]
Get all open orders of a given product
- Return type:
- Attributes:
product_id (str): the product id
- Return:
CancelMultipleOrdersResult: contains a list of open orders
- Raises:
BSXRequestException: If the response status is not “success”.
- get_order_history(params)[source]
Get order history
- Return type:
- Attributes:
params (GetOrderHistoryParams): parameters to get order history
- Return:
OrderListingResult: contains a list of orders
- Raises:
BSXRequestException: If the response status is not “success”.
- get_order_history_async(params)[source]
Get order history
- Return type:
- Attributes:
params (GetOrderHistoryParams): parameters to get order history
- Return:
OrderListingResult: contains a list of orders
- Raises:
BSXRequestException: If the response status is not “success”.
- submit_withdrawal_request(params)[source]
Submit withdrawal request
- Return type:
bool
- Attributes:
params (WithdrawParams): parameters to create withdrawal request
- Return:
bool: whether the withdrawal request was created successfully or not
- Raises:
BSXRequestException: If the response status is not “success”.
- submit_withdrawal_request_async(params)[source]
Submit withdrawal request
- Return type:
bool
- Attributes:
params (WithdrawParams): parameters to create withdrawal request
- Return:
bool: whether the withdrawal request was created successfully or not
- Raises:
BSXRequestException: If the response status is not “success”.
- get_portfolio_detail()[source]
Get portfolio detail
- Return type:
- Return:
Portfolio: portfolio detail of the current user
- Raises:
BSXRequestException: If the response status is not “success”.
- get_portfolio_detail_async()[source]
Get portfolio detail
- Return type:
- Return:
Portfolio: portfolio detail of the current user
- Raises:
BSXRequestException: If the response status is not “success”.
- batch_update_orders(params)[source]
Update orders in batch
- Return type:
- Attributes:
params (BatchOrderUpdateParams): update orders parameters
- Return:
BatchOrderUpdateResponse: update result. The order of items in the result is the same as the order of items in the input params
- Raises:
BSXRequestException: If the response status is not “success”.
- batch_update_orders_async(params)[source]
Update orders in batch
- Return type:
- Attributes:
params (BatchOrderUpdateParams): update orders parameters
- Return:
BatchOrderUpdateResponse: update result. The order of items in the result is the same as the order of items in the input params
- Raises:
BSXRequestException: If the response status is not “success”.
- get_user_trade_history(params)[source]
Get user’s trade history
- Return type:
- Attributes:
params (GetTradeHistoryParams): filter parameters
- Return:
GetTradeHistoryResponse: trade history
- Raises:
BSXRequestException: If the response status is not “success”.
- get_user_trade_history_async(params)[source]
Get user’s trade history
- Return type:
- Attributes:
params (GetTradeHistoryParams): filter parameters
- Return:
GetTradeHistoryResponse: trade history
- Raises:
BSXRequestException: If the response status is not “success”.
- get_products()[source]
Get all markets
- Return type:
list[Product]
- Return:
list[Product]: list of all markets
- Raises:
BSXRequestException: If the response status is not “success”.
- get_products_async()[source]
Get all markets
- Return type:
list[Product]
- Return:
list[Product]: list of all markets
- Raises:
BSXRequestException: If the response status is not “success”.
- get_funding_history(params)[source]
Get funding rate history
- Return type:
- Attributes:
params (GetFundingHistoryParams): filter parameters
- Return:
GetFundingHistoryResponse: funding rate history
- Raises:
BSXRequestException: If the response status is not “success”.
- get_funding_history_async(params)[source]
Get funding rate history
- Return type:
- Attributes:
params (GetFundingHistoryParams): filter parameters
- Return:
GetFundingHistoryResponse: funding rate history
- Raises:
BSXRequestException: If the response status is not “success”.
- get_api_key_list()[source]
Get all active API keys
- Return type:
- Return:
GetAPIKeysResponse: API keys list
- Raises:
BSXRequestException: If the response status is not “success”.
- get_api_key_list_async()[source]
Get all active API keys
- Return type:
- Return:
GetAPIKeysResponse: API keys list
- Raises:
BSXRequestException: If the response status is not “success”.
- delete_user_api_key(api_key)[source]
Delete an API key
- Return type:
str
- Attributes:
api_key (str): API key to be deleted
- Return:
str: API key that was deleted
- Raises:
BSXRequestException: If the response status is not “success”.
- delete_user_api_key_async(api_key)[source]
Delete an API key
- Return type:
str
- Attributes:
api_key (str): API key to be deleted
- Return:
str: API key that was deleted
- Raises:
BSXRequestException: If the response status is not “success”.
bsx_py.common.types.account
- class bsx_py.common.types.account.WithdrawParams(amount, nonce)[source]
Bases:
objectContains parameters for creating a withdrawal request
- Args:
amount (Decimal): Token amount to withdraw. For USDC, the minimum amount is 2 USDC. We currently only allow withdraw up to min(settled_usdc_balance, free_collateral).
nonce (int): timestamp in nanosecond that is larger than (request received time - 10 minutes)
-
amount:
Decimal
-
nonce:
int
- __init__(amount, nonce)
- class bsx_py.common.types.account.PortfolioSummary(margin_use, account_leverage, in_liquidation, free_collateral, total_account_value, total_notional, usdc_balance, unsettled_usdc, realized_pnl, total_initial_margin, total_maintenance_margin, has_pending_withdrawal)[source]
Bases:
object-
margin_use:
Decimal
-
account_leverage:
Decimal
-
in_liquidation:
bool
-
free_collateral:
Decimal
-
total_account_value:
Decimal
-
total_notional:
Decimal
-
usdc_balance:
Decimal
-
unsettled_usdc:
Decimal
-
realized_pnl:
Decimal
-
total_initial_margin:
Decimal
-
total_maintenance_margin:
Decimal
-
has_pending_withdrawal:
bool
- __init__(margin_use, account_leverage, in_liquidation, free_collateral, total_account_value, total_notional, usdc_balance, unsettled_usdc, realized_pnl, total_initial_margin, total_maintenance_margin, has_pending_withdrawal)
-
margin_use:
- class bsx_py.common.types.account.Position(product_index, product_id, net_size, avg_entry_price, initial_margin_requirement, maintenance_margin_requirement, liquidation_price, unrealized_pnl, mark_price, leverage, unsettled_funding, funding_index, quote_balance)[source]
Bases:
object-
product_index:
int
-
product_id:
str
-
net_size:
Decimal
-
avg_entry_price:
Decimal
-
initial_margin_requirement:
Decimal
-
maintenance_margin_requirement:
Decimal
-
liquidation_price:
Decimal
-
unrealized_pnl:
Decimal
-
mark_price:
Decimal
-
leverage:
Decimal
-
unsettled_funding:
Decimal
-
funding_index:
Decimal
-
quote_balance:
Decimal
- __init__(product_index, product_id, net_size, avg_entry_price, initial_margin_requirement, maintenance_margin_requirement, liquidation_price, unrealized_pnl, mark_price, leverage, unsettled_funding, funding_index, quote_balance)
-
product_index:
- class bsx_py.common.types.account.OrderStats(total_orders, total_done_orders, total_open_orders, total_pending_orders)[source]
Bases:
object-
total_orders:
Decimal
-
total_done_orders:
Decimal
-
total_open_orders:
Decimal
-
total_pending_orders:
Decimal
- __init__(total_orders, total_done_orders, total_open_orders, total_pending_orders)
-
total_orders:
- class bsx_py.common.types.account.ProductStats(total_orders, total_done_orders, total_open_orders, total_pending_orders)[source]
Bases:
object-
total_orders:
Decimal
-
total_done_orders:
Decimal
-
total_open_orders:
Decimal
-
total_pending_orders:
Decimal
- __init__(total_orders, total_done_orders, total_open_orders, total_pending_orders)
-
total_orders:
- class bsx_py.common.types.account.PortfolioProduct(product_id, stat)[source]
Bases:
object-
product_id:
str
-
stat:
ProductStats
- __init__(product_id, stat)
-
product_id:
- class bsx_py.common.types.account.TradingStats(total_trading_volume)[source]
Bases:
object-
total_trading_volume:
Decimal
- __init__(total_trading_volume)
-
total_trading_volume:
- class bsx_py.common.types.account.PortfolioStats(order_stats, products, trading_stats, total_deposit, total_withdraw)[source]
Bases:
object-
order_stats:
OrderStats
-
products:
list[PortfolioProduct]
-
trading_stats:
TradingStats
-
total_deposit:
Decimal
-
total_withdraw:
Decimal
- __init__(order_stats, products, trading_stats, total_deposit, total_withdraw)
-
order_stats:
- class bsx_py.common.types.account.Portfolio(account, summary, positions, stats)[source]
Bases:
object-
account:
str
-
summary:
PortfolioSummary
-
stats:
PortfolioStats
- __init__(account, summary, positions, stats)
-
account:
- class bsx_py.common.types.account.APIKey(api_key, api_secret, created_at, updated_at, name, sender, signer)[source]
Bases:
object-
api_key:
str
-
api_secret:
str
-
created_at:
datetime
-
updated_at:
datetime
-
name:
str
-
sender:
str
-
signer:
str
- __init__(api_key, api_secret, created_at, updated_at, name, sender, signer)
-
api_key:
bsx_py.common.types.market
- class bsx_py.common.types.market.Side(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum- BUY = 'BUY'
- SELL = 'SELL'
- class bsx_py.common.types.market.OrderType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum- LIMIT = 0
- MARKET = 1
- STOP = 2
- class bsx_py.common.types.market.OrderStatus(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum- PENDING = 'PENDING'
- OPEN = 'OPEN'
- DONE = 'DONE'
- class bsx_py.common.types.market.TransferType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum- WITHDRAW = 'WITHDRAW'
- DEPOSIT = 'DEPOSIT'
- class bsx_py.common.types.market.CreateOrderParams(side, type, product_index, price, size, time_in_force, nonce, post_only=False, reduce_only=False, client_order_id=None)[source]
Bases:
objectContains parameters required for creating a new order
- Args:
side (Side): The side of the order
type (OrderType): The type of order
product_index (int): Product to place order on. (BTC-PERP=1, ETH-PERP=2, SOL-PERP=3)
price (Decimal): The max or min price limit to buy or sell at
size (Decimal): The amount to buy or sell
time_in_force (str): GTC | IOC | FOK. default is GTC
nonce (int): timestamp in nanosecond that is larger than (request received time - 10 minutes)
post_only (bool): optional; default is false
reduce_only (bool): optional; default is false
client_order_id (str): optional; default is None. Max 32 alphabet characters. Case-insensitive. Must be unique among all open orders of the current user
-
product_index:
int
-
price:
Decimal
-
size:
Decimal
-
time_in_force:
str
-
nonce:
int
-
post_only:
bool= False
-
reduce_only:
bool= False
-
client_order_id:
Optional[str] = None
- __init__(side, type, product_index, price, size, time_in_force, nonce, post_only=False, reduce_only=False, client_order_id=None)
- class bsx_py.common.types.market.Trade(id, price, size, liquidity_indicator, time, funding_payment, trading_fee, sequencer_fee)[source]
Bases:
object-
id:
str
-
price:
Decimal
-
size:
Decimal
-
liquidity_indicator:
str
-
time:
datetime
-
funding_payment:
Decimal
-
trading_fee:
Decimal
-
sequencer_fee:
Decimal
- __init__(id, price, size, liquidity_indicator, time, funding_payment, trading_fee, sequencer_fee)
-
id:
- class bsx_py.common.types.market.Order(id, price, size, product_id, side, type, time_in_force, nonce, post_only, reduce_only, created_at, cancel_reason, reject_reason, cancel_reject_reason, filled_fees, filled_size, status, sender, avg_price, cancel_requested, is_liquidation, initial_margin, last_trades, client_order_id)[source]
Bases:
objectContains information about an order
- Args:
id (str): The order ID, should be an uuid
price (Decimal): The original price (in quote unit) of the order. Example 45000.1 (USDC)
size (Decimal): The original size (in base unit) of the order. Example 0.3 (BTC)
product_id (str): The product of the order
side (str): Order’s side. Possible values: BUY, SELL
type (str): Order’s type. Possible values: LIMIT, MARKET, STOP
time_in_force (str): GTC | IOC | FOK
nonce (int): The nonce of the order
post_only (bool): Post-only means the order will only be placed as a maker order. If any part of the order results in taking liquidity, the order will be rejected and no part of it will execute.
reduce_only (bool): Indicates if the order is reduce-only
created_at (datetime): Created at timestamp in nanosecond
cancel_reason (str): The cancel reason (if exists). Possible values: user/admin/insufficient funds/etc
reject_reason (str): The reason reason (if exists)
cancel_reject_reason (str): The cancel reason reason (if exists)
filled_fees (Decimal): The total filled fees (in quote unit - USDC) of the order
filled_size (Decimal): The total filled size (in base unit - BTC) of the order
status (str): PENDING | OPEN | DONE
sender (str): The owner address of the order
avg_price (Decimal): The average price (in quote unit - USDC) of the order
cancel_requested (bool): Indicates if the order is cancel requested
is_liquidation (bool): Indicates if the order is a liquidation order
initial_margin (str): Initial Margin Requirement for the order
client_order_id (str): The client order ID specified by user when creating new orders
-
id:
str
-
price:
Decimal
-
size:
Decimal
-
product_id:
str
-
side:
str
-
type:
str
-
time_in_force:
str
-
nonce:
int
-
post_only:
bool
-
reduce_only:
bool
-
created_at:
datetime
-
cancel_reason:
str
-
reject_reason:
str
-
cancel_reject_reason:
str
-
filled_fees:
Decimal
-
filled_size:
Decimal
-
status:
str
-
sender:
str
-
avg_price:
Decimal
-
cancel_requested:
bool
-
is_liquidation:
bool
-
initial_margin:
str
-
client_order_id:
str
- __init__(id, price, size, product_id, side, type, time_in_force, nonce, post_only, reduce_only, created_at, cancel_reason, reject_reason, cancel_reject_reason, filled_fees, filled_size, status, sender, avg_price, cancel_requested, is_liquidation, initial_margin, last_trades, client_order_id)
- class bsx_py.common.types.market.CancelMultipleOrdersParams(product_ids=None, order_ids=None, nonces=None)[source]
Bases:
object-
product_ids:
Optional[list[str]] = None
-
order_ids:
Optional[list[str]] = None
-
nonces:
Optional[list[int]] = None
- __init__(product_ids=None, order_ids=None, nonces=None)
-
product_ids:
- class bsx_py.common.types.market.CancelOrderResult(order_id, nonce, client_order_id)[source]
Bases:
objectReturned if an order is cancelled successfully
- Args:
order_id (str): Order id of the cancelled order
nonce (int): Nonce of the cancelled order
client_order_id (str): Client order ID of the cancelled order
-
order_id:
str
-
nonce:
int
-
client_order_id:
str
- __init__(order_id, nonce, client_order_id)
- class bsx_py.common.types.market.CancelOrdersResultItem(order_id, nonce, client_order_id)[source]
Bases:
objectReturned if an order is cancelled successfully
- Args:
order_id (str): Order id of the cancelled order
nonce (int): Nonce of the cancelled order
client_order_id (str): Client order ID of the cancelled order
-
order_id:
str
-
nonce:
int
-
client_order_id:
str
- __init__(order_id, nonce, client_order_id)
- class bsx_py.common.types.market.CancelMultipleOrdersResult(cancelled_orders)[source]
Bases:
object-
cancelled_orders:
list[CancelOrdersResultItem]
- __init__(cancelled_orders)
-
cancelled_orders:
- class bsx_py.common.types.market.OrderListingResult(orders)[source]
Bases:
object- __init__(orders)
- class bsx_py.common.types.market.GetOrderHistoryParams(product_id=None, start_time=None, end_time=None, limit=100, statuses=None, client_order_ids=None)[source]
Bases:
object-
product_id:
str= None
-
start_time:
Optional[datetime] = None
-
end_time:
Optional[datetime] = None
-
limit:
int= 100
-
statuses:
list[OrderStatus] = None
-
client_order_ids:
list[str] = None
- __init__(product_id=None, start_time=None, end_time=None, limit=100, statuses=None, client_order_ids=None)
-
product_id:
- class bsx_py.common.types.market.CancelOrderParams(order_id=None, nonce=None, client_order_id=None)[source]
Bases:
object-
order_id:
Optional[str] = None
-
nonce:
Optional[str] = None
-
client_order_id:
Optional[str] = None
- __init__(order_id=None, nonce=None, client_order_id=None)
-
order_id:
- class bsx_py.common.types.market.CancelOrdersParams(order_ids=None, nonces=None, client_order_ids=None)[source]
Bases:
object-
order_ids:
list[str] = None
-
nonces:
list[str] = None
-
client_order_ids:
list[str] = None
- __init__(order_ids=None, nonces=None, client_order_ids=None)
-
order_ids:
- class bsx_py.common.types.market.CancelAllParams(product_id)[source]
Bases:
object-
product_id:
str
- __init__(product_id)
-
product_id:
- class bsx_py.common.types.market.BatchOrderUpdateParams(operations)[source]
Bases:
object-
operations:
list[CreateOrderParams|CancelOrderParams|CancelOrdersParams|CancelAllParams]
- __init__(operations)
-
operations:
- class bsx_py.common.types.market.BatchOrderUpdateResult(code, message, detail)[source]
Bases:
object-
code:
int
-
message:
str
-
detail:
Order|CancelOrderResult|CancelMultipleOrdersResult
- __init__(code, message, detail)
-
code:
- class bsx_py.common.types.market.BatchOrderUpdateResponse(data)[source]
Bases:
object-
data:
list[BatchOrderUpdateResult]
- __init__(data)
-
data:
- class bsx_py.common.types.market.GetTradeHistoryParams(product_id, start_time=None, end_time=None, page=1, limit=100)[source]
Bases:
object-
product_id:
str
-
start_time:
Optional[datetime] = None
-
end_time:
Optional[datetime] = None
-
page:
int= 1
-
limit:
int= 100
- __init__(product_id, start_time=None, end_time=None, page=1, limit=100)
-
product_id:
- class bsx_py.common.types.market.GetTradeHistoryResponse(product_id, wallet_address, trades, page, total)[source]
Bases:
object-
product_id:
str
-
wallet_address:
str
-
page:
int
-
total:
int
- __init__(product_id, wallet_address, trades, page, total)
-
product_id:
- class bsx_py.common.types.market.PerpetualProductConfig(initial_margin, maintenance_margin, max_leverage)[source]
Bases:
object-
initial_margin:
Decimal
-
maintenance_margin:
Decimal
-
max_leverage:
Decimal
- __init__(initial_margin, maintenance_margin, max_leverage)
-
initial_margin:
- class bsx_py.common.types.market.Product(index, product_id, base_asset_symbol, quote_asset_symbol, underlying, display_name, display_base_asset_symbol, enabled, post_only, base_increment, quote_increment, quote_volume_24h, change_24h, high_24h, low_24h, last_price, mark_price, index_price, max_position_size, open_interest, funding_interval, next_funding_rate, next_funding_time, last_cumulative_funding, min_order_size, predicted_funding_rate, perpetual_product_config)[source]
Bases:
object-
index:
int
-
product_id:
str
-
base_asset_symbol:
str
-
quote_asset_symbol:
str
-
underlying:
str
-
display_name:
str
-
display_base_asset_symbol:
str
-
enabled:
bool
-
post_only:
bool
-
base_increment:
Decimal
-
quote_increment:
Decimal
-
quote_volume_24h:
Decimal
-
change_24h:
Decimal
-
high_24h:
Decimal
-
low_24h:
Decimal
-
last_price:
Decimal
-
mark_price:
Decimal
-
index_price:
Decimal
-
max_position_size:
Decimal
-
open_interest:
Decimal
-
funding_interval:
Decimal
-
next_funding_rate:
Decimal
-
next_funding_time:
Decimal
-
last_cumulative_funding:
Decimal
-
min_order_size:
Decimal
-
predicted_funding_rate:
Decimal
-
perpetual_product_config:
PerpetualProductConfig
- __init__(index, product_id, base_asset_symbol, quote_asset_symbol, underlying, display_name, display_base_asset_symbol, enabled, post_only, base_increment, quote_increment, quote_volume_24h, change_24h, high_24h, low_24h, last_price, mark_price, index_price, max_position_size, open_interest, funding_interval, next_funding_rate, next_funding_time, last_cumulative_funding, min_order_size, predicted_funding_rate, perpetual_product_config)
-
index:
- class bsx_py.common.types.market.GetProductsResponse(products)[source]
Bases:
object- __init__(products)
- class bsx_py.common.types.market.GetFundingHistoryParams(product_id, start_time, end_time, limit=20, page=1)[source]
Bases:
object-
product_id:
str
-
start_time:
Optional[datetime]
-
end_time:
Optional[datetime]
-
limit:
int= 20
-
page:
int= 1
- __init__(product_id, start_time, end_time, limit=20, page=1)
-
product_id:
- class bsx_py.common.types.market.FundingRate(time, rate)[source]
Bases:
object-
time:
datetime
-
rate:
Decimal
- __init__(time, rate)
-
time:
bsx_py.common.exception
- exception bsx_py.common.exception.BSXRequestException(code, message, detail)[source]
Bases:
ExceptionException class for BSX Request
- exception bsx_py.common.exception.UnknownException(response_body)[source]
Bases:
BSXRequestException
- exception bsx_py.common.exception.UnauthenticatedException[source]
Bases:
BSXRequestException
bsx_py.typed_message
- bsx_py.typed_message.gen_register_typed_message_for_smart_contract(env, signer, nonce)[source]
Helper function to generate the typed message that used to generate the signature for register a smart contract.
Note that this function should only be used to get the data of the typed message. The way to construct the message depends on the language that is used to generate the signature.
- Return type:
dict
- Attributes:
env (Environment|str): environment to use (Testnet or mainnet) or the domain in plain text
signer (LocalAccount): signer wallet used to sign requests
nonce (int): nonce that will be used to call the register API. We recommend using current timestamp in nanoseconds. Nonce should be unique across all requests of a user
- Return:
dict: typed message in dict format.