Skip to content

quantpylib.wrappers.paradex

Paradex

__init__(key=None, secret=None, l2_secret=None)

Instantiates the Paradex wrapper class.

Parameters:

Name Type Description Default
key str

Ethereum L1 public address.

None
secret str

Ethereum L1 private key.

None
l2_secret str

Starknet L2 private key.

None

account_balance(**kwargs) async

Retrieve balance details of the user, such as equity, margin (total, maintenance) and pnl.

Returns:

Type Description
dict

Balance details.

account_fill_subscribe(handler, **kwargs) async

Subscribe to account fill updates.

Parameters:

Name Type Description Default
handler coroutine

Coroutine handler receiving the account fill messages.

required

account_fill_unsubscribe(**kwargs) async

Unsubscribe to account fill updates.

all_mids_subscribe(handler, **kwargs) async

Subscribe to mid-price updates for all tickers.

Parameters:

Name Type Description Default
handler coroutine

A coroutine handler for the message received.

required
**kwargs

Exchange wrapper specific keyword arguments.

{}

all_mids_unsubscribe(**kwargs) async

Unsubscribe from mid-price updates for all tickers.

cancel_all_orders(market=None) async

Cancel all orders.

Parameters:

Name Type Description Default
market str

The market symbol. Defaults to None (cancel all open orders).

None

cancel_open_orders(ticker=None, **kwargs) async

Cancel open orders on the exchange.

Parameters:

Name Type Description Default
ticker str

The coin symbol. Defaults to None, which means cancel all open orders.

None
**kwargs

Additional keyword arguments for further customization.

{}

Returns:

Name Type Description
Any

The result of the cancellation request. Returns None if no open orders are found or no orders are canceled.

cancel_order(oid=None, cloid=None, **kwargs) async

Cancel an order.

Parameters:

Name Type Description Default
ticker str

Ticker symbol.

required
oid int

Order ID to cancel.

None
cloid str

Client Order ID to cancel.

None
**kwargs

Exchange wrapper specific keyword arguments.

{}

cancel_order_by_cloid(client_id) async

Cancel order by client ID.

Parameters:

Name Type Description Default
client_id str

The client ID for the order.

required

cancel_order_by_oid(order_id) async

Cancel order by order ID.

Parameters:

Name Type Description Default
order_id str

The order ID.

required

contract_specifications(**kwargs) async

Retrieve the contract's trading rules from the exchange.

Parameters:

Name Type Description Default
**kwargs

Additional keyword arguments.

{}

Returns:

Name Type Description
dict

A dictionary containing contract specifications for each asset with key-values: - SYMBOL_PRICE_PRECISION. - SYMBOL_QUANTITY_PRECISION. - SYMBOL_MIN_NOTIONAL - SYMBOL_BASE_ASSET - SYMBOL_QUOTE_ASSET

get_account() async

Get account details.

get_all_marks(**kwargs) async

Retrieve the mark-price for all available tickers.

Parameters:

Name Type Description Default
**kwargs

Additional keyword arguments.

{}

Returns:

Name Type Description
dict

A dictionary with contract symbols as keys and their corresponding mark-prices (Decimal) as values.

get_all_mids(**kwargs) async

Retrieve the mid-price for all available tickers.

Parameters:

Name Type Description Default
**kwargs

Additional keyword arguments.

{}

Returns:

Name Type Description
dict

A dictionary with contract symbols as keys and their corresponding mid-prices (Decimal) as values if ticker is not provided.

get_balances() async

Get account balances.

get_bbo(market) async

Get the best bid and offer for a specific market.

Parameters:

Name Type Description Default
market str

The market symbol.

required

get_fills(**kwargs) async

Get account fills.

Parameters:

Name Type Description Default
**kwargs

Additional params.

{}

get_funding_data(market, **kwargs) async

Get funding data for a specific market.

Parameters:

Name Type Description Default
market str

The market symbol.

required

get_funding_info(**kwargs) async

Retrieve funding information from the exchange.

Returns:

Name Type Description
dict

A dictionary containing information for each asset with key-values: - FUNDING_RATE. - NEXT_FUNDING. - MARK_PRICE. - FUNDING_INTERVAL.

get_funding_payments(**kwargs) async

Get account funding payments.

Parameters:

Name Type Description Default
**kwargs

