Reputation: 2834
I'm writing an Chrome extension to calculate total profit and loss from Robinhood trading history.
Found out that total profit/loss calculation for options trading is more complicated than what I expected when counting options events such as expiration, exercise, and assignment.
I tried to think through all possible scenarios and came up with the formula that I think it will work but wanted to get some other eyes on it to see if I'm missing anything or doing it completely wrong.
// Option trading Profit / Loss occurrence
// Buy to open call options > Betting on Bullish
// - TotalPL = (selling/expried premium * quantity) - (buying premium * quantity)
// - Exercise (underlying_price * (quantity * 100)) - (strike_price * (quantity * 100))
// Sell to open call options > Betting on Bearish
// - TotalPL = (buying premium * quantity) - (selling/expried premium * quantity)
// - Assignment (strike_price * (quantity * 100)) - (underlying_price * (quantity * 100))
//
// Example: Sell 2 of SPY $200 2023/01/06 call options at $10 premium (with the 200 shares of SPY as a collateral)
// Senario 1) selling options before expiration
// TotalPL = ($10 * 2) - (current premium at the time of selling * 2)
// Senario 2) option expired in the money
// TotalPL = ($10 * 2) - (0 * 2) >> current premium at the time of selling is $0. You keep all the credit. It is the same as senario 1.
// Senario 3) option expired out of the money. SPY ended at $250 on 2023/01/06
// TotalPL = ($200 * 200) - ($250 * 200)
// Buy to open put options > Betting on Bearish
// - TotalPL = (selling/expried premium * quantity) - (buying premium * quantity)
// - Exercise (strike_price * (quantity * 100)) - (underlying_price * (quantity * 100))
// Sell to open put options > Betting on Bullish
// - TotalPL = (buying premium * quantity) - (selling/expried premium * quantity)
// - Assignment (underlying_price * (quantity * 100)) - (strike_price * (quantity * 100))
Upvotes: 2
Views: 311