Skip to content

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

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]

market: Market Name

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_info()

Fetch profile for this account. Private endpoint requires authorization.

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]

cursor: Returns the next paginated page

end_at: End Time (unix time millisecond)

market: Market for the fills

page_size: Limit the number of responses in the page

start_at: Start Time (unix time millisecond)

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]

cursor: Returns the next paginated page

end_at: End Time (unix time millisecond)

market: Market for which funding payments are queried

page_size: Limit the number of responses in the page

start_at: Start Time (unix time millisecond)

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]

cursor: Returns the next paginated page

end_at: End Time (unix time millisecond)

market: Market for which funding payments are queried

page_size: Limit the number of responses in the page

start_at: Start Time (unix time millisecond)

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]

start (int): start time in milliseconds since epoch. end (int): end time in milliseconds since epoch.

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]

market: Market Name

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]

end: End Time (unix time millisecond)

market: Name of the market for which summary is requested (for all available markets use ALL)

start: Start Time (unix time millisecond)

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]

depth: Depth

None

fetch_orders(params=None)

Fetch open orders for the account. Private endpoint requires authorization.

Parameters:

Name Type Description Default
params Optional[Dict]

market: Market for the order

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]

client_id: Unique ID of client generating the order

cursor: Returns the next paginated page

end_at: End Time (unix time millisecond)

market: Market for the order

page_size: Limit the number of responses in the page

side: Order side

start_at: Start Time (unix time millisecond)

status: Order status

type: Order type

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_subaccounts()

Fetch list of sub-accounts for this account. Private endpoint requires authorization.

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]

cursor: Returns the next paginated page

end_at: End Time (unix time millisecond)

page_size: Limit the number of responses in the page

start_at: Start Time (unix time millisecond)

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

market: Market Name

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]

cursor: Returns the next paginated page

end_at: End Time (unix time millisecond)

page_size: Limit the number of responses in the page

start_at: Start Time (unix time millisecond)

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]

cursor: Returns the next paginated page

end_at: End Time (unix time millisecond)

page_size: Limit the number of responses in the page

start_at: Start Time (unix time millisecond)

status: none

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

modify_order(order_id, order)

Modify an open order previously sent to Paradex from this account. Private endpoint requires authorization.

Parameters:

Name Type Description Default
order_id str

Order Id

required
order Order

Order update

required

submit_order(order)

Send order to Paradex. Private endpoint requires authorization.

Parameters:

Name Type Description Default
order Order

Order containing all required fields.

required

submit_orders_batch(orders)

Send batch of orders to Paradex. Private endpoint requires authorization.

Parameters:

Name Type Description Default
orders list[Order]

List of orders containing all required fields.

required

Returns:

Name Type Description
orders list

List of Orders

errors list

List of Errors

paradex_py.api.ws_client.ParadexWebsocketChannel

Bases: Enum

Enum class to define the channels for Paradex Websocket API.

Attributes:

Name Type Description
ACCOUNT str

Private websocket channel for receiving updates of account status

BALANCE_EVENTS str

Private websocket channel to receive PnL calculation data

BBO str

Public websocket channel for tick updates of orderbook best bid/ask prices and amounts

FILLS str

Private websocket channel to receive details of fills for specific account

FUNDING_DATA str

Public websocket channel to receive funding data updates

FUNDING_PAYMENTS str

Private websocket channel to receive funding payments of an account

FUNDING_RATE_COMPARISON str

Public websocket channel for funding rate comparisons across exchanges

MARKETS_SUMMARY str

Public websocket channel for updates of available markets

ORDERS str

Private websocket channel to receive order updates

ORDER_BOOK str

Public websocket channel for orderbook snapshot updates of depth 15 at most every 50ms or 100ms, optionally grouped by price tick

POSITIONS str

Private websocket channel to receive updates when position is changed

TRADES str

Public websocket channel to receive updates on trades in particular market

TRADEBUSTS str

Private websocket channel to receive fills that are busted by a blockchain

TRANSACTIONS str

Private websocket channel for receiving transaction details of fills

TRANSFERS str

Websocket channel for receiving transfer updates

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 TESTNET
>>> async def main():
...     paradex = Paradex(env=TESTNET)
...     await paradex.ws_client.connect()
>>> import asyncio
>>> asyncio.run(main())

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 TESTNET from paradex_py.api.ws_client import ParadexWebsocketChannel, ParadexWebsocketClient async def main(): ... async def on_message(ws_channel, message): ... print(ws_channel, message) ... paradex = Paradex(env=TESTNET) ... await paradex.ws_client.connect() ... await paradex.ws_client.subscribe(ParadexWebsocketChannel.MARKETS_SUMMARY, callback=on_message) import asyncio asyncio.run(main())

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
>>> paradex.account.l2_public_key
>>> paradex.account.l2_private_key