### Install FalconX Python Client Source: https://github.com/falconxio/falconx-python/blob/master/README.md Installs the FalconX Python client library using pip. This is the primary step to begin using the client for API interactions. No specific inputs or outputs are described for this command. ```shell pip install falconx ``` -------------------------------- ### Quickstart: FalconX Client Initialization and Quote Execution Source: https://github.com/falconxio/falconx-python/blob/master/README.md Demonstrates initializing the FalconxClient with API credentials and executing a quote. It shows how to fetch a quote for a currency pair and then execute that quote. Requires API key, secret, and passphrase as input. ```python from falconx import FalconxClient client = FalconxClient(key=KEY, secret=SECRET, passphrase=PASSPHRASE) quote = client.get_quote('BTC', 'USD', 5, 'two_way') result = client.execute_quote(quote['fx_quote_id'], 'buy') ``` -------------------------------- ### Get Trading Limits Source: https://context7.com/falconxio/falconx-python/llms.txt Retrieve account trading limits and constraints for different platforms and token pairs. ```APIDOC ## GET /trades/limits ### Description Retrieve account trading limits and constraints for different platforms and token pairs. ### Method GET ### Endpoint /trades/limits ### Parameters #### Query Parameters - **platform** (string) - Optional - Filter limits by a specific trading platform. ### Request Example ```python from falconx import FalconxClient client = FalconxClient(key=KEY, secret=SECRET, passphrase=PASSPHRASE) # Get trade limits for API platform limits = client.get_trade_limits(platform='api') # Get trade size recommendations trade_sizes = client.get_trade_sizes() ``` ### Response #### Success Response (200) - **platform** (string) - The trading platform. - **limits** (array) - An array of trading limit objects. - **token_pair** (object) - The trading pair. - **base_token** (string) - The base token symbol. - **quote_token** (string) - The quote token symbol. - **min_order_size** (float) - The minimum order size for the token pair. - **max_order_size** (float) - The maximum order size for the token pair. - **max_daily_volume** (float) - The maximum daily trading volume for the token pair. #### Response Example ```json { "platform": "api", "limits": [ { "token_pair": {"base_token": "BTC", "quote_token": "USD"}, "min_order_size": 0.001, "max_order_size": 100.0, "max_daily_volume": 500.0 }, { "token_pair": {"base_token": "ETH", "quote_token": "USD"}, "min_order_size": 0.01, "max_order_size": 1000.0, "max_daily_volume": 5000.0 } ] } ``` ``` -------------------------------- ### Place Limit Order with Fill-or-Kill using FalconX Source: https://context7.com/falconxio/falconx-python/llms.txt Shows how to place a limit order with the 'fill-or-kill' (fok) time-in-force parameter. This order type requires specifying a limit price and can optionally include slippage tolerance. The example initializes the FalconxClient and constructs the order parameters. ```python from falconx import FalconxClient # Assuming KEY, SECRET, PASSPHRASE are defined elsewhere client = FalconxClient(key=KEY, secret=SECRET, passphrase=PASSPHRASE) # Place a limit order with FOK (fill or kill) limit_order = client.place_order( base='BTC', quote='USD', quantity=1.5, side='buy', order_type='limit', time_in_force='fok', limit_price=45000.00, slippage_bps=10, # Allow 10 basis points of slippage v3=True, client_order_id='limit-order-456', client_order_uuid='449886ed1461467c8489c58b3d22381c' ) ``` -------------------------------- ### GET /trading_pairs Source: https://context7.com/falconxio/falconx-python/llms.txt Retrieve all trading pairs available to your account for trading operations. ```APIDOC ## GET /trading_pairs ### Description Retrieve all trading pairs available to your account for trading operations. ### Method GET ### Endpoint /trading_pairs ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python from falconx import FalconxClient client = FalconxClient(key=KEY, secret=SECRET, passphrase=PASSPHRASE) # Get all available trading pairs pairs = client.get_trading_pairs() # Example response: # [ # {'base_token': 'BTC', 'quote_token': 'USD'}, # {'base_token': 'ETH', 'quote_token': 'USD'}, # {'base_token': 'ETH', 'quote_token': 'BTC'}, # {'base_token': 'USDC', 'quote_token': 'USD'} # ] # Iterate through available pairs for pair in pairs: print(f"Trade {pair['base_token']}/{pair['quote_token']}") ``` ### Response #### Success Response (200) - **base_token** (string) - The base token of the trading pair. - **quote_token** (string) - The quote token of the trading pair. #### Response Example ```json [ {'base_token': 'BTC', 'quote_token': 'USD'}, {'base_token': 'ETH', 'quote_token': 'USD'}, {'base_token': 'ETH', 'quote_token': 'BTC'}, {'base_token': 'USDC', 'quote_token': 'USD'} ] ``` ``` -------------------------------- ### Get Historical Executed Quotes with FalconX Python Source: https://context7.com/falconxio/falconx-python/llms.txt Demonstrates how to retrieve a history of executed quotes within a specified time range using the `get_executed_quotes` method. This is useful for reconciliation and reporting. The example calculates the total trading volume from the retrieved data. ```python from falconx import FalconxClient from datetime import datetime, timedelta # Assuming KEY, SECRET, PASSPHRASE are defined elsewhere client = FalconxClient(key=KEY, secret=SECRET, passphrase=PASSPHRASE) # Get executed quotes for the last 24 hours t_end = datetime.utcnow().isoformat() + '+00:00' t_start = (datetime.utcnow() - timedelta(days=1)).isoformat() + '+00:00' executed = client.get_executed_quotes( t_start=t_start, t_end=t_end, platform='api' ) # Calculate total volume total_usd = sum( float(q['price_executed']) * float(q['quantity_requested']['value']) for q in executed if q['is_filled'] ) print(f"Total trading volume: ${total_usd:,.2f}") ``` -------------------------------- ### Get Account Balances Source: https://context7.com/falconxio/falconx-python/llms.txt Retrieve current token balances across different trading platforms in your account. You can fetch all balances or filter by a specific platform. ```APIDOC ## GET /balances ### Description Retrieve current token balances across different trading platforms in your account. ### Method GET ### Endpoint /balances ### Parameters #### Query Parameters - **platform** (string) - Optional - Filter balances by a specific trading platform (e.g., 'api', 'browser'). ### Request Example ```python from falconx import FalconxClient client = FalconxClient(key=KEY, secret=SECRET, passphrase=PASSPHRASE) # Get all balances balances = client.get_balances() # Get balances for specific platform api_balances = client.get_balances(platform='api') ``` ### Response #### Success Response (200) - **balance** (float) - The amount of the token. - **token** (string) - The symbol of the token. - **platform** (string) - The trading platform where the balance is held. #### Response Example ```json [ {'balance': 2.5, 'token': 'BTC', 'platform': 'browser'}, {'balance': 15.3772, 'token': 'ETH', 'platform': 'api'}, {'balance': 187624.21, 'token': 'USD', 'platform': 'api'}, {'balance': 50000.00, 'token': 'USDC', 'platform': 'api'} ] ``` ``` -------------------------------- ### POST /quote Source: https://context7.com/falconxio/falconx-python/llms.txt Get buy and sell quotes for a specific token pair with specified quantity and side preferences. Can request a two-way quote, buy-only, or sell-only. ```APIDOC ## POST /quote ### Description Get buy and sell quotes for a specific token pair with specified quantity and side preferences. Can request a two-way quote, buy-only, or sell-only. ### Method POST ### Endpoint /quote ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **base** (string) - Required - The base token for the quote (e.g., 'BTC'). - **quote** (string) - Required - The quote token for the quote (e.g., 'USD'). - **quantity** (number) - Required - The amount of the base token to trade. - **side** (string) - Required - The side of the quote ('buy', 'sell', or 'two_way'). - **client_order_id** (string) - Optional - A unique identifier for the order. - **is_quote_token_quantity** (boolean) - Optional - If true, the quantity is in the quote token amount (e.g., USD amount for BTC/USD pair). Defaults to false. ### Request Example ```python from falconx import FalconxClient client = FalconxClient(key=KEY, secret=SECRET, passphrase=PASSPHRASE) # Request a two-way quote for 5 BTC quote = client.get_quote( base='BTC', quote='USD', quantity=5, side='two_way', client_order_id='order-123-abc' ) # Request buy-only quote buy_quote = client.get_quote('ETH', 'USD', 10, 'buy') # Request quote in quote token terms (USD instead of BTC) usd_based_quote = client.get_quote( base='BTC', quote='USD', quantity=50000, # $50,000 worth of BTC side='buy', is_quote_token_quantity=True ) ``` ### Response #### Success Response (200) - **status** (string) - Status of the quote request ('success'). - **fx_quote_id** (string) - Unique identifier for the quote. - **buy_price** (number) - The buy price for the quote. - **sell_price** (number) - The sell price for the quote. - **token_pair** (object) - Details of the token pair. - **base_token** (string) - The base token. - **quote_token** (string) - The quote token. - **quantity_requested** (object) - The quantity requested. - **token** (string) - The token symbol. - **value** (string) - The quantity value. - **side_requested** (string) - The side requested ('buy', 'sell', 'two_way'). - **t_quote** (string) - Timestamp when the quote was created. - **t_expiry** (string) - Timestamp when the quote expires. - **is_filled** (boolean) - Indicates if the quote has been filled. - **client_order_id** (string) - The client-provided order ID, if provided. #### Response Example ```json { "status": "success", "fx_quote_id": "00c884b056f949338788dfb59e495377", "buy_price": 12650.0, "sell_price": 12648.50, "token_pair": { "base_token": "BTC", "quote_token": "USD" }, "quantity_requested": { "token": "BTC", "value": "5" }, "side_requested": "two_way", "t_quote": "2019-06-27T11:59:21.875725+00:00", "t_expiry": "2019-06-27T11:59:22.875725+00:00", "is_filled": false, "client_order_id": "order-123-abc" } ``` ``` -------------------------------- ### Check Quote Status with FalconX Python Client Source: https://context7.com/falconxio/falconx-python/llms.txt Provides a Python example for checking the status of a specific quote using its ID. The `get_quote_status` method is called on an initialized FalconxClient. The response indicates whether the quote has been filled and provides execution details if available. ```python from falconx import FalconxClient # Assuming KEY, SECRET, PASSPHRASE are defined elsewhere client = FalconxClient(key=KEY, secret=SECRET, passphrase=PASSPHRASE) # Get quote status by ID fx_quote_id = "00c884b056f949338788dfb59e495377" status = client.get_quote_status(fx_quote_id) if status['is_filled']: print(f"Quote filled at {status['price_executed']} by {status['trader_email']}") else: print(f"Quote not yet filled, expires at {status['t_expiry']}") ``` -------------------------------- ### Get Available Trading Pairs Source: https://context7.com/falconxio/falconx-python/llms.txt Retrieves a list of all available trading pairs for an account. This function is crucial for identifying valid currency combinations for trading operations. The output is a list of dictionaries, each specifying the base and quote tokens. ```python from falconx import FalconxClient client = FalconxClient(key=KEY, secret=SECRET, passphrase=PASSPHRASE) # Get all available trading pairs pairs = client.get_trading_pairs() # Example response: # [ # {'base_token': 'BTC', 'quote_token': 'USD'}, # {'base_token': 'ETH', 'quote_token': 'USD'}, # {'base_token': 'ETH', 'quote_token': 'BTC'}, # {'base_token': 'USDC', 'quote_token': 'USD'} # ] # Iterate through available pairs for pair in pairs: print(f"Trade {pair['base_token']}/{pair['quote_token']}") ``` -------------------------------- ### Get Deposit and Withdrawal History with FalconX Python Client Source: https://context7.com/falconxio/falconx-python/llms.txt Retrieve historical records of deposits and withdrawals for audit and reconciliation purposes. This function requires specifying a start and end time, and optionally a platform. It returns a list of transfer records, which can then be used to calculate net transfers per token. ```python from falconx import FalconxClient from datetime import datetime, timedelta client = FalconxClient(key=KEY, secret=SECRET, passphrase=PASSPHRASE) # Get transfers for the last 30 days t_end = datetime.utcnow().isoformat() + '+00:00' t_start = (datetime.utcnow() - timedelta(days=30)).isoformat() + '+00:00' transfers = client.get_transfers( t_start=t_start, t_end=t_end, platform='api' ) # Example response: # [ # { # "type": "deposit", # "platform": "api", # "token": "BTC", # "quantity": 1.0, # "t_create": "2019-06-20T01:01:01+00:00" # }, # { # "type": "withdrawal", # "platform": "midas", # "token": "BTC", # "quantity": 0.5, # "t_create": "2019-06-22T01:01:01+00:00" # } # ] # Calculate net transfers by token from collections import defaultdict net_transfers = defaultdict(float) for transfer in transfers: amount = transfer['quantity'] if transfer['type'] == 'deposit': net_transfers[transfer['token']] += amount else: net_transfers[transfer['token']] -= amount for token, net in net_transfers.items(): print(f"{token}: {net:+.8f}") ``` -------------------------------- ### Get Trade Volume Statistics Source: https://context7.com/falconxio/falconx-python/llms.txt Retrieve trading volume statistics for a specified time period to monitor activity levels. You can get volume for a specific range or a trailing 30-day volume. ```APIDOC ## GET /trades/volume ### Description Retrieve trading volume statistics for a specified time period. ### Method GET ### Endpoint /trades/volume ### Parameters #### Query Parameters - **t_start** (string) - Optional - The start of the time range (ISO 8601 format). - **t_end** (string) - Optional - The end of the time range (ISO 8601 format). ### Request Example ```python from falconx import FalconxClient from datetime import datetime, timedelta client = FalconxClient(key=KEY, secret=SECRET, passphrase=PASSPHRASE) # Get trade volume for last 7 days t_end = datetime.utcnow().isoformat() + '+00:00' t_start = (datetime.utcnow() - timedelta(days=7)).isoformat() + '+00:00' volume = client.get_trade_volume(t_start=t_start, t_end=t_end) # Get 30-day trailing volume trailing_volume = client.get_30_day_trailing_volume() ``` ### Response #### Success Response (200) - **total_volume_usd** (float) - Total trading volume in USD. - **trade_count** (integer) - Total number of trades. - **average_trade_size** (float) - Average size of trades in USD. - **tokens** (object) - Object containing volume statistics per token. - **[token_symbol]** (object) - Statistics for a specific token. - **volume** (float) - Trading volume for the token. - **volume_usd** (float) - Trading volume for the token in USD. #### Response Example ```json { "total_volume_usd": 5000000.00, "trade_count": 145, "average_trade_size": 34482.76, "tokens": { "BTC": {"volume": 50.5, "volume_usd": 2500000.00}, "ETH": {"volume": 1250.0, "volume_usd": 2500000.00} } } ``` ``` -------------------------------- ### Get Deposit and Withdrawal History Source: https://context7.com/falconxio/falconx-python/llms.txt Retrieve historical records of deposits and withdrawals for audit and reconciliation purposes. You can filter by date range and platform. ```APIDOC ## GET /transfers ### Description Retrieve historical records of deposits and withdrawals for audit and reconciliation purposes. ### Method GET ### Endpoint /transfers ### Parameters #### Query Parameters - **t_start** (string) - Required - The start of the time range for transfers (ISO 8601 format). - **t_end** (string) - Required - The end of the time range for transfers (ISO 8601 format). - **platform** (string) - Optional - Filter transfers by a specific trading platform. ### Request Example ```python from falconx import FalconxClient from datetime import datetime, timedelta client = FalconxClient(key=KEY, secret=SECRET, passphrase=PASSPHRASE) # Get transfers for the last 30 days t_end = datetime.utcnow().isoformat() + '+00:00' t_start = (datetime.utcnow() - timedelta(days=30)).isoformat() + '+00:00' transfers = client.get_transfers( t_start=t_start, t_end=t_end, platform='api' ) ``` ### Response #### Success Response (200) - **type** (string) - 'deposit' or 'withdrawal'. - **platform** (string) - The trading platform. - **token** (string) - The symbol of the token. - **quantity** (float) - The amount of the token transferred. - **t_create** (string) - The timestamp of the transfer creation (ISO 8601 format). #### Response Example ```json [ { "type": "deposit", "platform": "api", "token": "BTC", "quantity": 1.0, "t_create": "2019-06-20T01:01:01+00:00" }, { "type": "withdrawal", "platform": "midas", "token": "BTC", "quantity": 0.5, "t_create": "2019-06-22T01:01:01+00:00" } ] ``` ``` -------------------------------- ### Get Account Balances with FalconX Python Client Source: https://context7.com/falconxio/falconx-python/llms.txt Retrieve current token balances across different trading platforms in your account. This function allows fetching all balances or filtering by a specific platform. It requires the FalconxClient to be initialized with API credentials. ```python from falconx import FalconxClient client = FalconxClient(key=KEY, secret=SECRET, passphrase=PASSPHRASE) # Get all balances balances = client.get_balances() # Example response: # [ # {'balance': 2.5, 'token': 'BTC', 'platform': 'browser'}, # {'balance': 15.3772, 'token': 'ETH', 'platform': 'api'}, # {'balance': 187624.21, 'token': 'USD', 'platform': 'api'}, # {'balance': 50000.00, 'token': 'USDC', 'platform': 'api'} # ] # Get balances for specific platform api_balances = client.get_balances(platform='api') # Display balances for bal in balances: if bal['balance'] > 0: print(f"{bal['token']}: {bal['balance']} ({bal['platform']})") # Get total balances across all platforms total_balances = client.get_total_balances() ``` -------------------------------- ### Get Derivative Margin Requirements with Python FalconX Client Source: https://context7.com/falconxio/falconx-python/llms.txt This snippet demonstrates how to retrieve the total margin requirements for all derivative positions, aggregated by token. It also shows how to check available balances against these requirements. The function requires API keys and returns a list of margin requirements per token and can compare them against fetched balances. ```python from falconx import FalconxClient client = FalconxClient(key=KEY, secret=SECRET, passphrase=PASSPHRASE) # Get margin requirements for all derivatives margins = client.get_derivatives_margin() # Example response: # [ # { # "token": "BTC", # "total_margin": 10.1 # }, # { # "token": "ETH", # "total_margin": 32.31 # }, # { # "token": "USD", # "total_margin": 250000.00 # } # ] # Calculate total margin in USD equivalent for margin in margins: token = margin['token'] amount = margin['total_margin'] print(f"{token} margin required: {amount}") # Check if sufficient balances exist balances = client.get_balances() balance_dict = {b['token']: b['balance'] for b in balances} for margin in margins: token = margin['token'] required = margin['total_margin'] available = balance_dict.get(token, 0) if available < required: print(f"WARNING: Insufficient {token} margin. Required: {required}, Available: {available}") ``` -------------------------------- ### Get Trading Limits with FalconX Python Client Source: https://context7.com/falconxio/falconx-python/llms.txt Retrieve account trading limits and constraints for different platforms and token pairs. This function allows fetching limits for a specific platform and also retrieving general trade size recommendations. The response details minimum and maximum order sizes, and daily volume limits. ```python from falconx import FalconxClient client = FalconxClient(key=KEY, secret=SECRET, passphrase=PASSPHRASE) # Get trade limits for API platform limits = client.get_trade_limits(platform='api') # Example response: # { # "platform": "api", # "limits": [ # { # "token_pair": {"base_token": "BTC", "quote_token": "USD"}, # "min_order_size": 0.001, # "max_order_size": 100.0, # "max_daily_volume": 500.0 # }, # { # "token_pair": {"base_token": "ETH", "quote_token": "USD"}, # "min_order_size": 0.01, # "max_order_size": 1000.0, # "max_daily_volume": 5000.0 # } # ] # } # Get trade size recommendations trade_sizes = client.get_trade_sizes() ``` -------------------------------- ### Get Trade Volume Statistics with FalconX Python Client Source: https://context7.com/falconxio/falconx-python/llms.txt Retrieve trading volume statistics for a specified time period to monitor activity levels. This function allows fetching volume for a date range or a trailing period. The response includes total volume, trade count, and per-token volume details. ```python from falconx import FalconxClient from datetime import datetime, timedelta client = FalconxClient(key=KEY, secret=SECRET, passphrase=PASSPHRASE) # Get trade volume for last 7 days t_end = datetime.utcnow().isoformat() + '+00:00' t_start = (datetime.utcnow() - timedelta(days=7)).isoformat() + '+00:00' volume = client.get_trade_volume(t_start=t_start, t_end=t_end) # Get 30-day trailing volume trailing_volume = client.get_30_day_trailing_volume() # Example response: # { # "total_volume_usd": 5000000.00, # "trade_count": 145, # "average_trade_size": 34482.76, # "tokens": { # "BTC": {"volume": 50.5, "volume_usd": 2500000.00}, # "ETH": {"volume": 1250.0, "volume_usd": 2500000.00} # } # } print(f"30-day volume: ${trailing_volume.get('total_volume_usd', 0):,.2f}") ``` -------------------------------- ### Get API Rate Limits with Python FalconX Client Source: https://context7.com/falconxio/falconx-python/llms.txt This snippet demonstrates how to check the current API rate limit status using the FalconX Python client. It helps in optimizing request patterns to avoid throttling. The function requires API keys and returns information about requests per minute, remaining requests, and reset time. ```python from falconx import FalconxClient client = FalconxClient(key=KEY, secret=SECRET, passphrase=PASSPHRASE) # Get current rate limit status rate_limits = client.get_rate_limits() # Example response: # { # "requests_per_minute": 60, # "requests_remaining": 45, # "reset_time": "2019-07-10T15:31:00+00:00", # "burst_limit": 10, # "burst_remaining": 8 # } if rate_limits['requests_remaining'] < 10: print("Warning: Approaching rate limit") print(f"Resets at: {rate_limits['reset_time']}") ``` -------------------------------- ### Get Derivative Positions with Python FalconX Client Source: https://context7.com/falconxio/falconx-python/llms.txt This snippet shows how to retrieve derivative positions, including options, NDFs, and interest rate swaps, along with their mark-to-market data. The function allows filtering by trade status, product type, and market list. It returns a list of derivative positions, each with detailed trade information. ```python from falconx import FalconxClient client = FalconxClient(key=KEY, secret=SECRET, passphrase=PASSPHRASE) # Get all open derivative positions derivatives = client.get_derivatives(trade_status='open') # Get specific product types options = client.get_derivatives( trade_status='open', product_type='option', market_list='BTC-USD,ETH-USD' ) # Get NDFs (non-deliverable forwards) ndfs = client.get_derivatives(product_type='ndf') # Example response: # [ # { # "trade_id": "13db3a3f832e444a90435e900d1c3222", # "product": "option", # "option_type": "put", # "status": "open", # "token_pair": { # "base_token": "BTC", # "quote_token": "USD" # }, # "quantity": 100.0, # "side": "sell", # "strike_price": { # "token": "USD", # "value": 20000.0 # }, # "premium": { # "token": "USD", # "value": 100000.00 # }, # "maturity_date": "2022-02-26T00:00:00+00:00", # "trade_date": "2022-02-26T00:03:00+00:00", # "fixing_expiry_time": "4pm NYC", # "spot_reference_price": { # "token": "USD", # "value": 20010.0 # }, # "daily_mark": { # "value": -2.0, # "token": "USD" # }, # "delta": -262.0, # "vega": { # "value": -272.0, # "token": "USD" # }, # "counterparty_margin_percent": { # "value": 15.0, # "token": "USD" # }, # "trader": "william@client.com", # "trading_entity": "solios" # } # ] # Calculate total exposure total_notional = sum( pos.get('trade_notional', {}).get('value', 0) for pos in derivatives ) print(f"Total derivative exposure: ${total_notional:,.2f}") ``` -------------------------------- ### Place Market Orders with FalconX Python Client Source: https://context7.com/falconxio/falconx-python/llms.txt Demonstrates how to place market orders for both selling ETH and buying BTC. It requires initializing the FalconxClient with API credentials and specifies base/quote tokens, quantity, side, and order type. The v3 parameter is used for the latest API version. ```python from falconx import FalconxClient # Assuming KEY, SECRET, PASSPHRASE are defined elsewhere client = FalconxClient(key=KEY, secret=SECRET, passphrase=PASSPHRASE) # Place a market order to sell 0.1 ETH order = client.place_order( base='ETH', quote='USD', quantity=0.1, side='sell', order_type='market', v3=True, client_order_id='market-order-001' ) # Place a market order to buy 2 BTC buy_order = client.place_order( base='BTC', quote='USD', quantity=2.0, side='buy', order_type='market', v3=True ) ``` -------------------------------- ### Client Initialization Source: https://context7.com/falconxio/falconx-python/llms.txt Initialize the FalconX client with authentication credentials to access all trading and account management functions. The client can also be configured with a custom API URL. ```APIDOC ## Client Initialization ### Description Initialize the FalconX client with authentication credentials to access all trading and account management functions. ### Method N/A (Constructor) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python from falconx import FalconxClient # Initialize client with credentials KEY = "your_api_key" SECRET = "your_base64_encoded_secret" PASSPHRASE = "your_passphrase" client = FalconxClient(key=KEY, secret=SECRET, passphrase=PASSPHRASE) # Custom API URL (optional) client_custom = FalconxClient( key=KEY, secret=SECRET, passphrase=PASSPHRASE, url="https://staging.api.falconx.io/" ) ``` ### Response N/A (Initialization) #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Initialize FalconX Client with Credentials Source: https://context7.com/falconxio/falconx-python/llms.txt Initializes the FalconX client using API credentials (key, secret, passphrase). Supports specifying a custom API URL for different environments like staging. This client is essential for all subsequent API interactions. ```python from falconx import FalconxClient # Initialize client with credentials KEY = "your_api_key" SECRET = "your_base64_encoded_secret" PASSPHRASE = "your_passphrase" client = FalconxClient(key=KEY, secret=SECRET, passphrase=PASSPHRASE) # Custom API URL (optional) client_custom = FalconxClient( key=KEY, secret=SECRET, passphrase=PASSPHRASE, url="https://staging.api.falconx.io/" ) ``` -------------------------------- ### FalconX Client: Place New Order Endpoint (v3) Source: https://github.com/falconxio/falconx-python/blob/master/README.md Illustrates placing a new order using the faster v3 endpoint. This method allows for more efficient order placement compared to older versions. Optional 'v3' argument controls endpoint usage. Requires asset, counter-asset, amount, order type, and order side as input. ```python from falconx import FalconxClient client = FalconxClient(key=KEY, secret=SECRET, passphrase=PASSPHRASE) client.place_order('ETH', 'USD', 0.1, 'sell', 'market', v3=True) ``` -------------------------------- ### Place Market Order (V3 Endpoint) Source: https://context7.com/falconxio/falconx-python/llms.txt Places an immediate market order using the V3 endpoint, designed for faster execution. This method is suitable for time-sensitive trading operations where rapid order placement is critical. It requires initialized client credentials. ```python from falconx import FalconxClient client = FalconxClient(key=KEY, secret=SECRET, passphrase=PASSPHRASE) ``` -------------------------------- ### POST /v3/market_order Source: https://context7.com/falconxio/falconx-python/llms.txt Place an immediate market order using the faster V3 endpoint for improved execution speed. ```APIDOC ## POST /v3/market_order ### Description Place an immediate market order using the faster V3 endpoint for improved execution speed. ### Method POST ### Endpoint /v3/market_order ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body (Details for this endpoint are not provided in the input text.) ### Request Example ```python from falconx import FalconxClient client = FalconxClient(key=KEY, secret=SECRET, passphrase=PASSPHRASE) # Example usage (payload structure needs to be defined based on API specification) # result = client.place_market_order(symbol='BTC-USD', side='buy', quantity=0.1) ``` ### Response #### Success Response (200) (Details for this endpoint are not provided in the input text.) #### Response Example (Details for this endpoint are not provided in the input text.) ``` -------------------------------- ### FalconX Client: RFQ in Quote Token Terms Source: https://github.com/falconxio/falconx-python/blob/master/README.md Shows how to request a quote using quote token terms. This variation of the get_quote method allows specifying the quantity in terms of quote tokens. Requires currency pair, amount, and quote type as input. ```python quote = client.get_quote('BTC', 'USD', 5, 'two_way', is_quote_token_quantity=True) ``` -------------------------------- ### POST /execute_quote Source: https://context7.com/falconxio/falconx-python/llms.txt Execute a previously requested quote by specifying the quote ID and execution side. This action commits to the trade at the quoted price. ```APIDOC ## POST /execute_quote ### Description Execute a previously requested quote by specifying the quote ID and execution side. This action commits to the trade at the quoted price. ### Method POST ### Endpoint /execute_quote ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **fx_quote_id** (string) - Required - The unique identifier of the quote to execute. - **side** (string) - Required - The side of the quote to execute ('buy' or 'sell'). ### Request Example ```python from falconx import FalconxClient client = FalconxClient(key=KEY, secret=SECRET, passphrase=PASSPHRASE) # First, get a quote quote = client.get_quote('BTC', 'USD', 5, 'two_way') fx_quote_id = quote['fx_quote_id'] # Execute the buy side of the quote result = client.execute_quote(fx_quote_id, 'buy') if result['is_filled']: print(f"Order executed at price: {result['price_executed']}") else: print(f"Order failed: {result['error']}") ``` ### Response #### Success Response (200) - **status** (string) - Status of the execution ('success'). - **fx_quote_id** (string) - The unique identifier of the executed quote. - **buy_price** (number) - The buy price at the time of execution. - **sell_price** (number) - The sell price at the time of execution. - **is_filled** (boolean) - Indicates if the order was successfully filled. - **price_executed** (number) - The actual price at which the order was executed. - **side_executed** (string) - The side that was executed ('buy' or 'sell'). - **side_requested** (string) - The side originally requested for the quote. - **quantity_requested** (object) - Details of the quantity requested. - **token** (string) - The token symbol. - **value** (string) - The quantity value. - **t_quote** (string) - Timestamp when the quote was created. - **t_expiry** (string) - Timestamp when the quote expired. - **t_execute** (string) - Timestamp when the execution occurred. - **token_pair** (object) - Details of the token pair. - **base_token** (string) - The base token. - **quote_token** (string) - The quote token. - **error** (string or null) - Error message if the execution failed. #### Response Example ```json { 'status': 'success', 'fx_quote_id': 'fad0ac687b1e439a92a0bafd92441e48', 'buy_price': 294.0, 'sell_price': 293.94, 'is_filled': True, 'price_executed': 294.0, 'side_executed': 'buy', 'side_requested': 'two_way', 'quantity_requested': {'token': 'ETH', 'value': '0.10000'}, 't_quote': '2019-07-03T21:45:07.198688+00:00', 't_expiry': '2019-07-03T21:45:17.198692+00:00', 't_execute': '2019-07-03T21:45:10.358335+00:00', 'token_pair': {'base_token': 'ETH', 'quote_token': 'USD'}, 'error': None } ``` ``` -------------------------------- ### Execute a Quote Source: https://context7.com/falconxio/falconx-python/llms.txt Executes a previously obtained quote using its unique `fx_quote_id` and specifying the execution side ('buy' or 'sell'). The response indicates if the order was filled and provides details like executed price and the side executed. Error handling is included. ```python from falconx import FalconxClient client = FalconxClient(key=KEY, secret=SECRET, passphrase=PASSPHRASE) # First, get a quote quote = client.get_quote('BTC', 'USD', 5, 'two_way') fx_quote_id = quote['fx_quote_id'] # Execute the buy side of the quote result = client.execute_quote(fx_quote_id, 'buy') # Example response: # { # 'status': 'success', # 'fx_quote_id': 'fad0ac687b1e439a92a0bafd92441e48', # 'buy_price': 294.0, # 'sell_price': 293.94, # 'is_filled': True, # 'price_executed': 294.0, # 'side_executed': 'buy', # 'side_requested': 'two_way', # 'quantity_requested': {'token': 'ETH', 'value': '0.10000'}, # 't_quote': '2019-07-03T21:45:07.198688+00:00', # 't_expiry': '2019-07-03T21:45:17.198692+00:00', # 't_execute': '2019-07-03T21:45:10.358335+00:00', # 'token_pair': {'base_token': 'ETH', 'quote_token': 'USD'}, # 'error': None # } if result['is_filled']: print(f"Order executed at price: {result['price_executed']}") else: print(f"Order failed: {result['error']}") ``` -------------------------------- ### Request a Two-Way Quote Source: https://context7.com/falconxio/falconx-python/llms.txt Requests a two-way quote (buy and sell prices) for a specified token pair, quantity, and side preference. It can also handle requests for buy-only or sell-only quotes and allows specifying quantity in quote token terms. Includes `client_order_id` for tracking. ```python from falconx import FalconxClient client = FalconxClient(key=KEY, secret=SECRET, passphrase=PASSPHRASE) # Request a two-way quote for 5 BTC quote = client.get_quote( base='BTC', quote='USD', quantity=5, side='two_way', client_order_id='order-123-abc' ) # Example response: # { # "status": "success", # "fx_quote_id": "00c884b056f949338788dfb59e495377", # "buy_price": 12650.0, # "sell_price": 12648.50, # "token_pair": { # "base_token": "BTC", # "quote_token": "USD" # }, # "quantity_requested": { # "token": "BTC", # "value": "5" # }, # "side_requested": "two_way", # "t_quote": "2019-06-27T11:59:21.875725+00:00", # "t_expiry": "2019-06-27T11:59:22.875725+00:00", # "is_filled": false, # "client_order_id": "order-123-abc" # } # Request buy-only quote buy_quote = client.get_quote('ETH', 'USD', 10, 'buy') # Request quote in quote token terms (USD instead of BTC) usd_based_quote = client.get_quote( base='BTC', quote='USD', quantity=50000, # $50,000 worth of BTC side='buy', is_quote_token_quantity=True ) ``` -------------------------------- ### Submit Withdrawal Request Source: https://context7.com/falconxio/falconx-python/llms.txt Request a withdrawal of tokens from your FalconX account to an external wallet. Requires token, amount, and platform. ```APIDOC ## POST /withdrawals ### Description Request a withdrawal of tokens from your FalconX account to an external wallet. ### Method POST ### Endpoint /withdrawals ### Parameters #### Request Body - **token** (string) - Required - The symbol of the token to withdraw. - **amount** (float) - Required - The amount of the token to withdraw. - **platform** (string) - Required - The platform from which to withdraw. ### Request Example ```python from falconx import FalconxClient client = FalconxClient(key=KEY, secret=SECRET, passphrase=PASSPHRASE) # Submit withdrawal request withdrawal = client.submit_withdrawal_request( token='BTC', amount=0.5, platform='api' ) ``` ### Response #### Success Response (200) - **status** (string) - Overall status of the request submission (e.g., 'success'). - **withdrawal_id** (string) - Unique identifier for the withdrawal request. - **token** (string) - The symbol of the token withdrawn. - **amount** (float) - The amount withdrawn. - **platform** (string) - The platform from which the withdrawal was made. - **status** (string) - The current status of the withdrawal (e.g., 'pending'). - **t_create** (string) - The timestamp when the withdrawal was created (ISO 8601 format). #### Response Example ```json { "status": "success", "withdrawal_id": "wd-12345", "token": "BTC", "amount": 0.5, "platform": "api", "status": "pending", "t_create": "2019-07-10T15:30:00+00:00" } ``` ``` -------------------------------- ### Submit Withdrawal Request with FalconX Python Client Source: https://context7.com/falconxio/falconx-python/llms.txt Request a withdrawal of tokens from your FalconX account to an external wallet. This function requires specifying the token, amount, and destination platform. It returns a status indicating success or failure, along with withdrawal details. ```python from falconx import FalconxClient client = FalconxClient(key=KEY, secret=SECRET, passphrase=PASSPHRASE) # Submit withdrawal request withdrawal = client.submit_withdrawal_request( token='BTC', amount=0.5, platform='api' ) # Example response: # { # "status": "success", # "withdrawal_id": "wd-12345", # "token": "BTC", # "amount": 0.5, # "platform": "api", # "status": "pending", # "t_create": "2019-07-10T15:30:00+00:00" # } if withdrawal.get('status') == 'success': print(f"Withdrawal request submitted: {withdrawal.get('withdrawal_id')}") else: print(f"Withdrawal failed: {withdrawal.get('text')}") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.