Additional params.

{}

get_insurance() async

Get insurance details.

get_jwt_token()

Get the current JWT token for the exchange private methods.

get_liquidations(**kwargs) async

Get liquidations.

Parameters:

Name Type Description Default
**kwargs

Additional keyword arguments.

{}

get_markets() async

Get all available markets.

get_markets_summary(market='ALL', **kwargs) async

Get the summary of all markets.

Parameters:

Name Type Description Default
market str

The market symbol. Defaults to 'ALL'.

'ALL'
**kwargs

Additional keyword arguments.

{}

get_ohlcv(end_at, resolution, start_at, symbol) async

Get OHLCV data for a specific market.

Parameters:

Name Type Description Default
end_at str

The end time.

required
resolution str

The resolution of the candle.

required
start_at str

The start time.

required
symbol str

The market symbol.

required

get_open_orders(**kwargs) async

Get open orders.

Parameters:

Name Type Description Default
**kwargs

Additional keyword arguments.

{}

get_open_positions() async

Get open positions.

get_order_by_cloid(client_id) async

Get order by client ID.

Parameters:

Name Type Description Default
client_id str

The client ID for the order.

required

get_order_by_oid(order_id) async

Get order by order ID.

Parameters:

Name Type Description Default
order_id str

The order ID.

required

get_orderbook(market, **kwargs) async

Get the orderbook for a specific market.

Parameters:

Name Type Description Default
market str

The market symbol.

required

get_orders_history(**kwargs) async

Get list of orders history.

Parameters:

Name Type Description Default
**kwargs

Additional keyword

{}

get_points(market, program) async

Get points data for a specific market and program.

Parameters:

Name Type Description Default
market str

The market symbol.

required
program str

The program.

required

get_profile() async

Get profile details.

get_referral_config() async

Get referral config.

get_referral_summary() async

Get user referral summary.

get_system_config() async

Get exchange system config.

get_system_state() async

Get exchange system state.

get_system_time() async

Get exchange system time.

get_tradebusts() async

Get tradebusts.

get_trades(market, **kwargs) async

Get trades for a specific market.

Parameters:

Name Type Description Default
market str

The market symbol.

required
**kwargs

Additional keyword arguments.

{}

get_transactions(**kwargs) async

Get transactions.

Parameters:

Name Type Description Default
**kwargs

Additional params.

{}

get_transfers(**kwargs) async

Get transfers.

Parameters:

Name Type Description Default
**kwargs

Additional keyword arguments.

{}

get_vault_account_summary(**kwargs) async

Get user's vault account summary.

Parameters:

Name Type Description Default
**kwargs

Additional keyword arguments.

{}

get_vault_config() async

Get vault config.

get_vault_history(address, type, resolution) async

Get vault history.

Parameters:

Name Type Description Default
address str

The address of the vault.

required
type str

The type.

required
resolution str

The resolution of history.

required

get_vault_positions(address) async

Get vault positions.

Parameters:

Name Type Description Default
address str

The address of the vault.

required

get_vault_summary(**kwargs) async

Get exchange vault summary.

Parameters:

Name Type Description Default
**kwargs

Additional keyword arguments.

{}

get_vaults(**kwargs) async

Get vault details.

Parameters:

Name Type Description Default
**kwargs

Additional keyword arguments.

{}

init_client() async

Initializes the exchange client.

l2_book_get(ticker, depth=100, standardize_schema=True, **kwargs) async

Retrieve the L2 Order Book for a specific ticker.

Parameters:

Name Type Description Default
ticker str

Ticker symbol.

required
depth int

Depth of the order book. Defaults to 100.

100
standardize_schema bool

If True, returns the order book in a standardized schema. Defaults to True.

True
**kwargs

Additional keyword arguments specific to the exchange wrapper.

{}

l2_book_mirror(ticker, depth=15, buffer_size=100, as_dict=True, on_update=None, speed_ms=100, **kwargs) async

Keep a live, internal L2 Order Book representation using a l2-book subscription.

Parameters:

Name Type Description Default
ticker str

Ticker symbol.

required
depth int

Depth of the order-book representation, if as_dict is False

15
buffer_size int

Size of the order-book buffer, if as_dict is False

100
as_dict (bool, True)

If True, pass state as dictionary, otherwise as a quantpylib.hft.lob.LOB object into handlers.

