curl --request GET \
--url https://api.example.com/api/v1/trading/positions/details{
"positions": [
{
"market_id": "<string>",
"token_id": "<string>",
"side": "<string>",
"size": 123,
"average_price": 123,
"market_question": "<string>",
"outcome_name": "<string>",
"current_price": 123,
"unrealized_pnl": 123,
"unrealized_pnl_pct": 123,
"market_value": 123,
"cost_basis": 123,
"reserved_for_sell": 123,
"available_to_sell": 123
}
]
}Get detailed position information including unrealized P&L
curl --request GET \
--url https://api.example.com/api/v1/trading/positions/details{
"positions": [
{
"market_id": "<string>",
"token_id": "<string>",
"side": "<string>",
"size": 123,
"average_price": 123,
"market_question": "<string>",
"outcome_name": "<string>",
"current_price": 123,
"unrealized_pnl": 123,
"unrealized_pnl_pct": 123,
"market_value": 123,
"cost_basis": 123,
"reserved_for_sell": 123,
"available_to_sell": 123
}
]
}positions = client.get_position_details()
Show Position object
from polyhush import PolyhushClient
client = PolyhushClient(api_key="your-api-key")
positions = client.get_position_details()
total_value = 0
total_pnl = 0
for pos in positions:
total_value += pos['market_value']
total_pnl += pos['unrealized_pnl']
# Color-code P&L
pnl_indicator = "📈" if pos['unrealized_pnl'] >= 0 else "📉"
print(f"{pnl_indicator} {pos['market_question']}")
print(f" Position: {pos['size']} {pos['outcome_name']} shares")
print(f" Entry: ${pos['average_price']:.2f} → Current: ${pos['current_price']:.2f}")
print(f" P&L: ${pos['unrealized_pnl']:.2f} ({pos['unrealized_pnl_pct']:.1f}%)")
print(f" Value: ${pos['market_value']:.2f}")
print()
print(f"━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
print(f"Total Portfolio Value: ${total_value:.2f}")
print(f"Total Unrealized P&L: ${total_pnl:.2f}")
[
{
"market_id": "0x1234...abcd",
"token_id": "12345678901234567890",
"side": "Yes",
"size": 100,
"average_price": 0.55,
"market_question": "Will BTC exceed $100k by end of 2024?",
"outcome_name": "Yes",
"current_price": 0.65,
"unrealized_pnl": 10.00,
"unrealized_pnl_pct": 18.18,
"market_value": 65.00,
"cost_basis": 55.00,
"reserved_for_sell": 0,
"available_to_sell": 100
}
]
unrealized_pnl is calculated as: (current_price - average_price) × size