views:

94

answers:

2

Hello, I am trying to calculate the profit/loss of a short call at various times in the future, but it isn't coming out correct. Compared to the time of expiration, the ones with time left have less profit above the strike price, but at some point below the strike they don't lose value as fast as the t=0 line. Below is the formula in pseudocode, what am I doing wrong?

profit(stockprice) = -1 * (black_scholes_price_of_call(stockPrice,optionStrike,daysTillExpiration) - premium);

Real matlab code:

function [ x ] = sell_call( current,strike,price,days)  
if (days > 0)  
    Sigma = .25;  
    Rates = 0.05;  
    Settle = today;  
    Maturity = today + days;  

    RateSpec = intenvset('ValuationDate', Settle, 'StartDates', Settle, 'EndDates',...
        Maturity, 'Rates', Rates, 'Compounding', -1);

    StockSpec = stockspec(Sigma, current);

    x = -1 * (optstockbybls(RateSpec, StockSpec, Settle, Maturity, 'call', strike) - price);
else
    x = min(price,strike-current-price);
end

end

Thanks, CP

+2  A: 

Your formula ain't right. I don't know why you need that leading -1 as a multiplier for, because when I distribute it out the "formula" is a simple one:

profit(stockprice) = premium - black_scholes_price_of_call(stockPrice,optionStrike,daysTillExpiration);

Pretty simple. So that means the problem is buried in that function for the price of the call, right?

When I compare your formula to what I see as the definition on Wikipedia, I don't see a correspondence at all. Your MATLAB code doesn't help, either. Dig into the functions and see where you went wrong.

Did you write those? How did you test them before you assembled them into this larger function. Test the smaller blocks before you assemble them into the bigger thing.

What baseline are you testing against? What known situation are you comparing your calculation to? There are lots of B-S calculators available. Maybe you can use one of those.

I'd assume that it's an error in your code rather than MATLAB. Or you've misunderstood the meaning of the parameters you're passing. Look at your stuff more carefully, re-read the documentation for that function, and get a good set of baseline cases.

duffymo
The function optstockbybls is part of a matlab toolbox.
CptanPanic
I'd assume that it's an error in your code rather than MATLAB. Look at your stuff more carefully, and get a good set of baseline cases.
duffymo
A: 

I found the problem, it had to do with the RateSpec argument. When you pass in a interest rate, it affects the option pricing.

CptanPanic
So "Or you've misunderstood the meaning of the parameters you're passing. Look at your stuff more carefully, re-read the documentation for that function, and get a good set of baseline cases" this was correct. Accept the correct answer if that's it.
duffymo

related questions