Paradex Python SDK¶
Warning
Experimental SDK, library API is subject to change
paradex_py.paradex.Paradex
¶
Paradex class to interact with Paradex REST API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
env |
Environment
|
Environment |
required |
l1_address |
str
|
L1 address. Defaults to None. |
None
|
l1_private_key |
str
|
L1 private key. Defaults to None. |
None
|
l2_private_key |
str
|
L2 private key. Defaults to None. |
None
|
logger |
Logger
|
Logger. Defaults to None. |
None
|
Examples:
>>> from paradex_py import Paradex
>>> from paradex_py.environment import Environment
>>> paradex = Paradex(env=Environment.TESTNET)
init_account(l1_address, l1_private_key=None, l2_private_key=None)
¶
Initialize paradex account with l1 or l2 private keys. Cannot be called if account is already initialized.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
l1_address |
str
|
L1 address |
required |
l1_private_key |
str
|
L1 private key |
None
|
l2_private_key |
str
|
L2 private key |
None
|
API Documentation Links¶
Full details for REST API & WebSocket JSON-RPC API can be found at the following links:
paradex_py.api.api_client.ParadexApiClient
¶
Bases: HttpClient
Class to interact with Paradex REST API.
Initialized along with Paradex
class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
env |
Environment
|
Environment |
required |
logger |
Logger
|
Logger. Defaults to None. |
None
|
Examples:
>>> from paradex_py import Paradex
>>> from paradex_py.environment import Environment
>>> paradex = Paradex(env=Environment.TESTNET)
cancel_all_orders(params=None)
¶
Cancel all open orders for specific market or for all markets. Private endpoint requires authorization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params |
Optional[Dict]
|
|
None
|
cancel_order(order_id)
¶
Cancel open order previously sent to Paradex from this account. Private endpoint requires authorization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
order_id |
str
|
Order Id |
required |
cancel_order_by_client_id(client_id)
¶
Cancel open order previously sent to Paradex from this account. Private endpoint requires authorization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client_id |
str
|
Order id as assigned by a trader. |
required |
fetch_account_profile()
¶
Fetch profile for this account. Private endpoint requires authorization.
fetch_account_summary()
¶
Fetch current summary for this account. Private endpoint requires authorization.
fetch_balances()
¶
Fetch all coin balances for this account. Private endpoint requires authorization.
Returns:
Name | Type | Description |
---|---|---|
results |
list
|
List of Balances |
fetch_bbo(market)
¶
Fetch best bid/offer for specific market.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
market |
str
|
Market Name |
required |
fetch_fills(params=None)
¶
Fetch history of fills for this account. Private endpoint requires authorization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params |
Optional[Dict]
|
|
None
|
Returns:
Name | Type | Description |
---|---|---|
next |
str
|
The pointer to fetch next set of records (null if there are no records left) |
prev |
str
|
The pointer to fetch previous set of records (null if there are no records left) |
results |
list
|
List of Fills |
fetch_funding_data(params=None)
¶
List historical funding data by market
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params |
Optional[Dict]
|
|
None
|
Returns:
Name | Type | Description |
---|---|---|
next |
str
|
The pointer to fetch next set of records (null if there are no records left) |
prev |
str
|
The pointer to fetch previous set of records (null if there are no records left) |
results |
list
|
List of Funding Payments |
fetch_funding_payments(params=None)
¶
Fetch history of funding payments for this account. Private endpoint requires authorization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params |
Optional[Dict]
|
|
None
|
Returns:
Name | Type | Description |
---|---|---|
next |
str
|
The pointer to fetch next set of records (null if there are no records left) |
prev |
str
|
The pointer to fetch previous set of records (null if there are no records left) |
results |
list
|
List of Funding Payments |
fetch_insurance_fund()
¶
Fetch insurance fund information
fetch_liquidations(params=None)
¶
Fetch history of liquidations for this account. Private endpoint requires authorization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params |
Optional[Dict]
|
|
None
|
Returns:
Name | Type | Description |
---|---|---|
results |
list
|
List of Liquidations |
fetch_markets(params=None)
¶
Fetch all markets information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params |
Optional[Dict]
|
|
None
|
Returns:
Name | Type | Description |
---|---|---|
results |
list
|
List of Markets |
fetch_markets_summary(params=None)
¶
Fetch ticker information for specific market.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params |
Optional[Dict]
|
|
None
|
Returns:
Name | Type | Description |
---|---|---|
results |
list
|
List of Market Summaries |
fetch_order(order_id)
¶
Fetch a state of specific order sent from this account. Private endpoint requires authorization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
order_id |
str
|
order's id as assigned by Paradex. |
required |
fetch_order_by_client_id(client_id)
¶
Fetch a state of specific order sent from this account. Private endpoint requires authorization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client_id |
str
|
order's client_id as assigned by a trader. |
required |
fetch_orderbook(market, params=None)
¶
Fetch order-book for specific market.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
market |
str
|
Market Name |
required |
params |
Optional[Dict]
|
|
None
|
fetch_orders(params=None)
¶
Fetch open orders for the account. Private endpoint requires authorization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params |
Optional[Dict]
|
|
None
|
Returns:
Name | Type | Description |
---|---|---|
results |
list
|
Orders list |
fetch_orders_history(params=None)
¶
Fetch history of orders for the account. Private endpoint requires authorization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params |
Optional[Dict]
|
|
None
|
Returns:
Name | Type | Description |
---|---|---|
next |
str
|
The pointer to fetch next set of records (null if there are no records left) |
prev |
str
|
The pointer to fetch previous set of records (null if there are no records left) |
results |
list
|
List of Orders |
fetch_points_data(market, program)
¶
Fetch points program data for specific market. Private endpoint requires authorization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
market |
str
|
Market Name |
required |
program |
str
|
Program Name - example: Maker, Fee |
required |
Returns:
Name | Type | Description |
---|---|---|
results |
list
|
List of points data |
fetch_positions()
¶
Fetch all derivatives positions for this account. Private endpoint requires authorization.
Returns:
Name | Type | Description |
---|---|---|
next |
str
|
The pointer to fetch next set of records (null if there are no records left) |
prev |
str
|
The pointer to fetch previous set of records (null if there are no records left) |
results |
list
|
List of Positions |
fetch_system_config()
¶
Fetch Paradex system config.
Examples:
>>> paradex.api_client.fetch_system_config()
>>> { ..., "paraclear_decimals": 8, ... }
fetch_system_state()
¶
Fetch Paradex system status.
Examples:
>>> paradex.api_client.fetch_system_state()
>>> { "status": "ok" }
fetch_system_time()
¶
Fetch Paradex system time.
Examples:
>>> paradex.api_client.fetch_system_time()
>>> { "server_time": "1710956478221" }
Returns:
Name | Type | Description |
---|---|---|
server_time |
Dict
|
Paradex Server time |
fetch_tradebusts(params=None)
¶
Fetch history of tradebusts for this account.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params |
Optional[Dict]
|
|
None
|
Returns:
Name | Type | Description |
---|---|---|
next |
str
|
The pointer to fetch next set of records (null if there are no records left) |
prev |
str
|
The pointer to fetch previous set of records (null if there are no records left) |
results |
list
|
List of Tradebusts |
fetch_trades(params)
¶
Fetch Paradex exchange trades for specific market.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params |
Dict
|
|
required |
Returns:
Name | Type | Description |
---|---|---|
next |
str
|
The pointer to fetch next set of records (null if there are no records left) |
prev |
str
|
The pointer to fetch previous set of records (null if there are no records left) |
results |
list
|
List of Trades |
fetch_transactions(params=None)
¶
Fetch history of transactions initiated by this account. Private endpoint requires authorization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params |
Optional[Dict]
|
|
None
|
Returns:
Name | Type | Description |
---|---|---|
next |
str
|
The pointer to fetch next set of records (null if there are no records left) |
prev |
str
|
The pointer to fetch previous set of records (null if there are no records left) |
results |
list
|
List of Transactions |
fetch_transfers(params=None)
¶
Fetch history of transfers initiated by this account. Private endpoint requires authorization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params |
Optional[Dict]
|
|
None
|
Returns:
Name | Type | Description |
---|---|---|
next |
str
|
The pointer to fetch next set of records (null if there are no records left) |
prev |
str
|
The pointer to fetch previous set of records (null if there are no records left) |
results |
list
|
List of Transfers |
submit_order(order)
¶
Send order to Paradex. Private endpoint requires authorization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
order |
Order
|
Order containing all required fields. |
required |
paradex_py.api.ws_client.ParadexWebsocketChannel
¶
Bases: Enum
Enum class to define the channels for Paradex Websocket API.
Attributes:
Name | Type | Description |
---|---|---|
ACCOUNT |
str
|
Account channel |
BALANCE_EVENTS |
str
|
Balance events channel |
BBO |
str
|
Best Bid Offer channel |
FILLS |
str
|
Fills channel |
FUNDING_DATA |
str
|
Funding data channel |
FUNDING_PAYMENTS |
str
|
Funding payments channel |
MARKETS_SUMMARY |
str
|
Markets summary channel |
ORDERS |
str
|
Orders channel |
ORDER_BOOK |
str
|
Order book snapshots channel |
ORDER_BOOK_DELTAS |
str
|
Order book deltas channel |
POINTS_DATA |
str
|
Points data channel |
POSITIONS |
str
|
Positions channel |
TRADES |
str
|
Trades channel |
TRADEBUSTS |
str
|
Tradebusts channel |
TRANSACTIONS |
str
|
Transactions channel |
TRANSFERS |
str
|
Transfers channel |
paradex_py.api.ws_client.ParadexWebsocketClient
¶
Class to interact with Paradex WebSocket JSON-RPC API.
Initialized along with Paradex
class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
env |
Environment
|
Environment |
required |
logger |
Optional[Logger]
|
Logger. Defaults to None. |
None
|
Examples:
>>> from paradex_py import Paradex
>>> from paradex_py.environment import Environment
>>> paradex = Paradex(env=Environment.TESTNET)
>>> paradex.ws_client.connect()
connect()
async
¶
Connect to Paradex WebSocket API.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if connection is successful. |
Examples:
>>> from paradex_py import Paradex
>>> from paradex_py.environment import Environment
>>> paradex = Paradex(env=Environment.TESTNET)
>>> await paradex.ws_client.connect()
subscribe(channel, callback, params=None)
async
¶
Subscribe to a websocket channel with optional parameters. Callback function is invoked when a message is received.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
channel |
ParadexWebsocketChannel
|
Channel to subscribe |
required |
callback |
Callable
|
Callback function |
required |
params |
Optional[dict]
|
Parameters for the channel. Defaults to None. |
None
|
Examples:
>>> from paradex_py import Paradex
>>> from paradex_py.environment import Environment
>>> from paradex_py.api.ws_client import ParadexWebsocketChannel, ParadexWebsocketClient
>>> async def on_message(ws_channel, message):
>>> print(ws_channel, message)
>>> paradex = Paradex(env=Environment.TESTNET)
>>> await paradex.ws_client.connect()
>>> await paradex.ws_client.subscribe(ParadexWebsocketChannel.MARKETS_SUMMARY, callback=on_message)
paradex_py.account.account.ParadexAccount
¶
Class to generate and manage Paradex account.
Initialized along with Paradex
class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
SystemConfig
|
SystemConfig |
required |
l1_address |
str
|
Ethereum address |
required |
l1_private_key |
Optional[str]
|
Ethereum private key. Defaults to None. |
None
|
l2_private_key |
Optional[str]
|
Paradex private key. Defaults to None. |
None
|
Examples:
>>> from paradex_py import Paradex
>>> from paradex_py.environment import Environment
>>> paradex = Paradex(env=Environment.TESTNET, l1_address="0x...", l1_private_key="0x...")
>>> paradex.account.l2_address # 0x...
>>> paradex.account.l2_public_key # 0x...
>>> paradex.account.l2_private_key # 0x...