Skip to content

Commit

Permalink
We need to await on call_is_itm()
Browse files Browse the repository at this point in the history
  • Loading branch information
brndnmtthws committed Dec 3, 2024
1 parent 78c1f80 commit 0d21d58
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions thetagang/portfolio_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ async def call_is_itm(self, contract: Contract) -> bool:
def call_can_be_closed(self, call: PortfolioItem, table: Table) -> bool:
return self.position_can_be_closed(call, table)

def call_can_be_rolled(self, call: PortfolioItem, table: Table) -> bool:
async def call_can_be_rolled(self, call: PortfolioItem, table: Table) -> bool:
# Ignore long positions, we only roll shorts
if call.position > 0:
return False
Expand All @@ -256,7 +256,7 @@ def call_can_be_rolled(self, call: PortfolioItem, table: Table) -> bool:

if (
isinstance(call.contract, Option)
and self.call_is_itm(call.contract)
and await self.call_is_itm(call.contract)
and self.config["roll_when"]["calls"]["always_when_itm"]
):
table.add_row(
Expand All @@ -271,7 +271,7 @@ def call_can_be_rolled(self, call: PortfolioItem, table: Table) -> bool:
if (
not self.config["roll_when"]["calls"]["itm"]
and isinstance(call.contract, Option)
and self.call_is_itm(call.contract)
and await self.call_is_itm(call.contract)
):
return False

Expand Down Expand Up @@ -569,7 +569,7 @@ async def manage(self) -> None:
(rollable_puts, closeable_puts, group1) = await self.check_puts(
portfolio_positions
)
(rollable_calls, closeable_calls, group2) = self.check_calls(
(rollable_calls, closeable_calls, group2) = await self.check_calls(
portfolio_positions
)
console.print(Panel(Group(group1, group2)))
Expand Down Expand Up @@ -657,7 +657,7 @@ async def check_put_can_be_rolled_task(

return (rollable_puts, closeable_puts, group)

def check_calls(
async def check_calls(
self, portfolio_positions: Dict[str, List[PortfolioItem]]
) -> Tuple[List[Any], List[Any], Group]:
# Check for calls which may be rolled to the next expiration or a better price
Expand All @@ -675,7 +675,7 @@ def check_calls(
table.add_column("Detail")

for c in tqdm(calls, desc="Checking rollable/closeable calls..."):
if self.call_can_be_rolled(c, table):
if await self.call_can_be_rolled(c, table):
rollable_calls.append(c)
elif self.call_can_be_closed(c, table):
closeable_calls.append(c)
Expand Down

0 comments on commit 0d21d58

Please sign in to comment.