Usage
result = client.buy(
token_id="your-token-id",
shares=10,
price=0.55,
order_type="GTC" # Optional, defaults to GTC
)
For market orders that execute immediately, use market_buy() instead.
Parameters
The outcome token ID to buy.
Limit price per share (0.01 - 0.99).
Order type:
GTC - Good Till Cancelled (limit order, sits on book)
FOK - Fill Or Kill (must fully fill immediately or cancel)
FAK - Fill And Kill (fills immediately, cancels unfilled)
Response
Order status after placement.
Warning message, if any (e.g., partial fill warning).
Order execution latency in milliseconds.
Example
from polyhush import PolyhushClient, PolyhushAPIError
client = PolyhushClient(api_key="your-api-key")
try:
result = client.buy(
token_id="12345678901234567890",
shares=100,
price=0.55,
order_type="GTC"
)
print(f"Order placed: {result['order_id']}")
print(f"Status: {result['status']}")
print(f"Latency: {result['latency_ms']}ms")
if result.get('warning'):
print(f"⚠️ Warning: {result['warning']}")
except PolyhushAPIError as e:
print(f"Order failed: {e.message}")
Response
{
"order_id": "ord_abc123",
"status": "PLACED",
"message": "Order placed successfully",
"latency_ms": 45
}
Order Type Behavior
| Type | Behavior |
|---|
GTC | Order sits on book until filled or cancelled |
FOK | Must fill completely immediately or cancels |
FAK | Fills what’s available, cancels rest |
Use GTC orders to get better pricing by providing liquidity. Use FAK (via market_buy()) when you need immediate execution.