Syntax [PortRisk, PortReturn, PortWts] = portoptExpReturn, ExpCovariance, NumPorts, PortReturn, ConSet Arguments Description [PortRisk, PortReturn, PortWts] = portoptExpReturn, ExpCovari
Trang 12portcons
Purpose Portfolio constraints
Syntax ConSet = portcons(varargin)
Description Using linear inequalities,portconsgenerates a matrix of constraints for a
portfolio of asset investments The matrixConSetis defined as
the value, wherePortWtsis a 1-by-number of assets (NASSETS) vector of assetallocations
parametersData1, , DataN
ConSet = portcons('ConstType1', Data11, , Data1N,'ConstType2',
constraint typesConstTypeN, and the corresponding constraint parameters
Default All allocations are >= 0; no
short selling allowed
Combined value of portfolioallocations normalized to 1
Scalar representingnumber of assets inportfolio
PVal(required) Scalarrepresenting totalvalue of portfolio
Scalar representingnumber of assets inportfolio Seepcpval
Trang 22-183
allocation per asset
Scalar or vector oflengthNASSETS,specifying minimumallocation per asset
Scalar or vector oflengthNASSETS,specifying maximumallocation per asset
allocations to asset group
matrix specifyingwhich assets belong
to each group
Scalar or a vector oflengthNGROUPS,specifying minimumcombined allocations
in each group
Scalar or a vector oflengthNGROUPS,specifying maximumcombined allocations
in each group See
Trang 3Scalar or vector oflengthNGROUPS
specifying minimumratios of allocations in
Scalar or vector oflengthNGROUPS
specifying maximumratios of allocations in
b(required) Vector oflengthNCONSTRAINTS
specifying the righthand sides of theinequalities
Trang 42-185
Example Constrain a portfolio of three assets:
NumAssets = 3PVal = 1 % Scale portfolio value to 1
AssetMin = 0AssetMax = [0.5 0.9 0.8]
ConSet = 1.0000 1.0000 1.0000 1.0000 –1.0000 –1.0000 –1.0000 –1.0000 1.0000 0 0 0.5000
0 1.0000 0 0.9000
0 0 1.0000 0.8000 –1.0000 0 0 0
0 –1.0000 0 0
0 0 –1.0000 0 1.0000 1.0000 –1.5000 0
Portfolio weights of 30% in IBM, 30% in CPQ, and 40% in XON satisfy theconstraints
See Also pcalims, pcgcomp, pcglims, pcpval, portopt
Trang 52portopt
Purpose Portfolios on constrained efficient frontier
Syntax [PortRisk, PortReturn, PortWts] = portopt(ExpReturn, ExpCovariance,
NumPorts, PortReturn, ConSet)
Arguments
Description [PortRisk, PortReturn, PortWts] = portopt(ExpReturn, ExpCovariance,
frontier with user-specified covariance, returns, and asset constraints
asset investment weights that minimize the risk for given values of theexpected return The portfolio risk is minimized subject to constraints on thetotal portfolio value, the individual asset minimum and maximum allocation,the asset group minimum and maximum allocation, or the asset
group-to-group comparison
portfolio
expected (mean) return of each asset
of the asset returns
frontier Returns are equally spaced between themaximum possible return and the minimum riskpoint IfNumPortsis empty (entered as[]),computes
10equally spaced points
portfolios (NPORTS)-by-1vector If not entered or empty,
minimum and maximum possible values are used
created usingportcons If not specified, a default iscreated
Trang 62-187
Each row represents a portfolio The total of all weights in a portfolio is 1
efficient frontier
Examples Plot the risk-return efficient frontier of portfolios allocated among three assets
Connect 20 portfolios along the frontier having evenly spaced returns Bydefault, choose among portfolios without short-selling and scale the value ofthe portfolio to 1
ExpReturn = [0.1 0.2 0.15];
ExpCovariance = [ 0.005 -0.010 0.004 -0.010 0.040 -0.002 0.004 -0.002 0.023 ];
NumPorts = 20;
portopt(ExpReturn, ExpCovariance, NumPorts)
0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2 0.22 0.12
0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2
0.21
Mean−Variance−Efficient Frontier
Risk(Standard Deviation)
Trang 7Return the two efficient portfolios that have returns of 16% and 17% Limit toportfolios that have at least 20% of the allocation in the first asset, and cap thetotal value in the first and third assets at 50% of the portfolio
ExpReturn = [0.1 0.2 0.15];
ExpCovariance = [ 0.005 -0.010 0.004 -0.010 0.040 -0.002 0.004 -0.002 0.023 ];
PortReturn = [0.16 0.17];
[PortRisk, PortReturn, PortWts] = portopt(ExpReturn,
ExpCovariance, [], PortReturn, ConSet)PortRisk =
0.0919 0.1138PortReturn =
0.1600 0.1700 PortWts = 0.3000 0.5000 0.2000 0.2000 0.6000 0.2000
Trang 82-189
2portrand
Purpose Randomized portfolio risks, returns, and weights
Syntax [risk, ror, weights] = portrand(asset, ret, pts)
[risk, ror, weights] = portrand(asset, ret)[risk, ror, weights] = portrand(asset)portrand(asset, ret, pts)
Arguments asset M-by-N matrix of time series data Rows (M) are observations, and
each column (N) represents a single security
ret 1-by-N vector where each column represents the rate of return for the
corresponding security inasset By default,retis computed by takingthe average value of each column ofasset
pts Scalar that specifies how many random points should be generated
Default =1000
Description [risk, ror, weights] = portrand(asset, ret, pts) returns the risks,
rates of return, and weights of random portfolio configurations
risk Apts-by-1 vector of standard deviations
ror Apts-by-1 vector of expected rates of return
different portfolio configuration
configuration It does not return any data to the MATLAB workspace
This function is used in the MATLAB Financial Expo and illustrates howmultiple weighting combinations of the same portfolio will generate the sameexpected rate of return
See Also frontier
Reference Bodie, Kane, and Marcus, Investments, Chapter 7.
Trang 92portsim
Purpose Random simulation of correlated asset returns
Syntax RetSeries = portsim(ExpReturn, ExpCovariance, NumObs, RetIntervals,
NumSim)
Arguments
Description portsim simulates returns ofNASSETSassets over consecutive observation
intervals Returns are simulated as the increments of constant drift andvolatility Brownian processes
observations The return over an interval of lengthDTis given by
scalar whose value changes each timerandnis referenced
The returns realized from portfolios listed inPortWtsare given by:
which each row contains the asset allocations of a portfolio Each row of
column corresponds to one of the observations inRetSeries Seeportoptand
expected (mean) return of each asset
covariances The standard deviations of the returns
series IfNumObsis entered as the empty matrix[], thelength ofRetIntervalsis used
of interval times between observations If
assumed to have length 1
observations to perform Default = 1
Trang 10NumObs = 10;
RetSeries = portsim(ExpReturn, ExpCovariance, NumObs)RetSeries =
0.1429 0.2626 0.2365 0.0821 0.1599 –0.1796 0.0054 0.6126 0.1072 0.1719 –0.0669 0.1913 0.1518 –0.0843 0.0442 0.0112 0.2709 0.1501 0.0409 0.1683 0.1932 0.1485 0.2522 0.2774 0.0463 0.3222 0.0954 0.1990 0.1024 0.3843
See Also ewstats,portopt,portstats,randn,ret2tick
Trang 112portstats
Purpose Portfolio expected return and risk
Syntax [PortRisk, PortReturn] = portstats(ExpReturn, ExpCovariance,
PortWts)
Arguments
Description [PortRisk, PortReturn] = portstats(ExpReturn, ExpCovariance,
assets
expected (mean) return of each asset
of the asset returns
weights allocated to each asset Each row represents adifferent weighting combination Default =1/NASSETS
Trang 122-193
Examples ExpReturn = [0.1 0.2 0.15];
ExpCovariance = [ 0.0100 –0.0061 0.0042 –0.0061 0.0400 –0.0252 0.0042 –0.0252 0.0225 ];
PortWts=[0.4 0.2 0.4; 0.2 0.4 0.2];
[PortRisk, PortReturn] = portstats(ExpReturn, ExpCovariance, PortWts)
PortRisk = 0.0560 0.0550PortReturn = 0.1400 0.1300
See Also frontcon
Trang 132portvrisk
Purpose Portfolio value at risk
Syntax ValueAtRisk = portvrisk(PortReturn, PortRisk, RiskThreshold,
PortValue)
Arguments
Description ValueAtRisk = portvrisk(PortReturn, PortRisk, RiskThreshold,
one period of time, given the loss probability levelRiskThreshold
portfolio, predicted with a confidence probability of1– RiskThreshold
0.0688 0.0478 0.0366
the expected return of each portfolio over the period
of each portfolio over the period
probability Default =0.05(5%)
of asset portfolio Default =1
Trang 141.0e+007 * 3.6572 1.8684
See Also frontcon,portopt
Trang 152prbond
Purpose Price of security with regular periodic interest payments
Syntax [p, ai] = prbond(sd, md, rv, cpn, yld, per, basis)
[p, ai] = prbond(sd, md, rv, cpn, yld, per)[p, ai] = prbond(sd, md, rv, cpn, yld)
Arguments sd Settlement date Enter as serial date number or date string sdmust
be earlier than or equal tomd
md Maturity date Enter as serial date number or date string
rv Redemption (par, face) value
cpn Coupon rate Enter as decimal fraction
yld Yield Enter as decimal fraction
per Coupons per year An integer Default =2
2= actual/360,3= actual/365
Description [p, ai] = prbond(sd, md, rv, cpn, yld, per, basis) returns the price
pand accrued interestaiof a security with regular periodic interest payments.This function also applies to zero-coupon bonds or pure discount securities bysettingcpn = 0
Example Using this data:
Trang 162-197
returns
p = 1276.64e+003
ai = 6.8132
See Also acrubond, prdisc, prmat, proddf, proddfl, proddl, yldbond
Reference Mayle, Standard Securities Calculation Methods, Volumes I-II, 3rd edition.
Formulas 6, 7
Trang 172prdisc
Purpose Price of discounted security
Syntax p = prdisc(sd, md, rv, disc, basis)
p = prdisc(sd, md, rv, disc)
Arguments sd Settlement date Enter as serial date number or date string sdmust
be earlier than or equal tomd
md Maturity date Enter as serial date number or date string
rv Redemption (par, face) value
disc Discount rate of the security Enter as decimal fraction
See Also acrudisc, prbond, prmat, ylddisc
Reference Mayle, Standard Securities Calculation Methods, Volumes I-II, 3rd edition.
Formula 2
Trang 182-199
2prmat
Purpose Price with interest at maturity
Syntax [p, ai] = prmat(sd, md, id, rv, cpn, yld, basis)
[p, ai] = prmat(sd, md, id, rv, cpn, yld)
Arguments sd Settlement date Enter as serial date number or date string sdmust
be earlier than or equal tomd
md Maturity date Enter as serial date number or date string
id Issue date Enter as serial date number or date string
rv Redemption (par, face) value
cpn Coupon rate Enter as decimal fraction
yld Yield Enter as decimal fraction
2= actual/360,3= actual/365
Description [p, ai] = prmat(sd, md, id, rv, cpn, yld, basis) returns the pricep
and accrued interestaiof a security that pays interest at maturity Thisfunction also applies to zero-coupon bonds or pure discount securities bysettingcpn = 0
Example Using this data:
Trang 19returns
p = 99.9784
ai = 1.9591
See Also acrubond, acrudisc, prbond, prdisc, yldmat
Reference Mayle, Standard Securities Calculation Methods, Volumes I-II, 3rd edition.
Formula 4
Trang 202-201
2proddf
Purpose Price with odd first period
Syntax [p, ai] = proddf(sd, md, id, fd, rv, cpn, yld, per, basis)
[p, ai] = proddf(sd, md, id, fd, rv, cpn, yld, per)[p, ai] = proddf(sd, md, id, fd, rv, cpn, yld)
Arguments sd Settlement date Enter as serial date number or date string sdmust
be earlier than or equal tomd
md Maturity date Enter as serial date number or date string
id Issue date Enter as serial date number or date string
fd First coupon date Enter as serial date number or date string
rv Redemption (par, face) value
cpn Coupon rate Enter as decimal fraction
yld Yield Enter as decimal fraction
per Coupons per year An integer Default =2
2= actual/360,3= actual/365
Description [p, ai] = proddf(sd, md, id, fd, rv, cpn, yld, per, basis) returns
the pricepand accrued interestaiof a security with an odd first period and thesettlement date in the first period
Example Using this data:
Trang 21returns
p = 113.5977
ai = 0.5855
See Also acrubond, cfdates, prbond, proddfl, proddl, yldoddf
Reference Mayle, Standard Securities Calculation Methods, Volumes I-II, 3rd edition.
Formulas 8, 9
Trang 222-203
2proddfl
Purpose Price with odd first and last periods and settlement in first period
Syntax [p, ai] = proddfl(sd, md, id, fd, lcd, rv, cpn, yld, per, basis)
[p, ai] = proddfl(sd, md, id, fd, lcd, rv, cpn, yld, per)[p, ai] = proddfl(sd, md, id, fd, lcd, rv, cpn, yld)
Arguments sd Settlement date Enter as serial date number or date string sdmust
be earlier than or equal tomd
md Maturity date Enter as serial date number or date string
id Issue date Enter as serial date number or date string
fd First coupon date Enter as serial date number or date string
lcd Last coupon date Enter as serial date number or date string
rv Redemption (par, face) value
cpn Coupon rate Enter as decimal fraction
yld Yield Enter as decimal fraction
per Coupons per year An integer Default =2
2= actual/360,3= actual/365
Description [p, ai] = proddfl(sd, md, id, fd, lcd, rv, cpn, yld, per, basis)
returns the pricepand accrued interestaiof a security with odd first and lastperiods and the settlement date in the first period
Trang 23ai = 0.1556
See Also acrubond, cfdates, prbond, proddf, proddl, yldbond, yldoddfl
Reference Mayle, Standard Securities Calculation Methods, Volumes I-II, 3rd edition.
Formulas 16, 17, 18, 19
Trang 242-205
2proddl
Purpose Price with odd last period
Syntax [p, ai] = proddl(sd, md, lcd, rv, cpn, yld, per, basis)
[p, ai] = proddl(sd, md, lcd, rv, cpn, yld, per)[p, ai] = proddl(sd, md, lcd, rv, cpn, yld)
Arguments sd Settlement date Enter as serial date number or date string sdmust
be earlier than or equal tomd
md Maturity date Enter as serial date number or date string
lcd Last coupon date Enter as serial date number or date string
rv Redemption (par, face) value
cpn Coupon rate Enter as decimal fraction
yld Yield Enter as decimal fraction
per Coupons per year An integer Default =2
2= actual/360,3= actual/365
Description [p, ai] = proddl(sd, md, lcd, rv, cpn, yld, per, basis) returns the
pricepand accrued interestaiof a security with odd last period
Example Using this data:
Trang 25returns
p = 100.5411
ai = 0.0542
See Also acrubond, cfdates, prbond, proddf, proddfl, yldoddl
Reference Mayle, Standard Securities Calculation Methods, Volumes I-II, 3rd edition.
Formulas 11, 13, 14, 15
Trang 262-207
2prtbill
Purpose Price of Treasury bill
Syntax p = prtbill(sd, md, rv, disc)
Arguments sd Settlement date Enter as serial date number or date string sdmust
be earlier than or equal tomd
md Maturity date Enter as serial date number or date string
rv Redemption (par, face) value
disc Discount rate of the Treasury bill Enter as decimal fraction
Description p = prtbill(sd, md, rv, disc) returns the pricepfor a Treasury bill
Example The settlement date of a Treasury bill is February 10, 1992, the maturity date
is August 6, 1992, the discount rate is 3.77%, and the par value is $1000 Usingthis data:
p = prtbill('2/10/1992', '8/6/1992', 1000, 0.0377)
returns
p = 981.3594
See Also beytbill, yldtbill
Reference Bodie, Kane, and Marcus, Investments, pages 41-43.