如何用Black-Scholes公式计算空头看涨期权的价值?

发布于 2024-09-06 10:24:36 字数 872 浏览 3 评论 0原文

我试图计算未来不同时间的空头看涨期权的利润/损失,但结果不正确。与到期时相比,剩余时间的交易者在高于行使价时利润较少,但在低于行使价的某个点,它们的价值损失速度不会像 t=0 线那样快。下面是伪代码的公式,我做错了什么?

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

真实的matlab代码:

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

海未深 2024-09-13 10:24:36

你的公式不对。我不知道为什么你需要前导 -1 作为乘数,因为当我分发它时,“公式”是一个简单的公式:

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

非常简单。那么这意味着问题就埋藏在该函数的调用成本中,对吗?

当我将你的公式与维基百科上的定义进行比较时,我根本看不到对应关系。您的 MATLAB 代码也没有帮助。深入研究函数,看看哪里出了问题。

这些是你写的吗?在将它们组装成这个更大的函数之前,您如何测试它们?在将较小的块组装成更大的东西之前先对其进行测试。

您测试的基准是什么?您将您的计算与哪种已知情况进行比较?有很多 BS 计算器可用。也许你可以使用其中之一。

我认为这是您的代码中的错误,而不是 MATLAB 中的错误。或者您误解了您传递的参数的含义。更仔细地查看您的内容,重新阅读该功能的文档,并获得一组良好的基线案例。

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.

薄荷→糖丶微凉 2024-09-13 10:24:36

我发现了问题,它与 RateSpec 参数有关。当您传递利率时,它会影响期权定价。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文