LighterEquity

Documentation for eth_defi.lighter.valuation.LighterEquity Python class.

class LighterEquity

Bases: object

Equity breakdown for a Lighter trading account.

See fetch_lighter_total_equity().

Attributes summary

account_index

Lighter account index.

collateral

Account collateral before unrealised position PnL.

unrealised_pnl

Sum of positions[].unrealized_pnl in the collateral currency.

total_asset_value

Canonical account NAV reported by Lighter as total_asset_value.

available_balance

Free collateral balance available for new orders or withdrawals.

initial_margin_requirement

Cross-margin initial margin requirement in the collateral currency.

maintenance_margin_requirement

Cross-margin maintenance margin requirement in the collateral currency.

position_count

Number of open position records returned by the Lighter API.

Methods summary

__init__(account_index, collateral, ...)

calculate_total_from_parts()

Calculate account NAV from collateral and unrealised PnL.

get_total()

Return canonical Lighter account NAV.

account_index: int

Lighter account index.

collateral: decimal.Decimal

Account collateral before unrealised position PnL.

unrealised_pnl: decimal.Decimal

Sum of positions[].unrealized_pnl in the collateral currency.

total_asset_value: decimal.Decimal

Canonical account NAV reported by Lighter as total_asset_value.

available_balance: decimal.Decimal

Free collateral balance available for new orders or withdrawals.

initial_margin_requirement: decimal.Decimal

Cross-margin initial margin requirement in the collateral currency.

maintenance_margin_requirement: decimal.Decimal

Cross-margin maintenance margin requirement in the collateral currency.

position_count: int

Number of open position records returned by the Lighter API.

get_total()

Return canonical Lighter account NAV.

Lighter exposes total_asset_value directly, so this method returns the API value instead of recomputing it locally. Use calculate_total_from_parts() for a collateral plus PnL sanity check.

Returns

Account net asset value in the deployment’s collateral currency.

Return type

decimal.Decimal

calculate_total_from_parts()

Calculate account NAV from collateral and unrealised PnL.

Returns

collateral + unrealised_pnl in the collateral currency.

Return type

decimal.Decimal

__init__(account_index, collateral, unrealised_pnl, total_asset_value, available_balance, initial_margin_requirement, maintenance_margin_requirement, position_count)
Parameters
Return type

None