RoundTripTrade
Documentation for eth_defi.hyperliquid.trade_history.RoundTripTrade Python class.
- class RoundTripTrade
Bases:
objectA round-trip trade from position open through close.
Groups individual fills from position-open to position-close with volume-weighted average entry/exit prices, funding costs, and PnL.
For positions that were already open before the data window,
is_completeisFalseandentry_pricemay be unknown.Attributes summary
Asset symbol (e.g., "BTC", "ETH")
Trade direction
Whether the position is still open
Whether we have the full open→close lifecycle (False when position was already open before data window)
Timestamp when the position was first opened (or earliest known fill)
Timestamp when the position was closed (None if still open)
Volume-weighted average entry price
Volume-weighted average exit price (None if still open or no exits)
Maximum position size reached during the trade
Current position size (0 if closed)
Realised PnL from fills (sum of closed_pnl)
Total funding payments during this trade
Total fees paid across all fills
Net PnL (realised_pnl + funding_pnl - total_fees)
Unrealised PnL from clearinghouse state (open trades only)
All fills belonging to this trade
All funding payments during this trade's lifetime
Duration of the trade
Number of fills
Methods summary
__init__(coin, direction, is_open, ...[, ...])- coin: str
Asset symbol (e.g., “BTC”, “ETH”)
- direction: eth_defi.hyperliquid.position.PositionDirection
Trade direction
- is_open: bool
Whether the position is still open
- is_complete: bool
Whether we have the full open→close lifecycle (False when position was already open before data window)
- opened_at: datetime.datetime
Timestamp when the position was first opened (or earliest known fill)
- closed_at: datetime.datetime | None
Timestamp when the position was closed (None if still open)
- entry_price: decimal.Decimal
Volume-weighted average entry price
- exit_price: decimal.Decimal | None
Volume-weighted average exit price (None if still open or no exits)
- max_size: decimal.Decimal
Maximum position size reached during the trade
- current_size: decimal.Decimal
Current position size (0 if closed)
- realised_pnl: decimal.Decimal
Realised PnL from fills (sum of closed_pnl)
- funding_pnl: decimal.Decimal
Total funding payments during this trade
- total_fees: decimal.Decimal
Total fees paid across all fills
- net_pnl: decimal.Decimal
Net PnL (realised_pnl + funding_pnl - total_fees)
- unrealised_pnl: decimal.Decimal | None
Unrealised PnL from clearinghouse state (open trades only)
- fills: list[eth_defi.hyperliquid.position.Fill]
All fills belonging to this trade
- funding_payments: list[eth_defi.hyperliquid.trade_history.FundingPayment]
All funding payments during this trade’s lifetime
- duration: datetime.timedelta | None
Duration of the trade
- fill_count: int
Number of fills
- __init__(coin, direction, is_open, is_complete, opened_at, closed_at, entry_price, exit_price, max_size, current_size, realised_pnl, funding_pnl, total_fees, net_pnl, unrealised_pnl, fills=<factory>, funding_payments=<factory>, duration=None, fill_count=0, _entry_cost=Decimal('0'), _entry_size=Decimal('0'), _exit_cost=Decimal('0'), _exit_size=Decimal('0'))
- Parameters
coin (str) –
direction (eth_defi.hyperliquid.position.PositionDirection) –
is_open (bool) –
is_complete (bool) –
opened_at (datetime.datetime) –
closed_at (datetime.datetime | None) –
entry_price (decimal.Decimal) –
exit_price (decimal.Decimal | None) –
max_size (decimal.Decimal) –
current_size (decimal.Decimal) –
realised_pnl (decimal.Decimal) –
funding_pnl (decimal.Decimal) –
total_fees (decimal.Decimal) –
net_pnl (decimal.Decimal) –
unrealised_pnl (decimal.Decimal | None) –
fills (list[eth_defi.hyperliquid.position.Fill]) –
funding_payments (list[eth_defi.hyperliquid.trade_history.FundingPayment]) –
duration (datetime.timedelta | None) –
fill_count (int) –
_entry_cost (decimal.Decimal) –
_entry_size (decimal.Decimal) –
_exit_cost (decimal.Decimal) –
_exit_size (decimal.Decimal) –
- Return type
None