### Get Account Balance Source: https://context7.com/danielboye/exbitron-cli/llms.txt Retrieve the available and locked balance for a specific cryptocurrency in your Exbitron wallet. Requires authentication with valid API keys. ```python import exbitron client = exbitron.Client( access_key="your_access_key", secret_key="your_secret_key" ) # Get XKR balance xkr_balance = client.get("/api/v2/peatio/account/balances/xkr") print(f"XKR Balance: {xkr_balance['balance']}") # Output: XKR Balance: 1250.50 # Get BTC balance btc_balance = client.get("/api/v2/peatio/account/balances/btc") print(f"BTC Balance: {btc_balance['balance']}") # Output: BTC Balance: 0.00542 # Get USDT balance usdt_balance = client.get("/api/v2/peatio/account/balances/usdt") print(f"USDT Balance: {usdt_balance['balance']}") # Output: USDT Balance: 150.25 ``` -------------------------------- ### Get Order Book Depth Source: https://context7.com/danielboye/exbitron-cli/llms.txt Retrieve current ask and bid prices from the order book for a trading pair. The depth endpoint provides top orders at specified limits. ```python import exbitron client = exbitron.Client( access_key="your_access_key", secret_key="your_secret_key" ) # Get order book depth for BTC/USDT depth = client.get("/api/v2/peatio/public/markets/btcusdt/depth?limit=1") # Get best ask price (lowest sell order) best_ask = float(depth['asks'][0][0]) print(f"Best Ask: ${best_ask}") # Output: Best Ask: $42360.00 # Get best bid price (highest buy order) best_bid = float(depth['bids'][0][0]) print(f"Best Bid: ${best_bid}") # Output: Best Bid: $42340.00 # Get order book with more depth depth_10 = client.get("/api/v2/peatio/public/markets/btcusdt/depth?limit=10") for i, ask in enumerate(depth_10['asks'][:5]): print(f"Ask {i+1}: Price={ask[0]}, Volume={ask[1]}") ``` -------------------------------- ### Get Market Price Source: https://context7.com/danielboye/exbitron-cli/llms.txt Fetch the latest trade price for a specific trading pair by querying the public trades endpoint. Returns the most recent trade price. ```python import exbitron client = exbitron.Client( access_key="your_access_key", secret_key="your_secret_key" ) # Get BTC/USDT price from last trade btc_trades = client.get("/api/v2/peatio/public/markets/btcusdt/trades?limit=1") btc_price = float(btc_trades[0]['price']) print(f"BTC Price: ${btc_price}") # Output: BTC Price: $42350.50 # Get ETH/USDT price eth_trades = client.get("/api/v2/peatio/public/markets/ethusdt/trades?limit=1") eth_price = float(eth_trades[0]['price']) print(f"ETH Price: ${eth_price}") # Output: ETH Price: $2250.75 ``` -------------------------------- ### Initialize Exbitron Client Source: https://context7.com/danielboye/exbitron-cli/llms.txt Initialize the Exbitron client using API credentials. Credentials can be loaded from environment variables using dotenv or provided directly. ```python import exbitron import os from dotenv import load_dotenv load_dotenv() # Initialize client with API credentials from environment variables client = exbitron.Client( access_key=os.getenv('ACCESS_KEY'), secret_key=os.getenv('SECRET_KEY') ) # Or initialize with credentials directly client = exbitron.Client( endpoint="https://www.exbitron.com", access_key="fe12eb8b793dbbc9", secret_key="82f57fe6471b7f0e2bc665f97e41a7", timeout=60 ) ``` -------------------------------- ### Launch Interactive CLI Shell Source: https://context7.com/danielboye/exbitron-cli/llms.txt Commands for setting up and running the interactive terminal interface. ```bash # Setup and run the CLI chmod +x setup.sh ./setup.sh # Or run directly with Python python cli.py # CLI Commands available in the shell: # exbitron >> wallet - View wallet balances # exbitron >> oversikt - Overview of XKR, BTC, USDT balances # exbitron >> price btc - Get BTC/USDT price # exbitron >> ask btc - Get best ask price for BTC # exbitron >> bid btc - Get best bid price for BTC # exbitron >> spread btc - Calculate BTC spread percentage # exbitron >> clear - Clear terminal screen # exbitron >> exit - Exit the CLI # Example session: # exbitron >> price btc # Prisen til btc er 42350.50 # # exbitron >> spread btc # Spread til btc er på: 0.05% ``` -------------------------------- ### Configure Environment Variables Source: https://context7.com/danielboye/exbitron-cli/llms.txt Set API credentials via .env file or shell environment variables. ```bash # .env file format ACCESS_KEY=fe12eb8b793dbbc9 SECRET_KEY=82f57fe6471b7f0e2bc665f97e41a7 # Or set environment variables directly export ACCESS_KEY="fe12eb8b793dbbc9" export SECRET_KEY="82f57fe6471b7f0e2bc665f97e41a7" # Then run the CLI python cli.py # Answer 'Y' when prompted to use default API keys ``` -------------------------------- ### Make Public API Requests Source: https://context7.com/danielboye/exbitron-cli/llms.txt Use the get_public method to fetch market data without requiring API credentials. ```python import exbitron # Initialize client without credentials for public endpoints client = exbitron.Client() # Get public market data markets = client.get_public("/api/v2/peatio/public/markets") print(f"Available markets: {len(markets)}") # Get ticker info ticker = client.get_public("/api/v2/peatio/public/markets/btcusdt/tickers") print(f"24h Volume: {ticker['ticker']['volume']}") print(f"24h High: {ticker['ticker']['high']}") print(f"24h Low: {ticker['ticker']['low']}") ``` -------------------------------- ### Calculate Spread Source: https://context7.com/danielboye/exbitron-cli/llms.txt Calculate the bid-ask spread percentage for a trading pair. This function queries the order book depth and computes the spread as a percentage of the ask price. ```python import exbitron client = exbitron.Client( access_key="your_access_key", secret_key="your_secret_key" ) def calculate_spread(symbol): """Calculate spread percentage for a trading pair.""" depth = client.get(f"/api/v2/peatio/public/markets/{symbol}usdt/depth?limit=1") ask = float(depth['asks'][0][0]) bid = float(depth['bids'][0][0]) spread = ask - bid spread_percent = round(spread / ask, 4) * 100 return spread_percent # Calculate BTC spread btc_spread = calculate_spread("btc") print(f"BTC Spread: {btc_spread}%") # Output: BTC Spread: 0.05% # Calculate ETH spread eth_spread = calculate_spread("eth") print(f"ETH Spread: {eth_spread}%") # Output: ETH Spread: 0.12% ``` -------------------------------- ### Generate HMAC-SHA256 Authentication Signature Source: https://context7.com/danielboye/exbitron-cli/llms.txt Manual generation of authentication headers required for signed API requests. ```python import exbitron import hashlib import hmac from time import time # Authentication is handled automatically by the Client class # The Auth class generates these headers for each request: # - x-auth-apikey: Your access key # - x-auth-nonce: Timestamp in milliseconds # - x-auth-signature: HMAC-SHA256 signature of (nonce + access_key) # Manual signature generation (for reference) access_key = "your_access_key" secret_key = "your_secret_key" nonce = str(int(time() * 1000)) signature = hmac.new( secret_key.encode(), (nonce + access_key).encode(), hashlib.sha256 ).hexdigest() print(f"Nonce: {nonce}") print(f"Signature: {signature}") # Output: Nonce: 1699547892543 # Output: Signature: 8f4e2a1b9c3d5e7f... ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.