agent0.chainsync.analysis.calc_position_value ============================================= .. py:module:: agent0.chainsync.analysis.calc_position_value .. autoapi-nested-parse:: Calculates the pnl. .. !! processed by numpydoc !! Functions --------- .. autoapisummary:: agent0.chainsync.analysis.calc_position_value.calc_single_closeout agent0.chainsync.analysis.calc_position_value.calc_closeout_value agent0.chainsync.analysis.calc_position_value.fill_pnl_values Module Contents --------------- .. py:function:: calc_single_closeout(position: pandas.Series, interface: agent0.ethpy.hyperdrive.HyperdriveReadInterface, hyperdrive_state: agent0.ethpy.hyperdrive.state.PoolState, checkpoint_share_prices: pandas.Series, coerce_float: bool) -> decimal.Decimal | float Calculate the closeout value for a single position. :param position: The position to calculate the closeout value for (one row in current_wallet). :type position: pd.DataFrame :param interface: The hyperdrive read interface. :type interface: HyperdriveReadInterface :param hyperdrive_state: The hyperdrive pool state. :type hyperdrive_state: PoolState :param checkpoint_share_prices: A series with the index as checkpoint time and the value as the share prices. :type checkpoint_share_prices: pd.Series :param coerce_float: If True, will coerce underlying Decimals to floats. :type coerce_float: bool :returns: The closeout position value. Type depends on the coerce_float argument. :rtype: Decimal | float .. !! processed by numpydoc !! .. py:function:: calc_closeout_value(current_positions: pandas.DataFrame, checkpoint_info: pandas.DataFrame, interface: agent0.ethpy.hyperdrive.HyperdriveReadInterface, coerce_float: bool) -> pandas.Series Calculate closeout value of agent positions. :param current_positions: A dataframe resulting from `get_current_wallet` that describes the current wallet position. :type current_positions: pd.DataFrame :param checkpoint_info: A dataframe resulting from `get_checkpoint_info` that describes all checkpoints. :type checkpoint_info: pd.DataFrame :param interface: The hyperdrive read interface. :type interface: HyperdriveReadInterface :param coerce_float: If True, will coerce underlying Decimals to floats. :type coerce_float: bool :returns: A series matching the current_wallet input that contains the values of each position. :rtype: pd.Series .. !! processed by numpydoc !! .. py:function:: fill_pnl_values(in_df: pandas.DataFrame, db_session: sqlalchemy.orm.Session, interface: agent0.ethpy.hyperdrive.HyperdriveReadInterface, coerce_float: bool) -> pandas.DataFrame Fills in the unrealized and realized pnl for each position. :param in_df: A dataframe of positions from `get_current_positions`. :type in_df: pd.DataFrame :param db_session: The database session. :type db_session: Session :param interface: The hyperdrive read interface attached to a hyperdrive pool. :type interface: HyperdriveReadInterface :param coerce_float: If True, will coerce all numeric columns to float. :type coerce_float: bool :returns: The `in_df` with unrealized value and pnl columns added. :rtype: pd.DataFrame .. !! processed by numpydoc !!