### Get Orders with Filters - Python Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt This snippet demonstrates how to query orders using various filters such as symbol, status, time range, and pagination. It includes examples for fetching open orders, filtered orders by symbol and time, and algorithmic orders. The client must be initialized with authentication details. ```python from orderly_evm_connector.rest import Rest as Client import time client = Client( orderly_key="ed25519:your_key", orderly_secret="ed25519:your_secret", orderly_account_id="0xYourAccountId", orderly_testnet=True ) # Get all open orders (INCOMPLETE = NEW + PARTIAL_FILLED) open_orders = client.get_orders( status="INCOMPLETE", page=1, size=50 ) print(f"Open orders: {open_orders}") # Get orders for specific symbol with time range end_time = int(time.time() * 1000) start_time = end_time - (24 * 60 * 60 * 1000) # Last 24 hours filtered_orders = client.get_orders( symbol="PERP_ETH_USDC", side="BUY", order_type="LIMIT", status="COMPLETED", # COMPLETED = CANCELLED + FILLED start_t=start_time, end_t=end_time, page=1, size=100 ) print(f"Filtered orders: {filtered_orders}") # Get algo orders algo_orders = client.get_algo_orders( algo_type="STOP", symbol="PERP_ETH_USDC", status="NEW" ) print(f"Algo orders: {algo_orders}") ``` -------------------------------- ### Account Registration (Python) Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt Guides through the process of registering a new account on Orderly Network. It includes checking existing registration, fetching a nonce, and performing the registration with necessary parameters like broker ID, chain ID, and user address. Requires the `orderly_evm_connector` library. ```python from orderly_evm_connector.rest import Rest as Client client = Client( wallet_secret="your_wallet_private_key_hex", orderly_testnet=True ) # Check if wallet is already registered broker_info = client.get_broker(address="0xYourWalletAddress") print(f"Registration status: {broker_info}") # If not registered, get registration nonce nonce_response = client.get_registration_nonce() registration_nonce = nonce_response['data']['registration_nonce'] # Register account response = client.register_account( brokerId="woofi_pro", # Broker ID chainId=421614, # Chain ID (421614 for Arbitrum Sepolia testnet) registrationNonce=registration_nonce, userAddress="0xYourWalletAddress" ) print(f"Account registered: {response}") ``` -------------------------------- ### Manage Sub-Accounts with Orderly EVM Connector Python Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt Shows how to initialize the Orderly EVM connector client for managing sub-accounts. This setup is essential for applications requiring portfolio segregation and distinct management of trading accounts within the Orderly Network. ```python from orderly_evm_connector.rest import Rest as Client client = Client( orderly_key="ed25519:your_key", orderly_secret="ed25519:your_secret", orderly_account_id="0xYourMainAccountId", orderly_testnet=True ) ``` -------------------------------- ### Manage Referrals with Orderly EVM Connector Python Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt Provides Python code examples for managing referral codes, retrieving referral information, binding to existing codes, and accessing referral history and rebate summaries. This functionality is crucial for incentivizing user growth and tracking rewards. ```python from orderly_evm_connector.rest import Rest as Client client = Client( orderly_key="ed25519:your_key", orderly_secret="ed25519:your_secret", orderly_account_id="0xYourAccountId", orderly_testnet=True ) # Create a referral code response = client.create_referral_code( referral_code="MYCODE123", max_rebate_rate=0.1 # 10% rebate ) print(f"Referral code created: {response}") # Get referral info referral_info = client.get_referral_info() print(f"Referral info: {referral_info}") # Bind to a referral code (for new users) response = client.bind_referral_code(referral_code="FRIENDCODE") print(f"Bound to referral: {response}") # Get referral history history = client.get_referral_history( page=1, size=50 ) print(f"Referral history: {history}") # Get rebate summary rebate_summary = client.get_referral_rebate_summary() print(f"Rebate summary: {rebate_summary}") ``` -------------------------------- ### Install Orderly EVM Connector Source: https://github.com/orderlynetwork/orderly-evm-connector-python/blob/main/README.md Installs the Orderly EVM connector package using pip. This is the primary method for adding the library to your Python project. ```bash pip install orderly-evm-connector ``` -------------------------------- ### Request PnL Settlement and Get History (Python) Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt Demonstrates how to request PnL settlement using a provided nonce and retrieve the settlement history. Requires an initialized client object. ```python response = client.request_pnl_settlement( settle_nonce=settle_nonce ) print(f"Settlement requested: {response}") history = client.get_pnl_settlement_history() print(f"Settlement history: {history}") ``` -------------------------------- ### Get Funding Rate History (Python) Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt Retrieves the historical funding rates for a specific market. Requires market symbol and pagination parameters. ```python from orderly_evm_connector.rest import Rest as Client client = Client( orderly_key="ed25519:your_key", orderly_secret="ed25519:your_secret", orderly_account_id="0xYourAccountId", orderly_testnet=True ) # Get funding rate history history = client.get_funding_rate_history_for_one_market( symbol="PERP_ETH_USDC", page=1, size=50 ) print(f"Funding history: {history}") ``` -------------------------------- ### WebSocket Public Client for Market Data (Python) Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt Demonstrates how to subscribe to real-time public market data streams using the `WebsocketPublicAPIClient`. This includes setting up message handlers and subscribing to various data feeds like 24h tickers, orderbooks, trades, klines, BBO, mark prices, index prices, and funding rates. Requires the `orderly_evm_connector` library and basic Python logging setup. ```python from orderly_evm_connector.websocket.websocket_api import WebsocketPublicAPIClient import time import logging logging.basicConfig(level=logging.INFO) def on_message(_, message): logging.info(f"Received: {message}") def on_close(_): logging.info("Connection closed") def on_error(_, error): logging.error(f"Error: {error}") # Initialize public WebSocket client (no authentication required) wss_client = WebsocketPublicAPIClient( orderly_testnet=True, orderly_account_id="0xYourAccountId", # Required for connection wss_id="my-client-001", # Custom client ID (max 64 bytes) on_message=on_message, on_close=on_close, on_error=on_error, debug=True ) # Subscribe to 24h tickers for all symbols wss_client.get_24h_tickers() # Subscribe to orderbook for specific symbol wss_client.get_orderbook(topic="PERP_ETH_USDC@orderbook") # Subscribe to orderbook updates (200ms interval) wss_client.get_orderbookupdate(topic="PERP_ETH_USDC@orderbookupdate") # Subscribe to trades wss_client.get_trade(topic="PERP_ETH_USDC@trade") # Subscribe to klines (1 minute candles) wss_client.get_kline(topic="PERP_ETH_USDC@kline_1m") # Subscribe to BBO (best bid/offer) wss_client.get_bbo(topic="PERP_ETH_USDC@bbo") # Subscribe to all BBOs wss_client.get_bbos() # Subscribe to mark prices wss_client.get_mark_prices() # Subscribe to index prices wss_client.get_index_prices() # Subscribe to funding rate wss_client.get_estimated_funding_rate(topic="PERP_ETH_USDC@estfundingrate") ``` -------------------------------- ### Utilize Broker APIs with Orderly EVM Connector Python Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt Demonstrates the usage of broker-specific APIs via the Orderly EVM connector in Python. This includes fetching lists of brokers, retrieving user fee tiers, accessing daily trading volumes for brokers, getting default broker fees, and updating user fee rates. ```python from orderly_evm_connector.rest import Rest as Client client = Client( orderly_key="ed25519:your_key", orderly_secret="ed25519:your_secret", orderly_account_id="0xYourAccountId", orderly_testnet=True ) # Get list of brokers brokers = client.get_list_of_brokers() print(f"Brokers: {brokers}") # Get user fee tier fee_tier = client.get_user_fee_tier(account_id="0xUserAccountId") print(f"Fee tier: {fee_tier}") # Get broker daily volume daily_volume = client.get_broker_daily_volume( start_date="2024-01-01", end_date="2024-01-31" ) print(f"Broker daily volume: {daily_volume}") # Get default broker fee default_fee = client.get_default_broker_fee() print(f"Default broker fee: {default_fee}") # Update user fee rate (broker only) response = client.update_user_fee_rate( account_id="0xUserAccountId", futures_maker_fee_rate=0.0001, futures_taker_fee_rate=0.0003 ) print(f"Fee rate updated: {response}") ``` -------------------------------- ### Subscribe to Public WebSocket Events Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt Subscribe to public real-time data streams such as liquidation events and system maintenance status using the WebSocket client. This example demonstrates basic subscription and connection management. ```python # Subscribe to liquidation events wss_client.get_liquidation_push() # Subscribe to system maintenance status wss_client.get_system_maintenance_status() # Keep connection alive time.sleep(60) # Clean up wss_client.stop() ``` -------------------------------- ### Get Volume Statistics (Python) Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt Retrieves overall trading volume statistics for the platform. This is a simple GET request with no specific parameters required. ```python from orderly_evm_connector.rest import Rest as Client client = Client( orderly_key="ed25519:your_key", orderly_secret="ed25519:your_secret", orderly_account_id="0xYourAccountId", orderly_testnet=True ) # Get volume statistics volume = client.get_volume_statistics() print(f"Platform volume: {volume}") ``` -------------------------------- ### Get Account Information Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt Retrieves comprehensive account details, including fee rates, account type, current token holdings, trading volume statistics, and daily performance metrics. Supports fetching leverage settings for specific symbols. ```python from orderly_evm_connector.rest import Rest as Client client = Client( orderly_key="ed25519:your_key", orderly_secret="ed25519:your_secret", orderly_account_id="0xYourAccountId", orderly_testnet=True ) # Get account information (fee rates, account type, etc.) account_info = client.get_account_information() print(f"Account info: {account_info}") # Expected: {'success': True, 'data': {'account_id': '0x...', 'futures_taker_fee_rate': 0.0003, 'futures_maker_fee_rate': 0.0001, ...}} # Get current token holdings holdings = client.get_current_holdings(all=True) # all=True includes zero balances print(f"Holdings: {holdings}") # Get user volume statistics volume_stats = client.get_user_volume_statistics() print(f"Volume stats: {volume_stats}") # Get daily statistics daily_stats = client.get_user_daily_statistics( start_date="2024-01-01", end_date="2024-01-31" ) print(f"Daily stats: {daily_stats}") # Get leverage setting for a symbol leverage = client.get_leverage_setting(symbol="PERP_BTC_USDC") print(f"Leverage setting: {leverage}") ``` -------------------------------- ### Get Funding Fee History (Python) Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt Retrieves the user's funding fee payment history. Requires the trading symbol and a time range (start_t, end_t). Pagination parameters (page, size) are also available. ```python from orderly_evm_connector.rest import Rest as Client import time client = Client( orderly_key="ed25519:your_key", orderly_secret="ed25519:your_secret", orderly_account_id="0xYourAccountId", orderly_testnet=True ) # Get funding fee history end_time = int(time.time() * 1000) start_time = end_time - (30 * 24 * 60 * 60 * 1000) # Last 30 days funding_fees = client.get_funding_fee_history( symbol="PERP_ETH_USDC", start_t=start_time, end_t=end_time, page=1, size=60 ) print(f"Funding fees: {funding_fees}") ``` -------------------------------- ### Get Position Information Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt Retrieves current open positions and historical position data. Supports fetching all positions, a specific symbol's position, and position history with optional filtering. ```python from orderly_evm_connector.rest import Rest as Client client = Client( orderly_key="ed25519:your_key", orderly_secret="ed25519:your_secret", orderly_account_id="0xYourAccountId", orderly_testnet=True ) # Get all positions positions = client.get_all_positions_info() print(f"All positions: {positions}") # Expected: {'success': True, 'data': {'rows': [{'symbol': 'PERP_ETH_USDC', 'position_qty': 0.5, 'average_open_price': 1800.0, ...}]}} # Get position for specific symbol position = client.get_one_position_info(symbol="PERP_ETH_USDC") print(f"ETH position: {position}") # Get position history history = client.get_position_history( symbol="PERP_ETH_USDC", limit=50 ) print(f"Position history: {history}") ``` -------------------------------- ### Get Futures Information (Python) Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt Fetches futures trading information for all markets or a specific market. Requires market symbol for single market queries. ```python from orderly_evm_connector.rest import Rest as Client client = Client( orderly_key="ed25519:your_key", orderly_secret="ed25519:your_secret", orderly_account_id="0xYourAccountId", orderly_testnet=True ) # Get futures information utures_info = client.get_futures_info_for_all_markets() print(f"All futures: {futures_info}") # Get info for one market eth_futures = client.get_futures_info_for_one_market(symbol="PERP_ETH_USDC") print(f"ETH futures info: {eth_futures}") ``` -------------------------------- ### Get Orderbook Snapshot (Python) Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt Fetches the current orderbook for a specified trading pair. Requires authentication and the trading symbol. The `max_level` parameter controls the depth of the orderbook returned. ```python from orderly_evm_connector.rest import Rest as Client client = Client( orderly_key="ed25519:your_key", orderly_secret="ed25519:your_secret", orderly_account_id="0xYourAccountId", orderly_testnet=True ) # Get orderbook snapshot (requires authentication) orderbook = client.get_orderbook_snapshot( symbol="PERP_ETH_USDC", max_level=20 # Number of price levels (default: 100) ) print(f"Orderbook: {orderbook}") # Expected: {'success': True, 'data': {'asks': [[price, qty], ...], 'bids': [[price, qty], ...], 'timestamp': ...}} ``` -------------------------------- ### Get Order Details - Python Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt This code retrieves details for a specific order using its order ID or client-assigned order ID. It also shows how to fetch details for algorithmic orders. The client needs to be initialized with authentication credentials and testnet settings. ```python from orderly_evm_connector.rest import Rest as Client client = Client( orderly_key="ed25519:your_key", orderly_secret="ed25519:your_secret", orderly_account_id="0xYourAccountId", orderly_testnet=True ) # Get order by order_id order = client.get_order(order_id="123456789") print(f"Order details: {order}") # Expected: {'success': True, 'data': {'order_id': 123456789, 'symbol': 'PERP_ETH_USDC', 'status': 'FILLED', ...}} # Get order by client_order_id order_by_client_id = client.get_order_by_client_order_id(client_order_id="my-unique-order-id-001") print(f"Order by client ID: {order_by_client_id}") # Get algo order details algo_order = client.get_algo_order(order_id="987654321") print(f"Algo order: {algo_order}") ``` -------------------------------- ### Initialize REST API Client and Create Order Source: https://github.com/orderlynetwork/orderly-evm-connector-python/blob/main/README.md Demonstrates initializing the REST API client with account information and creating a limit buy order. It requires account details from a config file and specifies order parameters like symbol, type, price, and quantity. ```python from orderly_evm_connector.rest import Rest as Client from orderly_evm_connector.lib.utils import get_account_info (orderly_key, orderly_secret, orderly_account_id, orderly_testnet, wallet_secret, wss_id,) = get_account_info('config.ini') client = Client( orderly_key=orderly_key, orderly_secret=orderly_secret, orderly_account_id=orderly_account_id, orderly_testnet=True, timeout=5 ) # Orders APIs response = client.create_order( symbol="PERP_NEAR_USDC", order_type="LIMIT", side="BUY", order_price=1.95, order_quantity=1, ) ``` -------------------------------- ### Initialize REST API Client (Python) Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt Initializes the REST API client for Orderly Network using credentials loaded from a configuration file. The client handles authentication, request signing, and session management automatically. It supports configuration for testnet/mainnet, timeouts, and debug logging. ```python from orderly_evm_connector.rest import Rest as Client from orderly_evm_connector.lib.utils import get_account_info # Load credentials from config file ( orderly_key, orderly_secret, orderly_account_id, wallet_secret, orderly_testnet, wss_id, ) = get_account_info('config.ini') # Initialize client client = Client( orderly_key=orderly_key, orderly_secret=orderly_secret, orderly_account_id=orderly_account_id, orderly_testnet=True, # True for testnet, False for mainnet wallet_secret=wallet_secret, timeout=5, debug=True # Enable request/response logging ) ``` -------------------------------- ### Get Asset History (Deposits/Withdrawals) (Python) Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt Retrieves transaction history for deposits and withdrawals. Can filter by token, side (DEPOSIT/WITHDRAW), and status (COMPLETED/PROCESSING). Pagination is supported. ```python from orderly_evm_connector.rest import Rest as Client client = Client( orderly_key="ed25519:your_key", orderly_secret="ed25519:your_secret", orderly_account_id="0xYourAccountId", orderly_testnet=True ) # Get all asset history asset_history = client.get_asset_history( page=1, size=50 ) print(f"Asset history: {asset_history}") # Filter by type and status deposits = client.get_asset_history( token="USDC", side="DEPOSIT", status="COMPLETED", page=1, size=25 ) print(f"Completed deposits: {deposits}") withdrawals = client.get_asset_history( side="WITHDRAW", status="PROCESSING" ) print(f"Processing withdrawals: {withdrawals}") ``` -------------------------------- ### Configure Orderly EVM Connector Credentials Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt Sets up the configuration file (`config.ini`) with necessary API keys, account IDs, and wallet secrets for connecting to Orderly Network. This file is used to load credentials for client initialization. ```ini [keys] orderly_key=ed25519:your_orderly_key_here orderly_secret=ed25519:your_orderly_secret_here orderly_account_id=0xYourAccountIdHere orderly_testnet=True wallet_secret=your_wallet_private_key_hex wss_id=MyClientID debug=False ``` -------------------------------- ### REST API Client Initialization Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt Initialize the REST API client to interact with Orderly Network endpoints. The client handles authentication, request signing, and session management automatically. ```APIDOC ## REST API Client Initialization ### Description Initialize the REST API client to interact with Orderly Network endpoints. The client handles authentication, request signing, and session management automatically. ### Method N/A (Initialization) ### Endpoint N/A (Initialization) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python from orderly_evm_connector.rest import Rest as Client from orderly_evm_connector.lib.utils import get_account_info # Load credentials from config file (orderly_key, orderly_secret, orderly_account_id, wallet_secret, orderly_testnet, wss_id) = get_account_info('config.ini') # Initialize client client = Client( orderly_key=orderly_key, orderly_secret=orderly_secret, orderly_account_id=orderly_account_id, orderly_testnet=True, # True for testnet, False for mainnet wallet_secret=wallet_secret, timeout=5, debug=True # Enable request/response logging ) ``` ### Response #### Success Response (200) N/A (Initialization) #### Response Example N/A (Initialization) ``` -------------------------------- ### POST /create_order Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt Place a new order on Orderly Network. Supports LIMIT, MARKET, IOC, FOK, POST_ONLY, ASK, and BID order types. ```APIDOC ## POST /create_order ### Description Place a new order on Orderly Network. Supports LIMIT, MARKET, IOC, FOK, POST_ONLY, ASK, and BID order types. ### Method POST ### Endpoint /create_order ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **symbol** (string) - Required - The trading pair symbol (e.g., PERP_ETH_USDC). - **order_type** (string) - Required - The type of order (e.g., LIMIT, MARKET, IOC, FOK, POST_ONLY). - **side** (string) - Required - The side of the order (BUY or SELL). - **order_quantity** (float) - Required - The quantity of the asset to trade. - **order_price** (float) - Optional - The price for LIMIT orders. Not applicable for MARKET orders. - **client_order_id** (string) - Optional - A unique identifier for the order provided by the client. - **reduce_only** (boolean) - Optional - If True, the order will only be used to reduce an existing position. Defaults to False. ### Request Example ```python from orderly_evm_connector.rest import Rest as Client from orderly_evm_connector.error import ClientError, ServerError client = Client( orderly_key="ed25519:your_key", orderly_secret="ed25519:your_secret", orderly_account_id="0xYourAccountId", orderly_testnet=True ) try: # Create a LIMIT BUY order response = client.create_order( symbol="PERP_ETH_USDC", order_type="LIMIT", side="BUY", order_price=1800.50, order_quantity=0.1, client_order_id="my-unique-order-id-001", # Optional: custom order ID reduce_only=False # Optional: True to only reduce position ) print(f"Order created: {response}") # Create a MARKET SELL order market_order = client.create_order( symbol="PERP_BTC_USDC", order_type="MARKET", side="SELL", order_quantity=0.01 ) print(f"Market order: {market_order}") except ClientError as e: print(f"Client error: {e.status_code} - {e.error_code}: {e.error_message}") except ServerError as e: print(f"Server error: {e.status_code} - {e.message}") ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful. - **data** (object) - Contains the details of the created order. - **order_id** (integer) - The unique identifier for the order on Orderly Network. - **client_order_id** (string) - The client-provided order ID, if provided. - ... (other order details) #### Response Example ```json { "success": true, "data": { "order_id": 123456, "client_order_id": "my-unique-order-id-001", "symbol": "PERP_ETH_USDC", "order_type": "LIMIT", "side": "BUY", "order_price": 1800.50, "order_quantity": 0.1, "created_at": 1678886400000, "status": "NEW" } } ``` ``` -------------------------------- ### Create Single Order (Python) Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt Demonstrates how to place a single order (LIMIT BUY or MARKET SELL) on Orderly Network using the REST API client. It includes error handling for client-side and server-side issues. Supports various order types and optional parameters like `client_order_id` and `reduce_only`. ```python from orderly_evm_connector.rest import Rest as Client from orderly_evm_connector.error import ClientError, ServerError client = Client( orderly_key="ed25519:your_key", orderly_secret="ed25519:your_secret", orderly_account_id="0xYourAccountId", orderly_testnet=True ) try: # Create a LIMIT BUY order response = client.create_order( symbol="PERP_ETH_USDC", order_type="LIMIT", side="BUY", order_price=1800.50, order_quantity=0.1, client_order_id="my-unique-order-id-001", # Optional: custom order ID reduce_only=False # Optional: True to only reduce position ) print(f"Order created: {response}") # Expected output: {'success': True, 'data': {'order_id': 123456, 'client_order_id': 'my-unique-order-id-001', ...}} # Create a MARKET SELL order market_order = client.create_order( symbol="PERP_BTC_USDC", order_type="MARKET", side="SELL", order_quantity=0.01 ) print(f"Market order: {market_order}") except ClientError as e: print(f"Client error: {e.status_code} - {e.error_code}: {e.error_message}") except ServerError as e: print(f"Server error: {e.status_code} - {e.message}") ``` -------------------------------- ### Get Trades History Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt Fetches trade execution history, including recent trades, trades within a time range, specific trades by ID, and all trades associated with a particular order. Requires symbol and optional time filters. ```python from orderly_evm_connector.rest import Rest as Client import time client = Client( orderly_key="ed25519:your_key", orderly_secret="ed25519:your_secret", orderly_account_id="0xYourAccountId", orderly_testnet=True ) # Get recent trades trades = client.get_trades( symbol="PERP_ETH_USDC", page=1, size=50 ) print(f"Recent trades: {trades}") # Get trades with time filter end_time = int(time.time() * 1000) start_time = end_time - (7 * 24 * 60 * 60 * 1000) # Last 7 days trades = client.get_trades( symbol="PERP_BTC_USDC", start_t=start_time, end_t=end_time, page=1, size=100 ) print(f"Filtered trades: {trades}") # Get specific trade by ID trade = client.get_trade(trade_id=12345678) print(f"Trade details: {trade}") # Get all trades for a specific order order_trades = client.get_all_trades_of_order(order_id=123456789) print(f"Order trades: {order_trades}") ``` -------------------------------- ### IP Restriction Management (Python) Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt Shows how to configure IP restrictions for Orderly keys. This includes fetching current IP restrictions, setting new restrictions using a comma-separated list of IPs or ranges, and resetting restrictions to allow or disallow all IPs. Requires an initialized client object. ```python from orderly_evm_connector.rest import Rest as Client client = Client( orderly_key="ed25519:your_key", orderly_secret="ed25519:your_secret", orderly_account_id="0xYourAccountId", orderly_testnet=True ) # Get current IP restrictions restrictions = client.get_orderlykey_ip_restriction(orderly_key="ed25519:your_key") print(f"Current restrictions: {restrictions}") # Set IP restrictions (comma-separated IPs or ranges) response = client.set_orderlykey_ip_restriction( orderly_key="ed25519:your_key", ip_restriction_list="192.168.1.1,10.0.0.0/24" ) print(f"Restrictions set: {response}") # Reset to allow all IPs response = client.reset_orderlykey_ip_restriction( orderly_key="ed25519:your_key", reset_mode="ALLOW_ALL_IPS" # or "DISALLOW_ALL_IPS" ) print(f"Restrictions reset: {response}") ``` -------------------------------- ### Initialize Testnet Clients (REST and WebSocket) Source: https://github.com/orderlynetwork/orderly-evm-connector-python/blob/main/README.md Configures and initializes both REST and private WebSocket clients for the Orderly Testnet. This involves setting the `orderly_testnet` parameter to `True` and providing necessary authentication and connection details. ```python from orderly_evm_connector.rest import Rest as Client from orderly_evm_connector.websocket import WebsocketPrivateAPIClient orderly_testnet = True # Private Websocket Client on Testnet wss_client = WebsocketPrivateAPIClient( orderly_testnet=orderly_testnet, orderly_account_id=orderly_account_id, wss_id=wss_id, orderly_key=orderly_key, orderly_secret=orderly_secret, on_message=message_handler, on_close=on_close, ) # Private REST API Client client = Client( orderly_key=orderly_key, orderly_secret=orderly_secret, orderly_account_id=orderly_account_id, orderly_testnet=orderly_testnet, timeout=5 ) ``` -------------------------------- ### Broker APIs Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt Access broker-specific functionality for builders on the Orderly Network. ```APIDOC ## Broker APIs Access broker-specific functionality for builders on Orderly Network. ### Get List of Brokers Retrieves a list of available brokers on the network. ### Get User Fee Tier Retrieves the fee tier for a specific user account. - **account_id** (str) - Required - The account ID of the user. ### Get Broker Daily Volume Retrieves the daily trading volume for a broker within a specified date range. - **start_date** (str) - Required - The start date in YYYY-MM-DD format. - **end_date** (str) - Required - The end date in YYYY-MM-DD format. ### Get Default Broker Fee Retrieves the default fee structure for brokers. ### Update User Fee Rate Updates the fee rates for a user's futures trading (broker specific). - **account_id** (str) - Required - The account ID of the user. - **futures_maker_fee_rate** (float) - Optional - The new maker fee rate. - **futures_taker_fee_rate** (float) - Optional - The new taker fee rate. ### Request Example (Update User Fee Rate) ```python response = client.update_user_fee_rate( account_id="0xUserAccountId", futures_maker_fee_rate=0.0001, futures_taker_fee_rate=0.0003 ) print(f"Fee rate updated: {response}") ``` ### Response Example (Get List of Brokers) ```json { "data": [ { "broker_id": "broker1", "name": "Example Broker" } ] } ``` ``` -------------------------------- ### Referral System API Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt Manage referral codes, track referral rewards, and bind users to referral codes. ```APIDOC ## Referral System Manage referral codes and track referral rewards. ### Create Referral Code Creates a new referral code with a specified maximum rebate rate. - **referral_code** (str) - Required - The unique referral code. - **max_rebate_rate** (float) - Required - The maximum rebate rate (e.g., 0.1 for 10%). ### Get Referral Info Retrieves information about the current user's referral status. ### Bind Referral Code Binds the current user to an existing referral code. - **referral_code** (str) - Required - The referral code to bind to. ### Get Referral History Retrieves the history of referral activities. - **page** (int) - Optional - The page number for pagination. - **size** (int) - Optional - The number of items per page. ### Get Referral Rebate Summary Retrieves a summary of referral rebates earned. ### Request Example (Create Referral Code) ```python response = client.create_referral_code( referral_code="MYCODE123", max_rebate_rate=0.1 ) print(f"Referral code created: {response}") ``` ### Response Example (Get Referral Info) ```json { "data": { "referral_code": "YOURCODE", "max_rebate_rate": "0.1", "total_rebate": "100.50", "invite_count": 50 } } ``` ``` -------------------------------- ### Get Kline (OHLCV) Data (Python) Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt Retrieves candlestick (OHLCV) data for technical analysis. Supports fetching latest klines with a specified interval and limit, or historical data within a time range. Requires symbol, type/resolution, and time parameters. ```python from orderly_evm_connector.rest import Rest as Client client = Client( orderly_key="ed25519:your_key", orderly_secret="ed25519:your_secret", orderly_account_id="0xYourAccountId", orderly_testnet=True ) # Get latest klines # Type options: 1m, 5m, 15m, 30m, 1h, 4h, 12h, 1d, 1w, 1mon, 1y klines = client.get_kline( symbol="PERP_ETH_USDC", type="1h", limit=100 # Max 1000 ) print(f"Hourly klines: {klines}") # Get historical kline data with time range import time to_timestamp = str(int(time.time())) from_timestamp = str(int(time.time()) - 86400 * 7) # 7 days ago kline_history = client.get_kline_history( symbol="PERP_ETH_USDC", resolution="15m", from_timestamp=from_timestamp, to_timestamp=to_timestamp, limit=500 ) print(f"Kline history: {kline_history}") ``` -------------------------------- ### POST /batch_create_order Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt Create multiple orders in a single request. Maximum 10 orders per batch. ```APIDOC ## POST /batch_create_order ### Description Create multiple orders in a single request. Maximum 10 orders per batch. ### Method POST ### Endpoint /batch_create_order ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **orders** (array) - Required - An array of order objects to be created. - Each order object should have the following properties: - **symbol** (string) - Required - The trading pair symbol. - **order_type** (string) - Required - The type of order (e.g., LIMIT, MARKET). - **side** (string) - Required - The side of the order (BUY or SELL). - **order_quantity** (float) - Required - The quantity of the asset to trade. - **order_price** (float) - Optional - The price for LIMIT orders. ### Request Example ```python from orderly_evm_connector.rest import Rest as Client client = Client( orderly_key="ed25519:your_key", orderly_secret="ed25519:your_secret", orderly_account_id="0xYourAccountId", orderly_testnet=True ) # Define multiple orders orders = [ { "symbol": "PERP_ETH_USDC", "order_type": "LIMIT", "side": "BUY", "order_price": 1750.00, "order_quantity": 0.1 }, { "symbol": "PERP_ETH_USDC", "order_type": "LIMIT", "side": "SELL", "order_price": 1850.00, "order_quantity": 0.1 }, { "symbol": "PERP_BTC_USDC", "order_type": "LIMIT", "side": "BUY", "order_price": 42000.00, "order_quantity": 0.01 } ] response = client.batch_create_order(orders=orders) print(f"Batch orders created: {response}") ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful. - **data** (object) - Contains the results for each order in the batch. - **rows** (array) - An array of objects, where each object represents the result of an individual order creation. - **order_id** (integer) - The unique identifier for the order on Orderly Network. - ... (other order details for each row) #### Response Example ```json { "success": true, "data": { "rows": [ { "order_id": 123, "symbol": "PERP_ETH_USDC", "order_type": "LIMIT", "side": "BUY", "order_price": 1750.00, "order_quantity": 0.1, "status": "NEW" }, { "order_id": 124, "symbol": "PERP_ETH_USDC", "order_type": "LIMIT", "side": "SELL", "order_price": 1850.00, "order_quantity": 0.1, "status": "NEW" }, { "order_id": 125, "symbol": "PERP_BTC_USDC", "order_type": "LIMIT", "side": "BUY", "order_price": 42000.00, "order_quantity": 0.01, "status": "NEW" } ] } } ``` ``` -------------------------------- ### Access Trading Rewards, Campaigns, and Staking with Orderly EVM Connector Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt This Python snippet shows how to interact with trading rewards, campaigns, and staking features using the Orderly EVM Connector. It includes fetching epoch estimates, reward history, staking information, and managing campaign sign-ups. ```python from orderly_evm_connector.rest import Rest as Client client = Client( orderly_key="ed25519:your_key", orderly_secret="ed25519:your_secret", orderly_account_id="0xYourAccountId", orderly_testnet=True ) # Get current epoch estimate for trading rewards epoch_estimate = client.get_current_epoch_estimate() print(f"Epoch estimate: {epoch_estimate}") # Get trading rewards history rewards_history = client.get_account_trading_rewards_history() print(f"Rewards history: {rewards_history}") # Get staking overview staking_overview = client.get_staking_overview() print(f"Staking overview: {staking_overview}") # Get wallet staked balance staked_balance = client.get_wallet_staked_balance(address="0xYourWalletAddress") print(f"Staked balance: {staked_balance}") # Get available campaigns campaigns = client.get_campaigns() print(f"Available campaigns: {campaigns}") # Sign up for a campaign response = client.sign_up_campaign(campaign_id="campaign_123") print(f"Campaign signup: {response}") # Get user points points = client.get_user_points() print(f"User points: {points}") ``` -------------------------------- ### Cancel Order - Python Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt This section provides Python code examples for canceling orders. It covers canceling single orders by order ID or client order ID, canceling all orders for a symbol, canceling all orders across all symbols, batch canceling specific orders, canceling algorithmic orders, and canceling all pending algorithmic orders. ```python from orderly_evm_connector.rest import Rest as Client client = Client( orderly_key="ed25519:your_key", orderly_secret="ed25519:your_secret", orderly_account_id="0xYourAccountId", orderly_testnet=True ) # Cancel single order by order_id response = client.cancel_order(order_id=123456789, symbol="PERP_ETH_USDC") print(f"Cancelled: {response}") # Cancel order by client_order_id response = client.cancel_order_by_client_order_id( client_order_id="my-unique-order-id-001", symbol="PERP_ETH_USDC" ) print(f"Cancelled by client ID: {response}") # Cancel all orders for a symbol response = client.cancel_orders(symbol="PERP_ETH_USDC") print(f"All orders cancelled: {response}") # Cancel all orders across all symbols response = client.cancel_orders() print(f"All orders cancelled: {response}") # Batch cancel specific orders response = client.batch_cancel_orders(order_ids="123456,123457,123458") print(f"Batch cancelled: {response}") # Cancel algo order response = client.cancel_algo_order(order_id=987654321, symbol="PERP_ETH_USDC") print(f"Algo order cancelled: {response}") # Cancel all pending algo orders response = client.cancel_algo_all_pending_order( symbol="PERP_ETH_USDC", algo_type="STOP" # STOP, TAKE_PROFIT, STOP_LOSS, TP_SL, POSITIONAL_TP_SL, BRACKET ) print(f"All algo orders cancelled: {response}") ``` -------------------------------- ### Access Liquidation APIs with Orderly EVM Connector Python Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt Illustrates how to use the Orderly EVM connector in Python to monitor liquidation events. This includes fetching positions under liquidation, retrieving liquidated position details, accessing insurance fund information, claiming liquidated positions, and viewing a liquidator's history. ```python from orderly_evm_connector.rest import Rest as Client client = Client( orderly_key="ed25519:your_key", orderly_secret="ed25519:your_secret", orderly_account_id="0xYourAccountId", orderly_testnet=True ) # Get positions currently under liquidation positions_under_liquidation = client.get_positions_under_liquidation() print(f"Positions under liquidation: {positions_under_liquidation}") # Get liquidated positions info liquidated_info = client.get_liquidated_positions_info() print(f"Liquidated positions: {liquidated_info}") # Get insurance fund info insurance_fund = client.get_insurance_fund_info() print(f"Insurance fund: {insurance_fund}") # For liquidators: claim liquidated positions response = client.claim_liquidated_positions( liquidation_id=12345, symbol="PERP_ETH_USDC", quantity=0.5 ) print(f"Claimed position: {response}") # Get your liquidation history (as liquidator) liquidator_history = client.get_liquidated_positions_by_liquidator() print(f"Liquidator history: {liquidator_history}") ``` -------------------------------- ### Liquidation APIs Source: https://context7.com/orderlynetwork/orderly-evm-connector-python/llms.txt Monitor and participate in liquidation events on the Orderly Network. ```APIDOC ## Liquidation APIs Monitor and participate in liquidation events. ### Get Positions Under Liquidation Retrieves a list of positions that are currently under liquidation. ### Get Liquidated Positions Info Retrieves information about positions that have been liquidated. ### Get Insurance Fund Info Retrieves the current status and details of the insurance fund. ### Claim Liquidated Positions Allows liquidators to claim liquidated positions. - **liquidation_id** (int) - Required - The ID of the liquidation event. - **symbol** (str) - Required - The trading symbol of the position. - **quantity** (float) - Required - The quantity to claim. ### Get Liquidated Positions By Liquidator Retrieves the liquidation history for the current liquidator. ### Request Example (Claim Liquidated Positions) ```python response = client.claim_liquidated_positions( liquidation_id=12345, symbol="PERP_ETH_USDC", quantity=0.5 ) print(f"Claimed position: {response}") ``` ### Response Example (Get Positions Under Liquidation) ```json { "data": [ { "symbol": "PERP_ETH_USDC", "account_id": "0xUserAccountId", "liquidation_price": "1750.00", "position_size": "1.2" } ] } ``` ```