harbor run -t openthoughts/tasktrove-mix-h1-struggle-zone-v2-mix-h1-struggle-zone-0620harbor download openthoughts/tasktrove-mix-h1-struggle-zone-v2-mix-h1-struggle-zone-0620solution file
from hyperliquid.api import API
from hyperliquid.utils.types import Any, Callable, Meta, Optional, Subscription, cast
from hyperliquid.websocket_manager import WebsocketManager
class Info(API):
def __init__(self, base_url=None, skip_ws=False):
super().__init__(base_url)
if not skip_ws:
self.ws_manager = WebsocketManager(self.base_url)
self.ws_manager.start()
def user_state(self, address: str) -> Any:
"""Retrieve trading details about a user.
POST /info
Args:
address (str): Onchain address in 42-character hexadecimal format;
e.g. 0x0000000000000000000000000000000000000000.
Returns:
{
assetPositions: [
{
position: {
coin: str,
entryPx: Optional[float string]
leverage: {
type: "cross" | "isolated",
value: int,
rawUsd: float string # only if type is "isolated"
},
liquidationPx: Optional[float string]
marginUsed: float string,
maxTradeSzs: List[float string],
positionValue: float string,
returnOnEquity: float string,
szi: float string,
unrealizedPnl: float string
},
type: "oneWay"
}
],
crossMarginSummary: MarginSummary,
marginSummary: MarginSummary
}
where MarginSummary is {
accountValue: float string,
totalMarginUsed: float string,
totalNtlPos: float string,
totalRawUsd: float string,
withdrawable: float string,
}
"""
return self.
Complete the code above, taking into account the cross-file context provided. Your solution must work correctly with the related files in the project.
Place your complete solution in /app/solution.py