From 417ffb0d8653f04870a71d5193ec225397d2e013 Mon Sep 17 00:00:00 2001 From: Brenden Matthews Date: Tue, 3 Dec 2024 12:24:46 -0500 Subject: [PATCH] Handle this failure gracefully I completely misunderstood the code in the previous attempt and messed this up (in #524 and #525). --- thetagang/portfolio_manager.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/thetagang/portfolio_manager.py b/thetagang/portfolio_manager.py index c898236c8..c3dc07179 100644 --- a/thetagang/portfolio_manager.py +++ b/thetagang/portfolio_manager.py @@ -1299,15 +1299,10 @@ async def row_position_task(position: PortfolioItem) -> None: symbol = position.contract.symbol position.contract.exchange = self.get_order_exchange() - try: - buy_ticker = await self.ibkr.get_ticker_for_contract( - position.contract - ) - except RequiredFieldValidationError: - # Likely no market price available for this contract, - # possibly because there are no bids or asks. In this case, - # treat it as a $0.00 contract. - pass + buy_ticker = await self.ibkr.get_ticker_for_contract( + position.contract, + optional_fields=[TickerField.MIDPOINT, TickerField.MARKET_PRICE], + ) strike_limit = get_strike_limit(self.config, symbol, right) if right.startswith("C"):