Skip to content

Commit

Permalink
new ver
Browse files Browse the repository at this point in the history
  • Loading branch information
GravitySucks authored and GravitySucks committed Jul 12, 2023
1 parent 1cd3f6d commit e9b95cd
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ---------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion gvol/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__all__ = ("__version__", "GVol")
__version__ = "0.5.7"
__version__ = "0.5.8"

from gvol.client import GVol
73 changes: 73 additions & 0 deletions gvol/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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}
12 changes: 12 additions & 0 deletions gvol/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -1387,11 +1387,23 @@
{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)
{ date
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 } }
"""
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]

Expand Down

0 comments on commit e9b95cd

Please sign in to comment.