(!****************************************************** Xpress-SP Example ====================== `````````````````` FILE: OptionPricing.mos DESCRIPTION: Stochastic multi-stage linear model TYPE: Finance: Option pricing in presence of transaction costs The goal of this model is to evaluate the pay off of an option in dynamically complete market by trading stock and bonds. The option value is simply the cost of replicating the portfolio. Further we assume no cost of trading at the initial and the final stage, but there is a bid-ask spread on stocks in the intermediate stages. In the Black-Scholes option pricing model, we discretize the time period for re- investment. The interest rate is fixed, and so is the volatility of stocks. MODEL: Parameters: T= Number of stages (indexed by t) Assets= {Stocks,Bonds} (indexed by i) r= Fixed annualized rate of return of bonds ó= Volatility of returns of stocks del= Time span for re-investment è= Transaction cost X= Strike price of option Stochasticity: ä(t)= Movement (1/-1 corresponding to up/down) of stock at stage t P(i,t)= Price of Asset i at stage t: P(Bonds,t)=P(Bonds,t-1).exp(r.del) P(Stocks,t)=P(Stocks,t-1).exp(ä(t).ó.sqrt(del)) O = Option payoff on maturity: for call option= max(P(Stocks,T)-X,0) for put option= max(X-P(Stocks,T),0) Decision variables: q(i,t) = Quantity of Asset i at stage t x(t),y(t)= Quantity of stocks bought and sold respectively at stage t Model formulation: min sum(i) P(i,1).q(i,1) s.t q(Stocks,t) - q(Stocks,t-1) = x(t) - y(t), t>1 P(Stocks,t).[x(t).{1+del} - y(t).{1-del}] + P(Bonds,t).[q(Bonds,t) - q(Bonds,t-1)] <= 0, 1= O x(t), y(t)>= 0, t>1 FURTHER INFO: see Xpress-SP guide see 'Option Pricing with Transaction Costs', Optimization Methods in Finance', Gerard Cornuejols DATE: Oct 2006 (c) 2006 Dash Associates Author: Nitin Verma Dash Optimization Inc, NJ *******************************************************!) model OptionPricing uses 'mmsp' parameters T=5 !#stages call=true !call/ put option X=100.0 !strike price theta=0.02 !fraction of cost of trading sigma=0.35 !volatility delta=1.0 !time-span for re-invetment, Maturity date for option=T*delta r=0.07 !fixed rate of return for bonds InitStkPrice=95 !stock's price initially InitBndPrice=100 !bond's price initially DEBUG=false !debug model to see various information end-parameters forward procedure generateTree !generate tree declarations Assets={"Stocks","Bonds"} !set of all the assets Stages=1..T !set of stages q:array(Assets,Stages) of spvar !quantity of assets in each stage x,y:array(2..T) of spvar !quantity of stocks bought, sold resp in each stage movement:array(2..T) of sprand !up/down (1/-1 resp) movement of stocks price:array(Assets,Stages) of sprandexp !price of assets OptPayOff:sprandexp !amount to be paidoff at the end of horizon InitInv:splinctr !total initial investment BalanceStocks:array(2..T) of splinctr !balance of stocks BalancePosition:array(2..T) of splinctr !balance of cash position end-declarations spsetstages(Stages) !set stages for SP setparam('xsp_implicit_stage',true) !use last index t to associate with stage forall(t in Stages) do !random price of assets in each stage if t=1 then price("Stocks",t):=InitStkPrice price("Bonds",t):=InitBndPrice else price("Stocks",t):=price("Stocks",t-1)*exp(movement(t)*sigma*delta^0.5) price("Bonds",t):=price("Bonds",t-1)*exp(r*delta) end-if end-do if call then !payoff at the end depending on the option type OptPayOff:=maximum(price("Stocks",T)-X,0) !alternatively !OptPayOff:=spif(price("Stocks",T)>X,price("Stocks",T)-X,0) else OptPayOff:=maximum(X-price("Stocks",T),0) end-if generateTree !generate the stochastic tree based on movement if DEBUG then spprinttree !print scenario tree end-if forall(i in Assets,t in Stages) q(i,t) is_free !-ive value implies short position !InitInv:=q("Stocks",1)*InitStkPrice+q("Bonds",1)*InitBndPrice InitInv:=sum(i in Assets) q(i,1)*price(i,1) forall(t in 2..T) BalanceStocks(t):=q("Stocks",t)-q("Stocks",t-1)=x(t)-y(t) forall(t in 2..T) if t=T then BalancePosition(t):=sum(i in Assets) q(i,t-1)*price(i,t)>=OptPayOff else BalancePosition(t):= (x(t)*(1+theta)-y(t)*(1-theta))*price("Stocks",t)+ (q("Bonds",t)-q("Bonds",t-1))*price("Bonds",t)<=0 end-if setparam("xsp_scen_based",false) !create a node based problem setparam('xsp_verbose',true) !get messages from optimizer in IVE setparam('xsp_disp_warnings',false) ! do not display any warnings if DEBUG then spexportprob(XSP_MIN,InitInv,XSP_X_SP) !print stochastic problem ! cannot export this problem in SMSPS format as coeff are of the form f(rand(t))=f(rand(t-1))*() spexportprob(XSP_MIN,InitInv,XSP_X_LP) !print LP file end-if minimize(InitInv) spwriteprob("InitInv","") procedure generateTree declarations val:array(1..2) of real prob:array(1..2) of real end-declarations val:: [1,-1] !up/down movement values prob:: [.5,.5] !up/down movement probabilities forall(t in 2..T) spsetdist(movement(t),val,prob) !set distributions spgenexhtree !generate exhaustive tree based on distributions end-procedure end-model