fix the input values

for acm related to oi
Nelson Torres 2024-12-07 10:16:37 -03:00
parent 3b8cec45da
commit 423b514cec
2 changed files with 22 additions and 3 deletions

View File

@ -8,8 +8,20 @@ from piker.brokers.deribit.api import (
async def max_pain_daemon( async def max_pain_daemon(
) -> None: ) -> None:
async with maybe_open_oi_feed() as oi_feed: def check_if_complete(
print('Im in...') 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(): async def main():

View File

@ -826,8 +826,8 @@ async def maybe_open_price_feed(
async def aio_open_interest_feed_relay( async def aio_open_interest_feed_relay(
fh: FeedHandler, fh: FeedHandler,
instruments: list,
oi_by_strikes: dict[str, dict[str, Decimal]], oi_by_strikes: dict[str, dict[str, Decimal]],
instruments: list[Symbol],
from_trio: asyncio.Queue, from_trio: asyncio.Queue,
to_trio: trio.abc.SendChannel, to_trio: trio.abc.SendChannel,
) -> None: ) -> None:
@ -929,6 +929,7 @@ async def aio_open_interest_feed_relay(
@acm @acm
async def open_oi_feed( async def open_oi_feed(
instruments: list[Symbol],
) -> to_asyncio.LinkedTaskChannel: ) -> to_asyncio.LinkedTaskChannel:
expiry_date: str = '6DEC24' expiry_date: str = '6DEC24'
instruments: list[Symbol] = [] instruments: list[Symbol] = []
@ -960,12 +961,18 @@ async def open_oi_feed(
@acm @acm
async def maybe_open_oi_feed( async def maybe_open_oi_feed(
instruments: list[Symbol],
) -> trio.abc.ReceiveStream: ) -> trio.abc.ReceiveStream:
# TODO: add a predicate to maybe_open_context # TODO: add a predicate to maybe_open_context
feed: to_asyncio.LinkedTaskChannel feed: to_asyncio.LinkedTaskChannel
async with maybe_open_context( async with maybe_open_context(
acm_func=open_oi_feed, acm_func=open_oi_feed,
kwargs={
'instruments': instruments
},
key=f'{instruments[0]}',
) as (cache_hit, feed): ) as (cache_hit, feed):
if cache_hit: if cache_hit:
yield broadcast_receiver(feed, 10) yield broadcast_receiver(feed, 10)