New in Wolfram
Mathematica
8: Built-in Financial Computations
◄
previous
|
next
►
Application Areas
Applications
Construct a synthetic short position on a stock by using the capabilities of
FinancialDerivative
.
In[1]:=
X
synth[a_, b_] := Block[{tab, lower, upper, pricec = FinancialDerivative[{"American", "Call"}, a, b, "Value"], pricep = FinancialDerivative[{"American", "Put"}, a, b, "Value"], deltac = FinancialDerivative[{"American", "Call"}, a, b, "Delta"], deltap = FinancialDerivative[{"American", "Put"}, a, b, "Delta"], gammac = FinancialDerivative[{"American", "Call"}, a, b, "Gamma"], gammap = FinancialDerivative[{"American", "Put"}, a, b, "Gamma"], qcall, qput, myParabolicApproximation, underlyingprice = "CurrentPrice" /. b, strikeprice = "StrikePrice" /. a, volatility = "Volatility" /. b, timetoexpiry = "Expiration" /. a, underlyingrange}, underlyingrange[number_] := underlyingprice + number*underlyingprice*volatility*Sqrt[timetoexpiry]; lower = underlyingprice - 1.5*strikeprice*volatility*Sqrt[timetoexpiry]; upper = underlyingprice + 1.5*strikeprice*volatility*Sqrt[timetoexpiry]; {qcall, qput} = {qc, qp} /. Flatten@Solve[-qc deltac + qp deltap == -1. && -qc gammac + qp gammap == 0, {qc, qp}]; tab = Transpose@ Flatten[Table[{{val, time, underlyingprice - val}, {val, time, qput (FinancialDerivative[{"American", "Put"}, a /. _["Expiration", _] :> Rule["Expiration", time], b /. _["CurrentPrice", _] :> Rule["CurrentPrice", val], "Value"] - pricep) - qcall (FinancialDerivative[{"American", "Call"}, a /. _["Expiration", _] :> Rule["Expiration", time], b /. _["CurrentPrice", _] :> Rule["CurrentPrice", val], "Value"] - pricec)}}, {val, lower, upper, (upper - lower)/81}, {time, "Expiration" /. a, ("Expiration" /. a)/ 2, -("Expiration" /. a)/40}], 1]; Column[{Spacer[30], Style["Total cost of synthetic short position: $" <> ToString[ qput pricep - qcall pricec], FontFamily -> "Georgia"], Spacer[30], ListPlot3D[tab, AxesLabel -> {"price", "time", "value"}, AxesOrigin -> {lower, 0}, ImageSize -> 425, Mesh -> None, PlotStyle -> {Directive[Orange, Specularity[White, 40]], Directive[LightBlue]}]}]]; synth[ {"StrikePrice" -> 40.00, "Expiration" -> 1, "Value" -> 13}, {"InterestRate" -> 0.01, "CurrentPrice" -> 50, "Dividend" -> 0.05, "Volatility" -> 0.40}]
Out[1]=
This plot shows that the value of the synthetic short closely tracks the value of an actual short position over time and price.