True
on_update coroutine

A coroutine handler when order book state is updated.

None
speed_ms (int, 100)

Speed of the order book updates in milliseconds.

100
**kwargs

Exchange wrapper specific keyword arguments.

{}

l2_book_peek(ticker, as_dict=True, **kwargs)

Retrieve the mirrored, local internal L2 Order Book representation.

Parameters:

Name Type Description Default
ticker str

Ticker symbol.

required
as_dict (bool, True)

If True, return state as dictionary, otherwise as a quantpylib.hft.lob.LOB object.

True
**kwargs

Exchange wrapper specific keyword arguments.

{}

l2_book_subscribe(ticker, handler, depth=15, speed_ms=100, standardize_schema=True, **kwargs) async

Subscribe to L2 Order Book stream.

Parameters:

Name Type Description Default
ticker str

Ticker symbol.

required
handler coroutine

A coroutine handler for the message received.

required
depth int

Depth of the l2 stream updates. Defaults to 15 (snapshot). Other depths are delta updates.

15
speed_ms int

Speed of the order book updates in milliseconds. Defaults to 100.

100
standardize_schema (bool, True)

Processes the incoming message to {ts,b,a}

True
**kwargs

Exchange wrapper specific keyword arguments.

{}

l2_book_subscriptions(**kwargs)

Retrieve the list of open l2 book subscriptions.

l2_book_unsubscribe(ticker, depth=15, speed_ms=100, **kwargs) async

Unsubscribe from L2 Order Book.

Parameters:

Name Type Description Default
ticker str

Ticker symbol.

required
depth int

Depth of the l2 stream update subscribed. Defaults to 15.

15
speed_ms int

Speed of the order book updates in milliseconds. Defaults to 100.

100
**kwargs

Exchange wrapper specific keyword arguments.

{}

limit_order(ticker, amount, price, tif='GTC', reduce_only=False, cloid=None, round_price=False, round_size=False, **kwargs) async

Submit a limit order.

Parameters:

Name Type Description Default
ticker str

The coin symbol.

required
amount float or Decimal

The signed quantity of contracts to long or short.

required
price float

The price at which to execute the order.

required
tif str

