Compare commits

...

2 Commits

Author SHA1 Message Date
Nelson Torres 5c320bc7ab Max pain docs. 2025-01-30 02:53:18 +00:00
Nelson Torres 5423e38a75 Add get expiration dates in deribit api 2025-01-29 23:52:18 -03:00
4 changed files with 58 additions and 2 deletions

View File

View File

@ -23,8 +23,22 @@ def check_if_complete(
async def max_pain_daemon(
) -> None:
expiry_date: str = input('Please enter a valid expiration date (7feb25): ').upper()
print('Initializing...')
oi_by_strikes: dict[str, dict[str, Decimal | None]]
expiry_dates: list[str]
currency: str = 'btc'
kind: str = 'option'
async with get_client(
) as client:
expiry_dates: list[str] = await client.get_expiration_dates(
currency=currency,
kind=kind
)
print(f'Available expiration dates for {currency}-{kind}:')
print(f'{expiry_dates}')
expiry_date: str = input('Please enter a valid expiration date: ').upper()
print('Starting little daemon...')
instruments: list[Symbol] = []
oi_by_strikes: dict[str, dict[str, Decimal]]

View File

@ -0,0 +1,19 @@
## Max Pain Calculation for Deribit Options
This feature, which calculates the max pain point for options traded on the Deribit exchange using cryptofeed library.
- Functions in the api module for fetching options data from Deribit. [commit](https://pikers.dev/pikers/piker/commit/da55856dd2876291f55a06eb0561438a912d8241)
- Compute the max pain point based on open interest data using deribit's api. [commit](https://pikers.dev/pikers/piker/commit/0d9d6e15ba0edeb662ec97f7599dd66af3046b94)
### How to test it?
**Before start:** in order to get this working with `uv`, you **must** use my `tractor` [fork](https://pikers.dev/ntorres/tractor/src/branch/aio_abandons) and this branch: `aio_abandons`, the reason is that I cherry-pick the `uv_migration` that guille made, for some reason that a didn't dive into, in my system y need tractor using `uv` too. quite hacky I guess.
1. `uv lock`
2. `uv run --no-dev python examples/max_pain.py`
3. A message should be display, enter one of the expiration date available.
4. The script should be up and running.

View File

@ -425,6 +425,29 @@ class Client:
return response_list
async def get_expiration_dates(
self,
currency: str = 'btc',
kind: str = 'option',
) -> list[str]:
"""
Get a dict with all expiration dates listed as value and currency as key.
"""
params: dict[str, str] = {
'currency': currency.upper(),
'kind': kind,
}
r: JSONRPCResult = await self._json_rpc_auth_wrapper(
'public/get_expirations',
params,
)
resp = r.result
return resp[currency][kind]
def get_strikes_dict(
self,
instruments: list[Symbol],