Backpack private package
bpx.bpx module
- class bpx.BpxClient(api_key: str, api_secret: str, window: int = 5000, proxies: dict = None)[source]
Bases:
object
- Parameters:
api_key (
str
) – Base64 encoded verifying key of the ED25519 keypair.api_secret (
str
) – private key of the ED25519 keypair that corresponds to the public keywindow (
int64
, optional) – Time window in milliseconds that the request is valid for, default is5000
and maximum is60000
proxies (
dict
, optional) – Proxy that will be used for requests. More details about format on requests documentation.
- ExeOrder(symbol: str, side: str, orderType: str, timeInForce: str, quantity: float, price: float = 0, triggerPrice: float = 0, selfTradePrevention: str = 'RejectBoth', quoteQuantity: float = None)[source]
- Parameters:
symbol (
str
) – The market for the order.side (
str
) – Which side of the order book the order is on.orderType (
str
) – The type of an order.timeInForce (
str
) –quantity (
float
) – The order quantity. Market orders must specify either aquantity
orquoteQuantity
. All other order types must specify aquantity
.price (
float
) – The order price if this is a limit order.triggerPrice (
float
) – Trigger price if this is a conditional order.selfTradePrevention (
str
) – Self trade prevention describes what should happen if the order attempts to fill against another order from the same account or trade group.quoteQuantity (
float
) – The maximum amount of the quote asset to spend (Ask) or receive (Bid) for market orders. This is used for reverse market orders. The order book will execute aquantity
as close as possible to the notional value ofquote_quantity
.
- Returns:
Status of executed order.
- Return type:
dict
Warning
Order book is in limit-only mode. That means you cannot use Market Bid or Ask orders.
- balances()[source]
- Returns:
Account balances and the state of the balances (locked or available).
- Return type:
dict
- debug = False
- debugTs = 0
- depositAddress(chain: str)[source]
- Parameters:
chain (
str
) – Blockchain symbol to get a deposit address for.- Returns:
User specific deposit address if the user were to deposit on the specified blockchain.
- Return type:
dict
- deposits(limit: int = 100, offset: int = 0)[source]
- Parameters:
limit (
int64
) – Maximum number to return. Default100
, maximum1000
.offset (
int64
) – The offset of retrieving data. Default0
.
- Returns:
Deposit history.
- Return type:
dict
- fillHistoryQuery(symbol: str, limit: int = 100, offset: int = 0, _BpxClient__from: int = None, to: int = None)[source]
- Parameters:
symbol (
str
) – Filter to the given symbol.limit (
int64
) – Offset. Default0
.offset (
int64
) – Maximum number to return. Default100
, maximum1000
.__from (
int64
, optional) – Filter to minimum time (milliseconds).to (
int64
, optional) – Filter to maximum time (milliseconds).
- Returns:
Historical fills, with optional filtering for a specific order or symbol.
- get_withdrawals(limit: int = 100, offset: int = 0)[source]
- Parameters:
limit (
int64
) – Maximum number to return. Default100
, maximum1000
.offset (
int64
) – Offset. Default0
.
- Returns:
Withdrawal history.
- Return type:
dict
- orderCancel(symbol: str, orderId: str = None, clientId: int = None)[source]
- Parameters:
symbol (
str
) – Market the order exists on.orderId (
int64
) – ID of the order.clientId (
int64
) – Market the order exists on.
- Returns:
Status of canceling the order.
- Return type:
dict
Note
One of
orderId
orclientId
must be specified. If both are specified, thenorderId
takes precedence.
- orderCancelAll(symbol: str)[source]
- Parameters:
symbol (
str
) – Market to cancel orders for.- Returns:
Cancels all open orders on the specified market.
- Return type:
dict
- orderHistoryQuery(symbol: str, limit: int = 100, offset: int = 0)[source]
- Parameters:
symbol (
str
) – Filter to the given symbol.limit (
int64
) – Maximum number to return. Default100
, maximum1000
.offset (
int64
) – Offset. Default0
.
- Returns:
Order history for the user. This includes orders that have been filled and are no longer on the book. It may include orders that are on the book, but the
/orders
endpoint contains more up to date data.- Return type:
dict
- orderQuery(symbol: str, orderId: str = None, clientId: int = None)[source]
- Parameters:
symbol (
str
) – Market symbol for the order.orderId (
int64
) – ID of the order.clientId (
int64
) – Client ID of the order.
- Returns:
open order from the order book. This only returns the order if it is resting on the order book (i.e. has not been completely filled, expired, or cancelled).
- Return type:
dict
Note
One of
orderId
orclientId
must be specified. If both are specified, thenorderId
takes precedence.
- ordersQuery(symbol: str = None)[source]
- Parameters:
symbol (
str
, optional) – The symbol of the market for the orders.- Returns:
Retrieves all open orders. If a symbol is provided, only open orders for that market will be returned, otherwise all open orders are returned.
- Return type:
dict
- withdrawal(address: str, symbol: str, blockchain: str, quantity: str, twoFactorToken: str = None)[source]
- Parameters:
address (
str
) – Address to withdraw to.symbol (
str
) – Blockchain to withdraw on.blockchain (
str
) – Quantity to withdraw.quantity (
float
) – Symbol of the asset to withdraw.twoFactorToken (
str
) – Issued two factor token.
- Returns:
Requests a withdrawal from the exchange.
- Return type:
dict
Note
The twoFactorToken field is required if the withdrawal address is not an address that is configured in the address book to not require 2FA. These addresses can be configured here.