From e9b95cdd6e47ef654681b0a74d95c418e7376749 Mon Sep 17 00:00:00 2001 From: GravitySucks Date: Wed, 12 Jul 2023 09:44:13 +0200 Subject: [PATCH] new ver --- docs/source/conf.py | 2 +- gvol/__init__.py | 2 +- gvol/client.py | 73 +++++++++++++++++++++++++++++++++++++++++++++ gvol/queries.py | 12 ++++++++ pyproject.toml | 2 +- 5 files changed, 88 insertions(+), 3 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 3a640c2..54c62d5 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -23,7 +23,7 @@ author = "Denys Halenok" # The full version, including alpha/beta/rc tags -release = "0.5.7" +release = "0.5.8" # -- General configuration --------------------------------------------------- diff --git a/gvol/__init__.py b/gvol/__init__.py index ab5f610..2735026 100644 --- a/gvol/__init__.py +++ b/gvol/__init__.py @@ -1,4 +1,4 @@ __all__ = ("__version__", "GVol") -__version__ = "0.5.7" +__version__ = "0.5.8" from gvol.client import GVol diff --git a/gvol/client.py b/gvol/client.py index 5694a04..1fb251d 100644 --- a/gvol/client.py +++ b/gvol/client.py @@ -1519,7 +1519,46 @@ def options_cumulative_net_volumes( variable_values={"symbol":symbol, "exchange":exchange, "days":days, "showActiveExpirations":showActiveExpirations, "tradeType":tradeType} ) + def options_cumulative_net_volumes_hist( + self, symbol: types.BTCOrETHEnumType, exchange: types.ExchangeDeribit, dateStart: types.String, dateEnd: types.String, showActiveExpirations: types.Boolean, tradeType: types.TradeTypeEnum + ) -> Dict: + """ + This endpoint returns the cumulative net volumes of trades for the date range selected (dateStart/dateEnd). + + For calculating the "net" volume (aka the volume traded with the sign of the initiator) we use our proprietary algorithm composed from several heuristics which use the orderbook previous of the trade at millisecond granularity. You can read more about this here Gvol Direction. + + The endpoint is completed with some useful filters, such as: + - tradeType = ALL/block/onScreen + - showActiveExpirations: + - true = endpoint returns only trades for active expirations + - false = endpoint returns all the trades even for expired expirations. + Args: + { + "symbol": "BTC", + "dateStart": "2023-06-01", + "dateEnd": "2023-06-04", + "exchange": "deribit", + "trade": "all", + "showActiveExpirations": true + } + + Returns: + { + "date": "1685923200000", + "strike": 48000, + "cumulative": 1.9, + "cumulativeGamma": 0, + "cumulativeVega": 7.92, + "cumulativeDelta": 0.03, + "indexPrice": 27125.03 + } + """ + return self._client.execute( + gql(queries.options_cumulative_net_volumes_hist), + variable_values={"symbol":symbol, "exchange":exchange, "dateStart":dateStart, "dateEnd":dateEnd, "showActiveExpirations":showActiveExpirations, "tradeType":tradeType} + ) + def options_cumulative_net_positioning( self, symbol: types.BTCOrETHEnumType, exchange: types.ExchangeDeribit, dateStart: types.String ) -> Dict: @@ -1547,3 +1586,37 @@ def options_cumulative_net_positioning( gql(queries.options_cumulative_net_positioning), variable_values={"symbol":symbol, "exchange":exchange, "dateStart":dateStart} ) + + def options_cumulative_net_positioning_hist( + self, symbol: types.BTCOrETHEnumType, exchange: types.ExchangeDeribit, dateStart: types.String, dateEnd: types.String + ) -> Dict: + """ + This endpoint returns the cumulative net oi for the date range selected (dateStart/dateEnd) + + The cumulative net oi is the incremental change in the open interest according to the trades flow using our proprietary "taker detection". + + When a strike is positive means that has been bought from traders, when is negative has been sold. + + To the other side of positioning, there are the dealers with their inventory. + + For not losing information cutting some open interest forming process it's strongly adviced to start from 1st November 2022. + + Args: + { + "symbol": "BTC", + "exchange": "deribit", + "dateStart": "2023-03-01" + "dateEnd": "2023-04-01" + } + + Returns: + { + "date": "1677628800000", + "strike": 5000, + "netInv": 0, + "indexPrice": 23134 + } + """ + return self._client.execute( + gql(queries.options_cumulative_net_positioning_hist), + variable_values={"symbol":symbol, "exchange":exchange, "dateStart":dateStart, "dateEnd":dateEnd} diff --git a/gvol/queries.py b/gvol/queries.py index 6647d17..7840468 100644 --- a/gvol/queries.py +++ b/gvol/queries.py @@ -1387,6 +1387,12 @@ {date strike cumulative indexPrice}} """ +options_cumulative_net_volumes_hist = """ +query HistoricalNetVolumeApi($symbol: SymbolEnumType, $dateStart: String, $dateEnd: String $exchange: ExchangeEnumType, $trade: TradeEnumType, $showActiveExpirations: Boolean) +{HistoricalNetVolumeApi(symbol: $symbol, dateStart: $dateStart, dateEnd: $dateEnd exchange: $exchange, trade: $trade, showActiveExpirations: $showActiveExpirations) +{date strike cumulative cumulativeGamma cumulativeVega cumulativeDelta indexPrice} } +""" + options_cumulative_net_positioning = """ query NetPositioning( $symbol: SymbolEnumType, $exchange: ExchangeEnumType, $dateStart: String) {genericNetPositioningGvolDirection(symbol: $symbol, exchange: $exchange, dateStart: $dateStart) @@ -1394,4 +1400,10 @@ strike netInv indexPrice}} +""" + +options_cumulative_net_positioning_hist = """ +query HistoricalNetPositioningApi($symbol: SymbolEnumType, $dateStart: String, $dateEnd: String $exchange: ExchangeEnumType) +{HistoricalNetPositioningApi(symbol: $symbol, dateStart: $dateStart, dateEnd: $dateEnd exchange: $exchange) +{date strike netInv indexPrice } } """ \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index b05b9a9..93b1c41 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "gvol" -version = "0.5.7" +version = "0.5.8" description = "GVol is a Python library to access the GVol API" authors = ["Denys Halenok "]