I'm new-ish to Mathematica and I'm using it to learn the basics of derivative trading (for fun not for trading!). I've defined a simple function to calculate the pay off of a trading on a call. I have no problem drawing the P/(L) diagram but I cannot find which Mathematica function to use to get the region of x for which my P/(L) is positive. Can you help?
My function is basic and calculates the difference between the cost of the call (callPremium) and value of the Call at expiration:
PayOffCall[currentPrice_?NumberQ, strikePrice_?NumberQ,
callPremium_?NumberQ] :=
FinancialDerivative[{"European",
"Call"}, {"StrikePrice" -> strikePrice,
"Expiration" -> 0}, {"InterestRate" -> 0.1, "Volatility" -> 0.2,
"CurrentPrice" -> currentPrice, "Dividend" -> 0.05}] -
callPremium;
I can then easily plot the P/(L) diagram
ListLinePlot[{#, PayOffCall[#, 50, 2]} & /@ Range[47, 57, 1],
AxesLabel -> {"Strike Price at Expiration", "P/(L)"}]
I can find the break-even point:
In:= FindRoot[PayOffCall[x, 50, 2] == 0, {x, 47, 57}] // Quiet
Out:= {x -> 52.}
And now I'd like Mathematica to tell me that PayOffCall[x,50,2] is positive for x>=52.
I've tried different function without any success: Solve,NSolve, FindMaximum, etc... but I think my Mathematica skills are letting me down.
For instance:
In:= NSolve[PayOffCall[x, 50, 2] > 0, x]
NSolve::nsmet: This system cannot be solved with the methods available to NSolve. >>
Out:= NSolve[PayOffCall[x, 50, 2] > 0, x]
I'd like to know the right function to return:
Out:= {x>52.}
Any help to this newbie question is much appreciated!
Thanks to b.gatessucks for his answer. Now if I define an additional function for Put
PayOffPut[currentPrice_?NumberQ, strikePrice_?NumberQ,
putPremium_?NumberQ] :=
FinancialDerivative[{"European",
"Put"}, {"StrikePrice" -> strikePrice,
"Expiration" -> 0}, {"InterestRate" -> 0.1, "Volatility" -> 0.2,
"CurrentPrice" -> currentPrice, "Dividend" -> 0.05}] -
putPremium;
I can draw the P/L diagram for a "Long Straddle" where I buy a 50 Call at 3 USD and I buy 50 Put at 2 USD
ListLinePlot[{#, PayOffCall[#, 50, 3] + PayOffPut[#, 50, 2]} & /@
Range[41, 59, 1],
AxesLabel -> {"Strike Price at Expiration", "P/(L)"}]
But then neither FindRoot or NMinimize return the correct region
In:= FindRoot[PayOffCall[x, 50, 3] + PayOffPut[x, 50, 2] == 0, {x, 47, 57}]
Out:= {x -> 55.}
In:= NMinimize[{x, 41 < x < 60,
PayOffCall[x, 50, 3] + PayOffPut[x, 50, 2] > 0}, x]
Out:= {41., {x -> 41.}}
What's the solution then!?
Update Thanks to eldo and b.gatessucks answers, I created the following simple algorithm:
<< RootSearch`
f[x_] := PayOffCall[x, 50, 3] + PayOffPut[x, 50, 2];
r = RootSearch[f[x] == 0, {x, 1, 100}]; // Quiet
r2 = x /. r; AppendTo[r2, r2[[-1]]*1.5]; PrependTo[r2, 0.0001];
r2 = Partition[r2, 2, 1]
Do[
v = f[#] & /@ Range[##, 1.] & @@ r2[[n]];
AppendTo[r2[[n]], "Profit" -> AllTrue[v, # >= 0 &]],
{n, Length[r2]}];
r2
Which returns what I needed:
{{0.0001, 45., "Profit" -> True}, {45., 55., "Profit" -> False}, {55.,
82.5, "Profit" -> True}}
NMinimize[{x , 0 < x < 100, PayOffCall[x, 50., 2.] > 0}, x]
. $\endgroup$RootSearch[ PayOffCall[x, 50, 3] + PayOffPut[x, 50, 2] == 0, {x, 0, 100}]
to find all the zeros. $\endgroup$