Skip to content

Commit

Permalink
Future options bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rylorin committed Jul 11, 2024
1 parent 2289690 commit b1a3eb9
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/routers/trades.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ const computeComboRisk = (thisTrade: Trade, virtuals: Record<number, VirtualPosi
stocks[item.contract.id] = { contract: item.contract, cost: item.cost, quantity: item.quantity };
break;
case ContractType.Option:
case ContractType.FutureOption:
if (item.quantity && !((item.contract as StatementUnderlyingOption).strike in limits))
limits.push((item.contract as StatementUnderlyingOption).strike);
switch ((item.contract as StatementUnderlyingOption).callOrPut) {
Expand Down Expand Up @@ -375,7 +376,12 @@ const computeComboRisk = (thisTrade: Trade, virtuals: Record<number, VirtualPosi
}
break;
default:
logger.log(LogLevel.Error, MODULE + ".computeComboRisk", undefined, "unimplemented secType");
logger.log(
LogLevel.Error,
MODULE + ".computeComboRisk",
undefined,
"Unimplemented SecType: " + item.contract.secType,
);
}
});
limits.sort((a, b) => a - b);
Expand Down Expand Up @@ -443,6 +449,7 @@ const countContratTypes = (virtuals: Record<number, VirtualPositionEntry>): numb
else if (item.quantity < 0) short_stock += 1;
break;
case ContractType.Option:
case ContractType.FutureOption:
switch ((item.contract as StatementUnderlyingOption).callOrPut) {
case OptionType.Call:
if (item.quantity > 0) long_call += 1;
Expand All @@ -455,7 +462,12 @@ const countContratTypes = (virtuals: Record<number, VirtualPositionEntry>): numb
}
break;
default:
logger.log(LogLevel.Error, ".computeTradeStrategy", undefined, "unimplemented sec type");
logger.log(
LogLevel.Error,
MODULE + ".computeTradeStrategy",
undefined,
"Unimplemented SecType: " + item.contract.secType,
);
}
});
return [long_stock, short_stock, long_call, short_call, long_put, short_put];
Expand Down

0 comments on commit b1a3eb9

Please sign in to comment.