Hi Nick,
Depending on your options strategy, you can calculate profit in different ways.
If you want to sell the option before expiration, then you can calculate profit using the UnrealizedProfit attribute of a security.
self.Portfolio[optionContract.Symbol].UnrealizedProfit
If you plan to exercise your options/let them expire, then you would want to calculate the exercise value using something like the following:
def CalculateExerciseProfit(self, optionContract, dataTime):
if optionContract.Expiry == dataTime:
strike = optionContract.Strike
underlying = optionContract.UnderlyingLastPrice
quantity = self.Portfolio[optionContract.Symbol].Quantity
## Options contracts are for 100 shares, so multiply by 100
## and the number of contracts that will be exercised
if (optionContract.Right == OptionRight.Call):
exerciseProfit = (underlying - strike) * 100 * quantity
if (optionContract.Right == OptionRight.Put):
exerciseProfit = (strike - underlying) * 100 * quantity
return exerciseProfit
This value could be calculated anytime but is only relevant when the options expire. It is sub-optimal to exercise an option before expiration unless it is an American option whose underlying pays a dividend.