:

## Financial options plotting

I've just made a sheet with two procedures that can be used to plot financial options at expiry.

>

version 1.0 - feb 2006

>

> inst_value:=proc(oType, E) if oType="put" then S->max(S-E,0) elif oType="call" then S->max(E-S,0) elif oType="share"then S->S else S->0; end if; end proc;

> C:=[E1=1,E2=2];

> nops(C);

> seq(op(2,C[k]),k=1..2);

> inst_plot:=proc( x) local opts, pf, plt, lst, ys, my, My, ti,S,VR, frep,k,Es, Xs,EL;
opts:= [args[2..-1]];
pf:=args[1];
if not hasoption(opts,'title','ti') then ti:=""; end if;
frep:=pf(S);
if hasoption(opts,'variables','VR') then frep:=subs(VR,frep); else; VR:=[E=1]; frep:=subs(E=1,frep); end if;
Xs:=seq(op(2,VR[k]),k=1..nops(VR));
plt:=plot(frep,S=min(Xs)-1..max(Xs)+1,labels=["value of share","value of position"],labeldirections=[HORIZONTAL,VERTICAL],scaling=CONSTRAINED,thickness=2,xtickmarks=0,ytickmarks=0,title=ti):
lst:=op(1,op(1,plt)): ys:=seq(lst[k][2],k=1..nops(lst)): My:=max(ys); my:=min(ys);
Es:=seq([[op(2,VR[k]),my],[op(2,VR[k]),My]],k=1..nops(VR));
EL:=seq(TEXT([op(2,VR[k]),My+.1],op(1,VR[k])),k=1..nops(VR));
PLOT(EL,CURVES(Es,COLOR(RGB,[0,0,1])),op(1,plt),seq(op(k,plt),k=2..nops(plt)));
end proc;

> #trace(inst_plot);

> example_a:=(inst_value("put",E)+inst_value("share",0));

> inst_plot( example_a, title="+1 put / +1 share");

> inst_plot( inst_value("call", E)+inst_value("put",E),title="+1 call / +1 put");

> inst_plot( inst_value("call", E1)-inst_value("put",E2),title="+1 call(E1) / -1 put(E2)",variables=[E1=1,E2=2]);

> inst_plot( inst_value("call",E1)+inst_value("put",E2),title="+1 call(E1) / +1 put(E2)", variables=[E1=1,E2=2]);

> inst_plot( inst_value("call",E1)+inst_value("put",E2),title="+1 call(E1) / +1 put(E2)", variables=[E1=2,E2=1]);

>

> inst_plot( inst_value("call",E1)+inst_value("put",E2)-2*inst_value("call",E),title="+1 call(E1) / +1 put(E2) / -2 call(E)", variables=[E1=1,E=2,E2=3]);

>

>

>

>

This post was generated using the MaplePrimes File Manager