Signature
client.get_positions(detailed: bool = False) -> List[Dict]
Parameters
| Parameter | Type | Description |
|---|
detailed | bool | If True, includes current prices, P&L, and market info. Default: False |
Returns
Basic (detailed=False):
| Field | Type | Description |
|---|
market_id | string | Market/condition ID |
token_id | string | Token identifier |
side | string | Position side |
size | float | Shares held |
average_price | float | Average entry price |
Detailed (detailed=True): adds these fields:
| Field | Type | Description |
|---|
market_question | string | The market question |
outcome_name | string | Name of the outcome |
current_price | float or None | Current market price (None if unavailable) |
unrealized_pnl | float or None | Unrealized P&L in USDC (None if price unavailable) |
unrealized_pnl_pct | float or None | P&L as percentage (None if price unavailable) |
market_value | float or None | Current market value of position (None if price unavailable) |
cost_basis | float | Original cost of position |
reserved_for_sell | float | Shares reserved in pending sell orders |
available_to_sell | float | Shares available to sell (size - reserved_for_sell) |
Important: reserved_for_sell and available_to_sell are only included when detailed=True. Always check available_to_sell before placing sell orders to avoid overselling.
Example
from polyhush import PolyhushClient
client = PolyhushClient(api_key="your-api-key")
# Basic positions
positions = client.get_positions()
for pos in positions:
print(f"{pos['side']}: {pos['size']} shares @ ${pos['average_price']:.2f}")
# Detailed with P&L
positions = client.get_positions(detailed=True)
for pos in positions:
print(f"{pos['market_question'][:40]}...")
print(f" P&L: ${pos['unrealized_pnl']:.2f} ({pos['unrealized_pnl_pct']:+.1f}%)")
Use detailed=True for dashboards. Check available_to_sell before placing sell orders.