From e37fb00e7dd5d9364520a79feccbc048c4bb6c47 Mon Sep 17 00:00:00 2001 From: Nelson Torres Date: Fri, 6 Dec 2024 07:41:48 -0300 Subject: [PATCH] removed unused variable minor refactor --- piker/brokers/deribit/api.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/piker/brokers/deribit/api.py b/piker/brokers/deribit/api.py index f01f6112..784e8efe 100644 --- a/piker/brokers/deribit/api.py +++ b/piker/brokers/deribit/api.py @@ -875,12 +875,10 @@ async def aio_open_interest_feed_relay( open_interest: Decimal = oi.open_interest oi_by_strikes[f'{strike_price}'][f'{option_type}'] = open_interest - is_ready = check_if_complete(oi_by_strikes) - if is_ready: + if check_if_complete(oi_by_strikes): + closes: list[str] = sorted(oi_by_strikes.keys()) for strike in oi_by_strikes: s: Decimal = Decimal(f'{strike}') - close_losses = Decimal(0) - closes: list[str] = sorted(oi_by_strikes.keys()) call_cash: Decimal = Decimal(0) put_cash: Decimal = Decimal(0) for close in closes: @@ -888,10 +886,11 @@ async def aio_open_interest_feed_relay( call_cash += max(0, (s - c) * oi_by_strikes[f'{close}']['C']) put_cash += max(0, (c - s) * oi_by_strikes[f'{close}']['P']) - intrinsic_values[f'{strike}'] = {} - intrinsic_values[f'{strike}']['C'] = call_cash - intrinsic_values[f'{strike}']['P'] = put_cash - intrinsic_values[f'{strike}']['total'] = (call_cash + put_cash) + intrinsic_values[strike] = { + 'C': call_cash, + 'P': put_cash, + 'total': call_cash + put_cash, + } for strike in intrinsic_values: if intrinsic_values[f'{strike}']['total'] < total_intrinsic_value: