Re: [閒聊] 蝴蝶蝴蝶真的真美麗
日曆
====================================
function payoff = calendar( St,k,r,t,sigma,c )
%calendar spread
LC=max(blsprice(St,k,r,t,sigma),0)-c;%long a call 遠期
SC=-max(St-k,0)+c;%short a call 近期
payoff=LC+SC;
end
=================================
k=40;%strike
r=0.05;%rate
t=300;
c=4;
St=20:0.1:60;
sigma=0.4;
plot(St,-max(St-k,0)+c,'--black');
hold on;
plot(St,max(blsprice(St,k,r,t,sigma),0)-c,'--blue');
plot(St,calendar( St,k,r,t,sigma,c) ,'r');
======================================
input
========================================
E1=input('請輸入E1=');
E2=input('請輸入E2=');
S=linspace(0,6,100);
B=max(S-E1,0)-max(S-E2,0);
plot(S,B);
ylim([0,3]);
xlabel('S');
ylabel('B');
title('Bull Spread payoff')
grid on
=================================
慢用
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.114.135.236
討論串 (同標題文章)
完整討論串 (本文為第 2 之 3 篇):
閒聊
3
3