cryptodatapy.util.utils

Functions

compute_reference_price(→ pandas.DataFrame)

Computes the reference price from a list of dataframes.

stitch_dataframes(→ pandas.DataFrame)

Stitches together dataframes with different start dates.

rebase_fx_to_foreign_vs_usd(→ pandas.DataFrame)

Rebase FX rates to foreign currency vs. USD format, so that an increase

Module Contents

cryptodatapy.util.utils.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.

Parameters:
  • dfs (pd.DataFrame) – List of dataframes containing price data.

  • method (str, optional) – Method to compute the reference price. Options are ‘median’ or ‘trimmed_mean’. Default is ‘median’.

  • trim_pct (float, optional) – Percentage of data to trim from both ends for ‘trimmed_mean’ method. Default is 0.25 (25%).

Returns:

Dataframe with the reference price.

Return type:

pd.DataFrame

cryptodatapy.util.utils.stitch_dataframes(df1: pandas.DataFrame, df2: pandas.DataFrame) pandas.DataFrame

Stitches together dataframes with different start dates.

Parameters:
  • df1 (pd.DataFrame) – First dataframe to be stitched.

  • df2 (pd.DataFrame) – Second dataframe to be stitched.

Returns:

combined_df – Combined or stitched dataframes with extended data.

Return type:

pd.DataFrame

cryptodatapy.util.utils.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).

Parameters:

df (pd.DataFrame) – FX DataFrame with either: - MultiIndex (date, ticker) - Datetime index and tickers as columns

Returns:

Rebased FX rates with tickers as foreign currency (e.g., ‘EUR’, ‘JPY’).

Return type:

pd.DataFrame