PositionEvent

Documentation for eth_defi.hyperliquid.position.PositionEvent Python class.

class PositionEvent

Bases: object

Represents 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

event_type

Type of position event

coin

Asset symbol (e.g., "BTC", "ETH")

direction

Position direction

size

Size of this fill (always positive)

price

Execution price

timestamp

Event timestamp

position_after

Position size after this event (positive = long, negative = short)

realized_pnl

Realized PnL for closes/decreases (None for opens/increases)

fill_hash

Transaction hash

order_id

Order ID

trade_id

Trade ID

fee

Fee paid

fee_token

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)

fill_hash: str | None

Transaction hash

order_id: int | None

Order ID

trade_id: int | None

Trade ID

fee: decimal.Decimal | None

Fee paid

fee_token: str | None

Fee token (e.g., “USDC”)

__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
Return type

None