# How to find the positive region of this function?

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,
FinancialDerivative[{"European",
"Call"}, {"StrikePrice" -> strikePrice,
"Expiration" -> 0}, {"InterestRate" -> 0.1, "Volatility" -> 0.2,
"CurrentPrice" -> currentPrice, "Dividend" -> 0.05}] -


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,
FinancialDerivative[{"European",
"Put"}, {"StrikePrice" -> strikePrice,
"Expiration" -> 0}, {"InterestRate" -> 0.1, "Volatility" -> 0.2,
"CurrentPrice" -> currentPrice, "Dividend" -> 0.05}] -


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}}

• You can do NMinimize[{x , 0 < x < 100, PayOffCall[x, 50., 2.] > 0}, x]. Aug 23, 2014 at 9:32
• Excellent! Thanks so much. I wouldn't have thought of this one. Aug 23, 2014 at 9:39
• This is not a discussion forum. We follow a Question & Answer format instead. Therefore it is appropriate to put extensions and clarifications to your original question in the Question itself (by editing it). I have moved your content for you in this case. Aug 23, 2014 at 9:53
• You can use the package here with RootSearch[ PayOffCall[x, 50, 3] + PayOffPut[x, 50, 2] == 0, {x, 0, 100}] to find all the zeros. Aug 23, 2014 at 10:30

I would suggest:

PayOffCall

Select a limit large enough for your purposes:

lim = 100.;


Compute the values:

v1 = {#, PayOffCall[#, 50, 2]} & /@ Range[lim];


Create an interpolating function:

f = Interpolation[v1, InterpolationOrder -> 1];

Plot[f[x], {x, 1, lim}] We can evaluate f for arbitrary points

{f[1.4], f[61.3]}


{-2., 9.3}

Find the break-even point

break = FindInstance[f[x] == 0, x, Reals][[1, 1, 2]]


52.

Is PayOffCall positive for x >= 52?

v2 = f[#] & /@ Range[break, lim, 1.];

AllTrue[v2, NonNegative] (* Version 10 *)


True

And @@ (NonNegative /@ v2) (* Prior versions *)


Call + Put

v1 = (PayOffCall[#, 50, 3] + PayOffPut[#, 50, 2]) & /@ Range[lim];

f = Interpolation[v1, InterpolationOrder -> 1];

roots = Rest @ NestList[FindInstance[f[x] == 0 && x > #, x, Reals][[1, 1, 2]] &, 0., 2]


{45., 55.}

Plot[f[x], {x, 41, 59},
ColorFunction -> Function[{x, y}, If[y >= 0, Green, Red]],
ColorFunctionScaling -> False,
AxesOrigin -> {41, 0},
Ticks -> {roots, Automatic},
ImageSize -> 500,
AxesLabel -> {"Strike Price at Expiration", "P/(L)"}]
` • Amazing answer. Thanks eldo. I will try this immediately. Aug 23, 2014 at 13:18