Usage
# Sell a specific number of shares
result = client.market_sell(token_id="your-token-id", shares=50)
# Or sell a specific USDC worth of shares
result = client.market_sell(token_id="your-token-id", usdc_amount=100)
Market orders execute immediately at the best available prices. Use shares to sell a specific quantity, or usdc_amount to sell a fixed dollar value.
Parameters
The outcome token ID to sell.
Number of shares to sell. Preferred for precise position management.
USDC value of shares to sell. Will be converted to shares using the current market price.
Provide either shares OR usdc_amount, not both.
Response
Order status (typically FILLED or CANCELLED for market orders).
Order execution latency in milliseconds.
Examples
Sell a specific number of shares
from polyhush import PolyhushClient
client = PolyhushClient(api_key="your-api-key")
# Sell 50 shares at market price
result = client.market_sell(
token_id="12345678901234567890",
shares=50
)
print(f"Order: {result['order_id']}")
print(f"Status: {result['status']}")
Sell a specific USDC value
# Sell $100 worth of shares at market price
result = client.market_sell(
token_id="12345678901234567890",
usdc_amount=100
)
print(f"Sold shares, order: {result['order_id']}")
Close entire position
# Get position details
positions = client.get_position_details()
position = next((p for p in positions if p['token_id'] == "12345678901234567890"), None)
if position:
# Sell all available shares
result = client.market_sell(
token_id="12345678901234567890",
shares=position['available_to_sell']
)
print(f"Closed position: {result['status']}")
Response
{
"order_id": "ord_mkt456",
"status": "FILLED",
"message": "Market order filled",
"latency_ms": 48
}
How It Works
Market sell orders use the FAK (Fill And Kill) order type:
- The order is placed at a low price to ensure it fills
- It matches against existing buy orders on the book
- Whatever fills immediately is executed
- Any unfilled portion is cancelled
Using shares is recommended for selling because:
- You know exactly how many shares you’re selling
- Easier to manage your position size
- The
available_to_sell field tells you exactly what you can sell
You can only sell shares you own and that aren’t reserved for other sell orders. Check available_to_sell in position details before placing a sell order.