chore(Linter): reformatted code with black (#211)

* chore(Linter): reformatted code with black

* Create black.yaml
This commit is contained in:
Mark Aron Szulyovszky
2022-02-17 19:22:17 +01:00
committed by GitHub
parent f3fee4a4e1
commit 8dd2d88740
101 changed files with 2595 additions and 2319 deletions
+65 -64
View File
@@ -4,45 +4,46 @@ from .client import GlassnodeClient
class Derivatives:
"""
Derivatives class.
Derivatives class.
Methods
-------
__init__(glassnode_client):
Constructs a Derivatives object.
futures_perpetual_funding_rate([exchange]):
Returns the average funding rate (in %) set by exchanges for perpetual futures contracts.
futures_perpetual_funding_rate_all():
Returns the average funding rate (in %) set by exchanges for perpetual futures contracts.
futures_volume([exchange]):
Returns the total volume traded in futures contracts in the last 24 hours.
futures_volume_latest_24h():
Returns the total volume traded in futures contracts per exchange over the last 24 hours.
futures_volume_stacked():
Returns the total volume traded in futures contracts in the last 24 hours.
futures_volume_perpetual([exchange]):
Returns The total volume traded in perpetual futures contracts in the last 24 hours.
futures_volume_perpetual_stacked():
Returns the total volume traded in perpetual futures contracts in the last 24 hours.
futures_open_interest([exchange]):
Returns the total amount of funds allocated in open futures contracts.
futures_open_interest_current():
Returns the current amount of allocated funds in futures contracts per exchange.
futures_open_interest_perpetual([exchange]):
Returns the total amount of funds allocated in open perpetual futures contracts.
futures_open_interest_perpetual_stacked():
Returns the total amount of funds allocated in open perpetual futures contracts.
futures_open_interest_stacked():
Returns the total amount of funds allocated in open futures contracts.
futures_long_liquidations([exchange]):
Returns the sum liquidated volume from long positions in futures contracts.
futures_long_liquidations_mean([exchange]):
Returns the mean liquidated volume from long positions in futures contracts.
futures_short_liquidations([exchange]):
Returns the sum liquidated volume from short positions in futures contracts.
futures_short_liquidations_mean([exchange]):
Returns the mean liquidated volume from short positions in futures contracts.
Methods
-------
__init__(glassnode_client):
Constructs a Derivatives object.
futures_perpetual_funding_rate([exchange]):
Returns the average funding rate (in %) set by exchanges for perpetual futures contracts.
futures_perpetual_funding_rate_all():
Returns the average funding rate (in %) set by exchanges for perpetual futures contracts.
futures_volume([exchange]):
Returns the total volume traded in futures contracts in the last 24 hours.
futures_volume_latest_24h():
Returns the total volume traded in futures contracts per exchange over the last 24 hours.
futures_volume_stacked():
Returns the total volume traded in futures contracts in the last 24 hours.
futures_volume_perpetual([exchange]):
Returns The total volume traded in perpetual futures contracts in the last 24 hours.
futures_volume_perpetual_stacked():
Returns the total volume traded in perpetual futures contracts in the last 24 hours.
futures_open_interest([exchange]):
Returns the total amount of funds allocated in open futures contracts.
futures_open_interest_current():
Returns the current amount of allocated funds in futures contracts per exchange.
futures_open_interest_perpetual([exchange]):
Returns the total amount of funds allocated in open perpetual futures contracts.
futures_open_interest_perpetual_stacked():
Returns the total amount of funds allocated in open perpetual futures contracts.
futures_open_interest_stacked():
Returns the total amount of funds allocated in open futures contracts.
futures_long_liquidations([exchange]):
Returns the sum liquidated volume from long positions in futures contracts.
futures_long_liquidations_mean([exchange]):
Returns the mean liquidated volume from long positions in futures contracts.
futures_short_liquidations([exchange]):
Returns the sum liquidated volume from short positions in futures contracts.
futures_short_liquidations_mean([exchange]):
Returns the mean liquidated volume from short positions in futures contracts.
"""
def __init__(self, glassnode_client: GlassnodeClient):
self._gc = glassnode_client
@@ -51,11 +52,11 @@ class Derivatives:
The average funding rate (in %) set by exchanges for perpetual futures contracts.
`View in Studio <https://studio.glassnode.com/metrics?a=BTC&m=derivatives.FuturesFundingRatePerpetual>`_
"""
endpoint = '/v1/metrics/derivatives/futures_funding_rate_perpetual'
endpoint = "/v1/metrics/derivatives/futures_funding_rate_perpetual"
if not is_supported_by_endpoint(self._gc, endpoint):
return pd.DataFrame()
return response_to_dataframe(self._gc.get(endpoint, {'e': exchange}))
return response_to_dataframe(self._gc.get(endpoint, {"e": exchange}))
@dataframe_with_inner_object
def futures_perpetual_funding_rate_all(self) -> pd.DataFrame:
@@ -63,7 +64,7 @@ class Derivatives:
The average funding rate (in %) set by exchanges for perpetual futures contracts.
`View in Studio <https://studio.glassnode.com/metrics?a=BTC&m=derivatives.FuturesFundingRatePerpetualAll>`_
"""
endpoint = '/v1/metrics/derivatives/futures_funding_rate_perpetual_all'
endpoint = "/v1/metrics/derivatives/futures_funding_rate_perpetual_all"
if not is_supported_by_endpoint(self._gc, endpoint):
return pd.DataFrame()
@@ -74,11 +75,11 @@ class Derivatives:
The total volume traded in futures contracts in the last 24 hours.
`View in Studio <https://studio.glassnode.com/metrics?a=BTC&m=derivatives.FuturesVolumeDailySum>`_
"""
url = '/v1/metrics/derivatives/futures_volume_daily_sum'
url = "/v1/metrics/derivatives/futures_volume_daily_sum"
if not is_supported_by_endpoint(self._gc, url):
return pd.DataFrame()
return response_to_dataframe(self._gc.get(url, {'e': exchange}))
return response_to_dataframe(self._gc.get(url, {"e": exchange}))
# TODO: Unpack inner object from response
def futures_volume_latest_24h(self) -> pd.DataFrame:
@@ -87,7 +88,7 @@ class Derivatives:
Values are updated every 10 min.
`View in Studio <https://studio.glassnode.com/metrics?a=BTC&m=derivatives.FuturesVolumeDailyLatest>`_
"""
endpoint = '/v1/metrics/derivatives/futures_volume_daily_latest'
endpoint = "/v1/metrics/derivatives/futures_volume_daily_latest"
if not is_supported_by_endpoint(self._gc, endpoint):
return pd.DataFrame()
@@ -99,7 +100,7 @@ class Derivatives:
The total volume traded in futures contracts in the last 24 hours.
`View in Studio <https://studio.glassnode.com/metrics?a=BTC&m=derivatives.FuturesVolumeDailySumAll>`_
"""
endpoint = '/v1/metrics/derivatives/futures_volume_daily_sum_all'
endpoint = "/v1/metrics/derivatives/futures_volume_daily_sum_all"
if not is_supported_by_endpoint(self._gc, endpoint):
return pd.DataFrame()
@@ -110,11 +111,11 @@ class Derivatives:
The total volume traded in perpetual (non-expiring) futures contracts in the last 24 hours.
`View in Studio <https://studio.glassnode.com/metrics?a=BTC&m=derivatives.FuturesVolumeDailyPerpetualSum>`_
"""
endpoint = '/v1/metrics/derivatives/futures_volume_daily_perpetual_sum'
endpoint = "/v1/metrics/derivatives/futures_volume_daily_perpetual_sum"
if not is_supported_by_endpoint(self._gc, endpoint):
return pd.DataFrame()
return response_to_dataframe(self._gc.get(endpoint, {'e': exchange}))
return response_to_dataframe(self._gc.get(endpoint, {"e": exchange}))
@dataframe_with_inner_object
def futures_volume_perpetual_stacked(self) -> pd.DataFrame:
@@ -122,7 +123,7 @@ class Derivatives:
The total volume traded in perpetual (non-expiring) futures contracts in the last 24 hours.
`View in Studio <https://studio.glassnode.com/metrics?a=BTC&m=derivatives.FuturesVolumeDailyPerpetualSumAll>`_
"""
endpoint = '/v1/metrics/derivatives/futures_volume_daily_perpetual_sum_all'
endpoint = "/v1/metrics/derivatives/futures_volume_daily_perpetual_sum_all"
if not is_supported_by_endpoint(self._gc, endpoint):
return pd.DataFrame()
@@ -133,11 +134,11 @@ class Derivatives:
The total amount of funds allocated in open futures contracts.
`View in Studio <https://studio.glassnode.com/metrics?a=BTC&m=derivatives.FuturesOpenInterestSum>`_
"""
endpoint = '/v1/metrics/derivatives/futures_open_interest_sum'
endpoint = "/v1/metrics/derivatives/futures_open_interest_sum"
if not is_supported_by_endpoint(self._gc, endpoint):
return pd.DataFrame()
return response_to_dataframe(self._gc.get(endpoint, {'e': exchange}))
return response_to_dataframe(self._gc.get(endpoint, {"e": exchange}))
# TODO: Unpack inner object from response
def futures_open_interest_current(self) -> pd.DataFrame:
@@ -145,7 +146,7 @@ class Derivatives:
The current amount of allocated funds in futures contracts per exchange.Values are updated every 10 min.
`View in Studio <https://studio.glassnode.com/metrics?a=BTC&m=derivatives.FuturesOpenInterestLatest>`_
"""
endpoint = '/v1/metrics/derivatives/futures_open_interest_latest'
endpoint = "/v1/metrics/derivatives/futures_open_interest_latest"
if not is_supported_by_endpoint(self._gc, endpoint):
return pd.DataFrame()
@@ -156,11 +157,11 @@ class Derivatives:
The total amount of funds allocated in open perpetual (non-expiring) futures contracts.
`View in Studio <https://studio.glassnode.com/metrics?a=BTC&m=derivatives.FuturesOpenInterestPerpetualSum>`_
"""
endpoint = '/v1/metrics/derivatives/futures_open_interest_perpetual_sum'
endpoint = "/v1/metrics/derivatives/futures_open_interest_perpetual_sum"
if not is_supported_by_endpoint(self._gc, endpoint):
return pd.DataFrame()
return response_to_dataframe(self._gc.get(endpoint, {'e': exchange}))
return response_to_dataframe(self._gc.get(endpoint, {"e": exchange}))
@dataframe_with_inner_object
def futures_open_interest_perpetual_stacked(self) -> pd.DataFrame:
@@ -168,7 +169,7 @@ class Derivatives:
The total amount of funds allocated in open perpetual (non-expiring) futures contracts.
`View in Studio <https://studio.glassnode.com/metrics?a=BTC&m=derivatives.FuturesOpenInterestPerpetualSumAll>`_
"""
endpoint = '/v1/metrics/derivatives/futures_open_interest_perpetual_sum_all'
endpoint = "/v1/metrics/derivatives/futures_open_interest_perpetual_sum_all"
if not is_supported_by_endpoint(self._gc, endpoint):
return pd.DataFrame()
@@ -180,7 +181,7 @@ class Derivatives:
The total amount of funds allocated in open futures contracts.
`View in Studio <https://studio.glassnode.com/metrics?a=BTC&m=derivatives.FuturesOpenInterestSumAll>`_
"""
endpoint = '/v1/metrics/derivatives/futures_open_interest_sum_all'
endpoint = "/v1/metrics/derivatives/futures_open_interest_sum_all"
if not is_supported_by_endpoint(self._gc, endpoint):
return pd.DataFrame()
@@ -191,49 +192,49 @@ class Derivatives:
The sum liquidated volume from long positions in futures contracts.
`View in Studio <https://studio.glassnode.com/metrics?a=BTC&m=derivatives.FuturesLiquidatedVolumeLongSum>`_
"""
endpoint = '/v1/metrics/derivatives/futures_liquidated_volume_long_sum'
endpoint = "/v1/metrics/derivatives/futures_liquidated_volume_long_sum"
if not is_supported_by_endpoint(self._gc, endpoint):
return pd.DataFrame()
return response_to_dataframe(self._gc.get(endpoint, {'e': exchange}))
return response_to_dataframe(self._gc.get(endpoint, {"e": exchange}))
def futures_long_liquidations_mean(self, exchange: str = None) -> pd.DataFrame:
"""
The mean liquidated volume from long positions in futures contracts.
`View in Studio <https://studio.glassnode.com/metrics?a=BTC&m=derivatives.FuturesLiquidatedVolumeLongMean>`_
"""
endpoint = '/v1/metrics/derivatives/futures_liquidated_volume_long_mean'
endpoint = "/v1/metrics/derivatives/futures_liquidated_volume_long_mean"
if not is_supported_by_endpoint(self._gc, endpoint):
return pd.DataFrame()
return response_to_dataframe(self._gc.get(endpoint, {'e': exchange}))
return response_to_dataframe(self._gc.get(endpoint, {"e": exchange}))
def futures_short_liquidations(self, exchange: str = None) -> pd.DataFrame:
"""
The sum liquidated volume from short positions in futures contracts.
`View in Studio <https://studio.glassnode.com/metrics?a=BTC&m=derivatives.FuturesLiquidatedVolumeShortSum>`_
"""
endpoint = '/v1/metrics/derivatives/futures_liquidated_volume_short_sum'
endpoint = "/v1/metrics/derivatives/futures_liquidated_volume_short_sum"
if not is_supported_by_endpoint(self._gc, endpoint):
return pd.DataFrame()
return response_to_dataframe(self._gc.get(endpoint, {'e': exchange}))
return response_to_dataframe(self._gc.get(endpoint, {"e": exchange}))
def futures_short_liquidations_mean(self, exchange: str = None) -> pd.DataFrame:
"""
The mean liquidated volume from short positions in futures contracts.
`View in Studio <https://studio.glassnode.com/metrics?a=BTC&m=derivatives.FuturesLiquidatedVolumeShortMean>`_
"""
endpoint = '/v1/metrics/derivatives/futures_liquidated_volume_short_mean'
endpoint = "/v1/metrics/derivatives/futures_liquidated_volume_short_mean"
if not is_supported_by_endpoint(self._gc, endpoint):
return pd.DataFrame()
return response_to_dataframe(self._gc.get(endpoint, {'e': exchange}))
return response_to_dataframe(self._gc.get(endpoint, {"e": exchange}))
def futures_estimated_leverage_ratio(self, exchange: str = None) -> pd.DataFrame:
endpoint = '/v1/metrics/derivatives/futures_estimated_leverage_ratio'
endpoint = "/v1/metrics/derivatives/futures_estimated_leverage_ratio"
if not is_supported_by_endpoint(self._gc, endpoint):
return pd.DataFrame()
return response_to_dataframe(self._gc.get(endpoint, {'e': exchange}))
return response_to_dataframe(self._gc.get(endpoint, {"e": exchange}))