Skip to main content

Signature

client.get_positions(detailed: bool = False) -> List[Dict]

Parameters

ParameterTypeDescription
detailedboolIf True, includes current prices, P&L, and market info. Default: False

Returns

Basic (detailed=False):
FieldTypeDescription
market_idstringMarket/condition ID
token_idstringToken identifier
sidestringPosition side
sizefloatShares held
average_pricefloatAverage entry price
Detailed (detailed=True): adds these fields:
FieldTypeDescription
market_questionstringThe market question
outcome_namestringName of the outcome
current_pricefloat or NoneCurrent market price (None if unavailable)
unrealized_pnlfloat or NoneUnrealized P&L in USDC (None if price unavailable)
unrealized_pnl_pctfloat or NoneP&L as percentage (None if price unavailable)
market_valuefloat or NoneCurrent market value of position (None if price unavailable)
cost_basisfloatOriginal cost of position
reserved_for_sellfloatShares reserved in pending sell orders
available_to_sellfloatShares 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.