DESK Python SDK
Project description
DESK Python SDK
A Python client for interacting with DESK Exchange API, featuring JWT authentication and EVM wallet integration.
Features
- EVM wallet integration
- JWT-based authentication
- Subaccount management
- Type-safe API interactions
- Real-time WebSocket support
- Comprehensive error handling
Installation
pip install desk-python-sdk
or
poetry add desk-python-sdk
List of functions
Info
subscribe
disconnect_websocket
get_market_info
get_mark_price
get_collaterals_info
get_last_trades
get_subaccount_summary
get_current_funding_rate
get_historical_funding_rates
Exchange
place_order
batch_place_order
cancel_order
batch_cancel_order
cancel_all_orders
deposit_collateral
withdraw_collateral
Usage
Initialize the Client
from desk.auth import Auth
from desk.exchange import Exchange
from desk.info import Info
# Initialize authentication
auth = Auth(
network="mainnet", # mainnet, testnet
private_key="YOUR_PRIVATE_KEY",
rpc_url="https://base-rpc.publicnode.com",
account="YOUR_ACCOUNT_ADDRESS",
sub_account_id=0
)
# Initialize exchange client
exchange = Exchange(
network="mainnet", # mainnet, testnet
auth=auth
)
# Initialize info client
info = Info(
network="mainnet", # mainnet, testnet
skip_ws=False
)
Account Management
# Get account information
account_summary = info.get_subaccount_summary(account="YOUR_ACCOUNT", sub_account_id=0)
# Get funding rates info
funding_rates = info.get_current_funding_rate("BTCUSD")
Trading Operations
from desk.enum import OrderSide, OrderType, TimeInForce, MarketSymbol
# Place a limit order
limit_order = exchange.place_order(
symbol=MarketSymbol.BTCUSD,
amount="0.001",
price="99714.4",
side=OrderSide.LONG,
order_type=OrderType.LIMIT,
time_in_force=TimeInForce.GTC,
wait_for_reply=True
)
# Place a market order
market_order = exchange.place_order(
symbol=MarketSymbol.BTCUSD,
amount="0.001",
price="92123.4",
side=OrderSide.SHORT,
order_type=OrderType.MARKET,
wait_for_reply=True
)
# Cancel an order
exchange.cancel_order(
symbol=MarketSymbol.BTCUSD,
order_digest="ORDER_DIGEST",
is_conditional_order=False,
wait_for_reply=True
)
# Batch manage orders
exchange.batch_place_orders(
orders=[
{
"symbol": "BTCUSD",
"amount": "0.001",
"price": "92123.4",
"side": OrderSide.LONG,
"order_type": OrderType.LIMIT,
"time_in_force": TimeInForce.GTC
},
{
"symbol": "BTCUSD",
"amount": "0.001",
"price": "92123.4",
"side": OrderSide.SHORT,
"order_type": OrderType.LIMIT,
"time_in_force": TimeInForce.GTC
}
]
)
# Batch Cancel Specific Orders
exchange.batch_cancel_order(
orders=[
{
"symbol": "BTCUSD",
},
{
"symbol": "ETHUSD",
"order_digest": "ORDER_DIGEST"
}
]
)
# Cancel all orders
exchange.cancel_all_orders(
symbol=MarketSymbol.BTCUSD,
is_conditional_order=False,
wait_for_reply=True
)
WebSocket Streams
from datetime import datetime
# Subscribe to mark prices
info.subscribe(
{"type": "markPricesV2"},
lambda x: print("markprice: ", x['data'])
)
# Subscribe to orderbook
info.subscribe(
{"type": "l2BookV2", "symbol": "BTCUSD"},
lambda x: print("orderbook: ", x['data'])
)
Running examples
python examples/manage_order.py
python examples/get_info.py
python examples/deposit_withdraw.py
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
See the Contributor Guide for more details.
License
MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file desk_python_sdk-0.0.7.tar.gz.
File metadata
- Download URL: desk_python_sdk-0.0.7.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.13.1 Darwin/24.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05646e1b741599fc171684a481d1249538494c02bb99e4087219a9ed9d2dc890
|
|
| MD5 |
1952a27cb0c3e436a498df2fa3a2a8cc
|
|
| BLAKE2b-256 |
aebad6e967030598e332542bd75945d13bb8c5b1b1088e48d9c5c3c34a364417
|
File details
Details for the file desk_python_sdk-0.0.7-py3-none-any.whl.
File metadata
- Download URL: desk_python_sdk-0.0.7-py3-none-any.whl
- Upload date:
- Size: 18.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.13.1 Darwin/24.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ace96792476b65d75ee0a786fcdeb72c5e0a41afc594facfc3d05c588bfcea44
|
|
| MD5 |
dfe2480ae1d74ad6ab13532a4a74af6d
|
|
| BLAKE2b-256 |
d3cc16757e3eb6e88de748475a22a7e3fa2f75f6ec2771c4f13435546e72d7f2
|