Skip to main content
POST
/
api
/
v1
/
trading
/
orders
Market Sell
curl --request POST \
  --url https://api.example.com/api/v1/trading/orders \
  --header 'Content-Type: application/json' \
  --data '
{
  "token_id": "<string>",
  "shares": 123,
  "usdc_amount": 123
}
'
{
  "order_id": "<string>",
  "status": "<string>",
  "message": "<string>",
  "warning": "<string>",
  "latency_ms": 123
}

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

token_id
string
required
The outcome token ID to sell.
shares
number
Number of shares to sell. Preferred for precise position management.
usdc_amount
number
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_id
string
The created order ID.
status
string
Order status (typically FILLED or CANCELLED for market orders).
message
string
Status message.
warning
string
Warning message, if any.
latency_ms
number
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:
  1. The order is placed at a low price to ensure it fills
  2. It matches against existing buy orders on the book
  3. Whatever fills immediately is executed
  4. 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.