agent0.chainsync.dashboard ========================== .. py:module:: agent0.chainsync.dashboard .. autoapi-nested-parse:: Dashboard utilities .. !! processed by numpydoc !! Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/agent0/chainsync/dashboard/build_dashboard_dfs/index /autoapi/agent0/chainsync/dashboard/build_fixed_rate/index /autoapi/agent0/chainsync/dashboard/build_leaderboard/index /autoapi/agent0/chainsync/dashboard/build_ohlcv/index /autoapi/agent0/chainsync/dashboard/build_outstanding_positions/index /autoapi/agent0/chainsync/dashboard/build_ticker/index /autoapi/agent0/chainsync/dashboard/build_variable_rate/index /autoapi/agent0/chainsync/dashboard/build_vault_share_price/index /autoapi/agent0/chainsync/dashboard/build_wallet_positions/index /autoapi/agent0/chainsync/dashboard/plot_ohlcv/index /autoapi/agent0/chainsync/dashboard/plot_outstanding_positions/index /autoapi/agent0/chainsync/dashboard/plot_rates/index /autoapi/agent0/chainsync/dashboard/plot_share_price/index /autoapi/agent0/chainsync/dashboard/plot_utils/index /autoapi/agent0/chainsync/dashboard/usernames/index Functions --------- .. autoapisummary:: agent0.chainsync.dashboard.build_pool_dashboard agent0.chainsync.dashboard.build_wallet_dashboard agent0.chainsync.dashboard.plot_ohlcv agent0.chainsync.dashboard.plot_outstanding_positions agent0.chainsync.dashboard.plot_rates agent0.chainsync.dashboard.plot_share_price agent0.chainsync.dashboard.reduce_plot_data agent0.chainsync.dashboard.abbreviate_address agent0.chainsync.dashboard.build_user_mapping agent0.chainsync.dashboard.map_addresses Package Contents ---------------- .. py:function:: build_pool_dashboard(hyperdrive_address: str, session: sqlalchemy.orm.Session, max_live_blocks: int = 20000, max_ticker_rows: int = 10000) -> dict[str, pandas.DataFrame] Builds the dataframes for the main dashboard page that focuses on pools. :param hyperdrive_address: The hyperdrive address to filter the results on. :type hyperdrive_address: str :param session: The initialized sqlalchemy db session object. :type session: Session :param max_live_blocks: The maximum look-back length in blocks. Defaults to 5000. :type max_live_blocks: int, optional :param max_ticker_rows: The maximum number of ticker rows to show. Defaults to 1000. :type max_ticker_rows: int, optional :returns: A collection of dataframes ready to be shown in the dashboard. :rtype: dict[str, DataFrame] .. !! processed by numpydoc !! .. py:function:: build_wallet_dashboard(wallet_addresses: list[str], session: sqlalchemy.orm.Session, user_map: pandas.DataFrame | None = None, max_plot_blocks: int = 5000, max_ticker_rows: int = 1000) -> dict[str, pandas.DataFrame] Builds the dataframes for the main dashboard page that focuses on pools. :param wallet_addresses: The list of wallet addresses to filter the results on. :type wallet_addresses: list[str] :param session: The initialized sqlalchemy db session object. :type session: Session :param user_map: The mapping of wallet addresses to usernames. Will build from db if None. :type user_map: pd.DataFrame | None, optional :param max_plot_blocks: The maximum number of blocks to look in the past for plotting. Defaults to 5000. :type max_plot_blocks: int, optional :param max_ticker_rows: The maximum number of ticker rows to show. Defaults to 1000. :type max_ticker_rows: int, optional :returns: A collection of dataframes ready to be shown in the dashboard. :rtype: dict[str, DataFrame] .. !! processed by numpydoc !! .. py:function:: plot_ohlcv(ohlcv: pandas.DataFrame, ohlcv_ax: matplotlib.axes.Axes) -> None Plots the ohlcv plot. :param ohlcv: The ohlcv dataframe to plot. :type ohlcv: pd.DataFrame :param ohlcv_ax: The matplotlib axes to plot on. :type ohlcv_ax: Axes .. !! processed by numpydoc !! .. py:function:: plot_outstanding_positions(data: pandas.DataFrame, axes: matplotlib.axes.Axes) Returns the fixed rate plot. :param data: The data to plot. :type data: pd.DataFrame :param axes: The matplotlib axes to plot on. :type axes: Axes .. !! processed by numpydoc !! .. py:function:: plot_rates(fixed_rate: pandas.DataFrame, variable_rate: pandas.DataFrame, axes: matplotlib.axes.Axes) -> None Plots the fixed and variable rates. :param fixed_rate: The fixed rate dataframe. :type fixed_rate: pd.DataFrame :param variable_rate: The variable rate dataframe. :type variable_rate: pd.DataFrame :param axes: The matplotlib axes to plot on. :type axes: Axes .. !! processed by numpydoc !! .. py:function:: plot_share_price(vault_share_price: pandas.DataFrame, axes: matplotlib.axes.Axes) -> None Plots the vault share price. :param vault_share_price: The vault_share_price dataframe. :type vault_share_price: pd.DataFrame :param axes: The matplotlib axes to plot on. :type axes: Axes .. !! processed by numpydoc !! .. py:function:: reduce_plot_data(data: pandas.DataFrame, x_column_name: str, y_column_name: str) -> pandas.DataFrame Reduces the data we plot by looking for redundant rows with no change, and only return x and y columns :param data: The data to plot. :type data: pd.DataFrame :param x_column_name: The name of the x column :type x_column_name: str :param y_column_name: The name of the y column :type y_column_name: str :returns: The reduced data :rtype: pd.DataFrame .. !! processed by numpydoc !! .. py:function:: abbreviate_address(address: pandas.Series) -> pandas.Series abbreviate_address(address: str) -> str Given a series of addresses, return the corresponding addresses in a human readable way. :param address: :type address: pd.Series | str :returns: The corresponding abbreviated addresses in the same order (with the same indices), or a single abbreviated address string. :rtype: pd.Series | str .. !! processed by numpydoc !! .. py:function:: build_user_mapping(addresses: pandas.Series, addr_to_username: pandas.DataFrame) -> pandas.DataFrame Builds a mapping from wallet addresses to usernames and any additional aliases that address may have. Given a pd.Series of wallet addresses, we build a corresponding dataframe that contains the mapping between that wallet address and any additional aliases that address may have. Specifically, the output dataframe contains the following columns: address: The original wallet address abbr_address: The wallet address abbreviated (e.g., 0x0000...0000) username: The one-to-one mapped username for that address gathered from the `addr_to_username` postgres table format_name: A formatted name for labels combining username with abbr_address If the address doesn't exist in the lookup, the username and user will reflect the abbr_address. :param addresses: The list of addresses to build the user map for. :type addresses: pd.Series :param addr_to_username: The mapping of addresses to username returned from `get_addr_to_username`. :type addr_to_username: pd.DataFrame :returns: A dataframe with 4 columns (address, abbr_address, username, format_name) :rtype: pd.Dataframe .. !! processed by numpydoc !! .. py:function:: map_addresses(key: str, user_map: pandas.DataFrame, map_column=None) -> pandas.Series map_addresses(key: pandas.Series | list, user_map: pandas.DataFrame, map_column=None) -> pandas.Series Helper function to look up the aliases for an address. :param key: The pd.Series, list, or individual key(s) to look up. :type key: pd.Series | list | str :param user_map: The lookup dataframe returned from build_user_mapping :type user_map: pd.DataFrame :param map_column: The column that key is mapped to. If None, will default to address. :type map_column: str | None :returns: A dataframe or series with 5 columns (address, abbr_address, username, user, format_name) in the same order as the input addresses series. Will return a dataframe if a series or list is passed in Will return a series if a single key is passed in :rtype: pd.Dataframe | pd.Series .. !! processed by numpydoc !!