cryptodatapy.util.utils ======================= .. py:module:: cryptodatapy.util.utils Functions --------- .. autoapisummary:: cryptodatapy.util.utils.compute_reference_price cryptodatapy.util.utils.stitch_dataframes cryptodatapy.util.utils.rebase_fx_to_foreign_vs_usd Module Contents --------------- .. py:function:: compute_reference_price(dfs: List[pandas.DataFrame], method: str = 'median', trim_pct: float = 0.25) -> pandas.DataFrame Computes the reference price from a list of dataframes. :param dfs: List of dataframes containing price data. :type dfs: pd.DataFrame :param method: Method to compute the reference price. Options are 'median' or 'trimmed_mean'. Default is 'median'. :type method: str, optional :param trim_pct: Percentage of data to trim from both ends for 'trimmed_mean' method. Default is 0.25 (25%). :type trim_pct: float, optional :returns: Dataframe with the reference price. :rtype: pd.DataFrame .. py:function:: stitch_dataframes(df1: pandas.DataFrame, df2: pandas.DataFrame) -> pandas.DataFrame Stitches together dataframes with different start dates. :param df1: First dataframe to be stitched. :type df1: pd.DataFrame :param df2: Second dataframe to be stitched. :type df2: pd.DataFrame :returns: **combined_df** -- Combined or stitched dataframes with extended data. :rtype: pd.DataFrame .. py:function:: rebase_fx_to_foreign_vs_usd(df) -> pandas.DataFrame Rebase FX rates to foreign currency vs. USD format, so that an increase means the foreign currency is appreciating. Works for both MultiIndex (date, ticker) and single-index (date index, tickers as columns). :param df: FX DataFrame with either: - MultiIndex (date, ticker) - Datetime index and tickers as columns :type df: pd.DataFrame :returns: Rebased FX rates with tickers as foreign currency (e.g., 'EUR', 'JPY'). :rtype: pd.DataFrame