PositionEvent
Documentation for eth_defi.hyperliquid.position.PositionEvent Python class.
- class PositionEvent
Bases:
objectRepresents a position change event reconstructed from fill data.
Position events are derived by processing fills chronologically and detecting when positions are opened, closed, increased, or decreased.
Attributes summary
Type of position event
Asset symbol (e.g., "BTC", "ETH")
Position direction
Size of this fill (always positive)
Execution price
Event timestamp
Position size after this event (positive = long, negative = short)
Realized PnL for closes/decreases (None for opens/increases)
Transaction hash
Order ID
Trade ID
Fee paid
Fee token (e.g., "USDC")
Methods summary
__init__(event_type, coin, direction, size, ...)- event_type: eth_defi.hyperliquid.position.PositionEventType
Type of position event
- coin: str
Asset symbol (e.g., “BTC”, “ETH”)
- direction: eth_defi.hyperliquid.position.PositionDirection
Position direction
- size: decimal.Decimal
Size of this fill (always positive)
- price: decimal.Decimal
Execution price
- timestamp: datetime.datetime
Event timestamp
- position_after: decimal.Decimal
Position size after this event (positive = long, negative = short)
- realized_pnl: decimal.Decimal | None
Realized PnL for closes/decreases (None for opens/increases)
- fee: decimal.Decimal | None
Fee paid
- __init__(event_type, coin, direction, size, price, timestamp, position_after, realized_pnl=None, fill_hash=None, order_id=None, trade_id=None, fee=None, fee_token=None)
- Parameters
event_type (eth_defi.hyperliquid.position.PositionEventType) –
coin (str) –
direction (eth_defi.hyperliquid.position.PositionDirection) –
size (decimal.Decimal) –
price (decimal.Decimal) –
timestamp (datetime.datetime) –
position_after (decimal.Decimal) –
realized_pnl (decimal.Decimal | None) –
fill_hash (str | None) –
order_id (int | None) –
trade_id (int | None) –
fee (decimal.Decimal | None) –
fee_token (str | None) –
- Return type
None