### Install bpx-py Source: https://github.com/sndmndss/bpx-py/blob/main/README.md Installs the Backpack SDK for Python. Requires Python version 3.8 or higher. ```bash pip install bpx-py ``` -------------------------------- ### Account Management (Sync) Source: https://github.com/sndmndss/bpx-py/blob/main/README.md Demonstrates synchronous usage of the Account class to get deposit addresses and fill history. Requires API keys and allows configuration of request windows and proxies. ```python from bpx.account import Account public_key = "" secret_key = "" account = Account(public_key, secret_key, window=6000, # default value is 5000 proxy={"http":"132.142.132.12:3128"}) # you can use any requests proxy supported by requests deposit_address_sol = account.get_deposit_address("Solana") account_fills = account.get_fill_history("SOL_USDC", limit=10, window=10000) # window only for this order print(deposit_address_sol) print(account_fills) ``` -------------------------------- ### Account Management (Async) Source: https://github.com/sndmndss/bpx-py/blob/main/README.md Demonstrates asynchronous usage of the Account class for account operations. Supports async/await syntax and allows specifying market types. ```python from bpx.async_.account import Account from bpx.constants.enums import MarketTypeEnum import asyncio async def main(): public_key = "" secret_key = "" account = Account(public_key, secret_key, proxy="http://your_proxy-address:1234") deposit_address_sol = await account.get_deposit_address("Solana") await asyncio.sleep(1) account_fills = await account.get_fill_history("SOL_USDC", limit=10, window=10000, market_type=MarketTypeEnum.SPOT) print(deposit_address_sol) print(account_fills) asyncio.run(main()) ``` -------------------------------- ### Public Data Access (Async) Source: https://github.com/sndmndss/bpx-py/blob/main/README.md Demonstrates asynchronous retrieval of public data, including assets and borrow/lend market history, using async/await. ```python from bpx.async_.public import Public from bpx.constants.enums import BorrowLendMarketHistoryIntervalEnum import asyncio async def main(): public = Public() assets = await public.get_assets() await asyncio.sleep(1) klines = await public.get_borrow_lend_market_history(BorrowLendMarketHistoryIntervalEnum.ONE_DAY) print(assets) print(klines) asyncio.run(main()) ``` -------------------------------- ### Request Configuration Source: https://github.com/sndmndss/bpx-py/blob/main/README.md Illustrates how to obtain request configuration details (URL, headers) without making an actual API call, using base classes for account and public endpoints. ```python from bpx.base.base_account import BaseAccount from bpx.base.base_public import BasePublic from bpx.models.objects import RequestConfiguration # unnecessary base_public = BasePublic() base_account = BaseAccount("", "", window=5000, debug=True) # let's get url and headers for this account request request_config: RequestConfiguration = base_account.get_balances() url = request_config.url headers = request_config.headers # let's get url for this public request request_url: str = base_public.get_ticker_url(symbol="SOL_USDC") ``` -------------------------------- ### Public Data Access (Sync) Source: https://github.com/sndmndss/bpx-py/blob/main/README.md Shows how to access public Backpack API endpoints without authentication, such as retrieving server time and market data. ```python from bpx.public import Public public = Public() server_time = public.get_time() markets = public.get_markets() print(server_time) print(markets) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.