Skip to content

Commit

Permalink
Continue when there's no market price for position
Browse files Browse the repository at this point in the history
Follow-up to #523 and #524.
  • Loading branch information
brndnmtthws committed Dec 3, 2024
1 parent 08ba514 commit 8aede60
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion thetagang/portfolio_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,15 @@ async def row_position_task(position: PortfolioItem) -> None:
symbol = position.contract.symbol

position.contract.exchange = self.get_order_exchange()
buy_ticker = await self.ibkr.get_ticker_for_contract(position.contract)
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

strike_limit = get_strike_limit(self.config, symbol, right)
if right.startswith("C"):
Expand Down

0 comments on commit 8aede60

Please sign in to comment.