The time in force for the order. Defaults to "Gtc". Allowed values are: - "GTC" (Good 'til canceled) - "POST_ONLY" (Add liquidity only) - "IOC" (Immediate or cancel)

'GTC'
reduce_only bool

Whether the order should only reduce an existing position. Defaults to False.

False
cloid str

Client order ID for order tracking. Defaults to None.

None
round_price bool

Whether to round the price to a valid order specification. Defaults to False.

False
round_size bool

Whether to round the price to a valid order specification. Defaults to False.

False
**kwargs

Additional keyword arguments for order customization.

{}

Returns:

Name Type Description
Any

The result of the order placement.

market_order(ticker, amount, tif='GTC', reduce_only=False, cloid=None, round_size=False, **kwargs) async

Submit a market order.

Parameters:

Name Type Description Default
ticker str

The ticker symbol for the asset.

required
amount float or Decimal

The signed quantity of contracts to long or short.

required
tif str

Time in force. Defaults to GTC. Valid values are GTC, IOC.

'GTC'
reduce_only bool

Whether the order should only reduce an existing position. Defaults to False.

False
cloid str

Client order ID for custom tracking. Defaults to None.

None
round_size bool

Whether to round the price to a valid order specification. Defaults to False.

False
**kwargs

Additional keyword arguments specific to the exchange wrapper.

{}

Returns:

Name Type Description
Any

The result of the order placement. This typically includes a confirmation of the placed order, or an error message if the order could not be placed.

oracle_subscribe(handler, ticker='USDC', **kwargs) async

Subscribe to the USD/USDC price updates.

order_query(ticker, oid=None, cloid=None, as_dict=True, **kwargs) async

Get order details using client order ID.

Parameters:

Name Type Description Default
oid str

Order ID in exchange (not used for actual query, echoed back as result).

None
cloid str

Client Order ID (used for actual query).

None
as_dict bool

If True, return the order details as a dictionary. Defaults to True.

True
**kwargs

Exchange wrapper specific keyword arguments.

{}

order_updates_subscribe(handler, **kwargs) async

Subscribe to creation, updation and deletion of account's orders.

Parameters:

Name Type Description Default
handler coroutine

A coroutine handler for the message received.

required
**kwargs

Exchange wrapper specific keyword arguments.

{}

order_updates_unsubscribe(**kwargs) async

Unsubscribe from order events.

orders_get(**kwargs) async

Get all open orders.

Returns:

Name Type Description
dict

A dictionary containing order details.

orders_mirror(on_update=None, as_list=True, **kwargs) async

Keeps a local mirror copy of the account open orders.

Parameters:

Name Type Description Default
on_update coroutine

A coroutine handler for orders dictionary on order event.

None
as_list bool

If True, pass state as list, otherwise as quantpylib.standards.Orders object into handlers.

True
**kwargs

Exchange wrapper specific keyword arguments.

{}

orders_peek(as_dict=True, **kwargs)

Retrieves the local mirror copy of the account open orders.

Parameters:

Name Type Description Default
as_dict bool

If True, pass state as dictionary, otherwise as quantpylib.standards.Orders object.

True
**kwargs

Exchange wrapper specific keyword arguments.

{}

positions_get() async

Get all open position details.

Parameters:

Name Type Description Default
**kwargs

Exchange wrapper specific keyword arguments.

required

positions_mirror(on_update=None, as_dict=True, **kwargs) async

Keeps a local mirror copy of the account open orders.

Parameters:

Name Type Description Default
on_update coroutine

A coroutine handler for positions dictionary on fill.

None
as_dict bool

If True, the method returns positions as a dictionary, otherwise as a quantpylib.standards.Positions object. Defaults to True.

True
**kwargs

Exchange wrapper specific keyword arguments.

{}

positions_peek(as_dict=True, **kwargs)

Retrieves the local mirror copy of the account open positions.

Parameters:

Name Type Description Default
as_dict bool

If True, the method returns positions as a dictionary, otherwise as a quantpylib.standards.Positions object. Defaults to True.

True
**kwargs

Exchange wrapper specific keyword arguments.

{}

post_auth() async

Post on auth request for a valid JWT token.

post_onboarding() async

Post on onboarding request.

post_order(market, instruction, side, size, type, price=Decimal('0'), client_id=None, reduce_only=False, recv_window=None, stp=None, trigger_price=None, **kwargs) async

Submit an order to the exchange.

Parameters:

Name Type Description Default
market str

The market symbol.

required
instruction str

The instruction for the order.

required
side str

The side of the order.

required
size float or Decimal

The size of the order.

required
type str

The type of the order.

required
price float or Decimal

The price of the order. Defaults to Decimal('0') for market order.

Decimal('0')
client_id str

The client ID for the order. Defaults to None.

None
reduce_only bool

Whether the order is reduce only. Defaults to False.

False
recv_window int

The receive window for the order. Defaults to None.

None
stp str

The stop price for the order. Defaults to None.

None
trigger_price float or Decimal

The trigger price for the order. Defaults to None.

None
**kwargs

Additional keyword arguments.

{}

rand_cloid(start='', end='', **kwargs)

Generate a random string (cloid) consisting of hexadecimal characters.

Parameters:

Name Type Description Default
start str

A string to prepend to the generated random string. Defaults to ''.

''
end str

A string to append to the generated random string. Defaults to ''.

''
**kwargs

Additional keyword arguments.

{}

Returns:

Name Type Description
str

A random hexadecimal string with a total length of 36 characters, including the optional 'start' and 'end' strings.

trades_subscribe(ticker, handler, standardize_schema=True, **kwargs) async

Subscribe to trade updates.

Parameters:

Name Type Description Default
ticker str

Ticker symbol.

required
handler coroutine

A coroutine handler for the message received.

required
standardize_schema (bool, True)

Processes the incoming message to (ts,price,sz,dir)

True
**kwargs

Exchange wrapper specific keyword arguments.

{}

trades_unsubscribe(ticker, **kwargs) async

Unsubscribe from trade updates.

Parameters:

Name Type Description Default
ticker str

Ticker symbol.

required
**kwargs

Exchange wrapper specific keyword arguments.

{}

message_signature(msg_hash, priv_key, seed=32)

Signs the message with private key.

verify_message_signature(msg_hash, signature, public_key)

Verifies ECDSA signature of a given message hash with a given public key. Returns true if public_key signs the message.