PolyhushClient class is the main entry point for all API operations.
Constructor
Parameters
Your Polyhush API key. If not provided, the client will look for the
POLYHUSH_API_KEY environment variable.Raises
ValueError- If no API key is provided andPOLYHUSH_API_KEYenvironment variable is not set.
Class Attributes
Order Type Constants
| Constant | Value | Description |
|---|---|---|
GTC | "GTC" | Limit order that sits on the order book until filled or cancelled |
FOK | "FOK" | Must be fully filled immediately or the entire order is cancelled |
FAK | "FAK" | Fills what’s available immediately, cancels the rest (market order) |
Methods
Account & Balance
get_balance()
Get your USDC balance and optional portfolio summary
Positions
get_positions()
Get your current positions with optional P&L details
Orders
buy()
Place a buy order
sell()
Place a sell order
cancel_orders()
Cancel orders
sync_orders()
Sync order status
Market Data
get_ticker()
Get current price ticker