From 423b514cec5b2d996437bd94c4d82687fb256015 Mon Sep 17 00:00:00 2001 From: Nelson Torres Date: Sat, 7 Dec 2024 10:16:37 -0300 Subject: [PATCH] fix the input values for acm related to oi --- max_pain.py | 16 ++++++++++++++-- piker/brokers/deribit/api.py | 9 ++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/max_pain.py b/max_pain.py index 64fba933..5446aa25 100644 --- a/max_pain.py +++ b/max_pain.py @@ -8,8 +8,20 @@ from piker.brokers.deribit.api import ( async def max_pain_daemon( ) -> None: - async with maybe_open_oi_feed() as oi_feed: - print('Im in...') + def check_if_complete( + oi: dict[str, dict[str, Decimal | None]], + + ) -> bool: + for strike in oi: + if ( + oi[strike]['C'] == None + or + oi[strike]['P'] == None + ): + return False + + return True + async def main(): diff --git a/piker/brokers/deribit/api.py b/piker/brokers/deribit/api.py index c642b0df..1640ba21 100644 --- a/piker/brokers/deribit/api.py +++ b/piker/brokers/deribit/api.py @@ -826,8 +826,8 @@ async def maybe_open_price_feed( async def aio_open_interest_feed_relay( fh: FeedHandler, - instruments: list, oi_by_strikes: dict[str, dict[str, Decimal]], + instruments: list[Symbol], from_trio: asyncio.Queue, to_trio: trio.abc.SendChannel, ) -> None: @@ -929,6 +929,7 @@ async def aio_open_interest_feed_relay( @acm async def open_oi_feed( + instruments: list[Symbol], ) -> to_asyncio.LinkedTaskChannel: expiry_date: str = '6DEC24' instruments: list[Symbol] = [] @@ -960,12 +961,18 @@ async def open_oi_feed( @acm async def maybe_open_oi_feed( + instruments: list[Symbol], ) -> trio.abc.ReceiveStream: # TODO: add a predicate to maybe_open_context feed: to_asyncio.LinkedTaskChannel async with maybe_open_context( acm_func=open_oi_feed, + kwargs={ + 'instruments': instruments + }, + key=f'{instruments[0]}', + ) as (cache_hit, feed): if cache_hit: yield broadcast_receiver(feed, 10)