Skip to content

Commit

Permalink
Trivial Addition to cm_utils
Browse files Browse the repository at this point in the history
  • Loading branch information
umocm committed Dec 3, 2024
1 parent 2d1f497 commit 7dd0a43
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions precog/utils/cm_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,23 +106,27 @@ def get_open_interest_catalog(self, base: str = "btc", quote: str = "usd", marke
base (str, optional): Base Asset of Market. Defaults to "btc".
quote (str, optional): Quote Asset of Market. Defaults to "usd".
market_type (str, optional): Market type ('spot', 'option', 'future'). Defaults to "spot".
Returns:
catalog (pd.DataFrame): Dataframe containing active markets with columns
['market', 'min_time', 'max_time']
"""
catalog = self.client.catalog_market_open_interest_v2(
base=base, quote=quote, market_type=market_type, page_size=10000, paging_from="end"
).to_dataframe()

return catalog

def get_market_open_interest(
self, markets: list, page_size: int = 10000, parallelize=False, **kwargs
) -> pd.DataFrame:
"""Fetches available market open interest from CoinMetrics Python client.
"""Fetches available market open interest from CoinMetrics Python client.
Possible markets can be obtained from the get_open_interest_catalog() method
Args:
markets (list): List of derivatives markets to get the Open Interest for.
Note there is a character limit to the query, so may need to be done in chunks for a long list
Returns:
DataFrame: Open Interest of unsettled derivatives contracts. Columns are:
[market, time, contract_count, value_usd, database_time, exchange_time]
Expand Down

0 comments on commit 7dd0a43

Please sign in to comment.