function fin_con

% FIN_CON Show the help for the functions in this toolbox.

% This file is automatically generated.  Matthew Simoneau, 09-04-98
% Copyright (c) 1984-98 by The MathWorks, Inc. All Rights Reserved
% $Revision: 1.14 $ $Date: 1998/10/16 23:19:17 $

helpwin('fin_con/Contents');

function Contents
%MATLAB Tour Partial Function Help:  fin_con
%
%Double click on any function for more information
%
%  Financial Toolbox.
%  Version 2.0.1 (R11)       14-Aug-1998
% 
%  Help and Documentation
%    Readme      - Release notes for the Financial Toolbox.
%    ftb         - Argument help headers.
%    calendar    - Contents of financial calendar functions
%    findemos    - Contents of financial demonstration functions
% 
%  Currency formatting.
%    cur2frac    - Decimal currency values to fractional values.
%    cur2str     - Bank formatted text.
%    frac2cur    - Fractional currency values to decimal values.
%    
%  Charts.
%    bolling     - Bollinger Band chart.
%    candle      - Candlestick chart.
%    dateaxis    - Date axis labels.
%    pointfig    - Point and figure chart.
%    highlow     - High, low, open, close chart.
%    movavg      - Leading and lagging moving averages chart.
%    
%  Present and Future Value.
%    pvfix       - Present value with fixed periodic payments.
%    pvvar       - Present value of varying cash flow.
%    fvfix       - Future value with fixed periodic payments.
%    fvvar       - Future value of varying cash flow.
%    fvdisc      - Future value of discounted security.
%    
%  Annuities.
%    annurate    - Periodic interest rate of annuity.
%    annuterm    - Number of periods to obtain value.
%    
%  Accrued interest.
%    acrubond    - Accrued interest of security with periodic interest payments.
%    acrudisc    - Accrued interest of security paying at maturity.
%    
%  Prices.
%    bndprice    - Price of an SIA standard fixed income security.
%    prbond      - Price with regular periodic interest payments.
%    prmat       - Price with interest at maturity.
%    proddf      - Price with odd first period.
%    proddfl     - Price with odd first and last periods and settlement in first
%                  period.
%    proddl      - Price with odd last period.
%    prtbill     - Price of treasury bill.
%    prdisc      - Price of discounted security.
%    
%  Term Structure of Interest Rates.
%    disc2zero   - Zero curve given a discount curve.
%    fwd2zero    - Zero curve given a forward curve.
%    pyld2zero   - Zero curve given a par yield curve.
%    termfit     - Term structure fitting with Splines Toolbox (demonstration).
%    tbl2bond    - Format treasury bill data.
%    tr2bonds    - Format treasury bond data.
%    zbtprice    - Bootstrap zero rate curve from market bond prices.
%    zbtyield    - Bootstrap zero rate curve from market bond yields.
%    zero2disc   - Discount curve given a zero curve.
%    zero2fwd    - Forward curve given a zero curve.
%    zero2pyld   - Par yield curve given a zero curve.
% 
%  Yields.
%    bndyield    - Yield of an SIA standard fixed income security.
%    beytbill    - Bond equivalent yield for treasury bill.
%    discrate    - Discount rate of a security.
%    yldbond     - Yield with regular periodic interest payments.
%    yldmat      - Yield with interest at maturity.
%    yldoddf     - Yield with odd first period.
%    yldoddfl    - Yield with odd first and last periods and settlement in first
%                  period.
%    yldoddl     - Yield with odd last period.
%    yldtbill    - Yield of treasury bill.
%    ylddisc     - Yield of discounted security.
%    
%  Rates of return.
%    effrr       - Effective rate of return.
%    irr         - Internal rate of return.
%    mirr        - Modified internal rate of return.
%    nomrr       - Nominal rate of return.
%    taxedrr     - After-tax rate of return.
%    xirr        - Internal rate of return for nonperiodic cash flow.
%    
%  Payment calculations.
%    payadv      - Periodic payment given number of advance payments.
%    payodd      - Payment of annuity with odd first period.
%    payper      - Periodic payment of loan or annuity.
%    payuni      - Uniform payment equal to varying cash flow.
%    
%  Interest rate sensitivities.
%    bnddurp     - Duration of an SIA standard security from price. 
%    bnddury     - Duration of an SIA standard security from yield.
%    bndconvp    - Convexity of an SIA standard security from price.
%    bndconvy    - Convexity of an SIA standard security from yield.
%    bondconv    - Convexity.
%    bonddur     - Macauley and modified durations.
%    cfconv      - Cash flow convexity and volatility.
%    cfdur       - Cash flow duration and modified duration.
%    
%  Amortization and Depreciation.
%    amortize    - Amortization.
%    depfixdb    - Fixed declining-balance depreciation.
%    depgendb    - General declining-balance depreciation.
%    deprdv      - Remaining depreciable value.
%    depsoyd     - Sum of years' digits depreciation.
%    depstln     - Straight line depreciation.
%      
%  Option valuation and sensitivity.
%    bdtbond     - Black-Derman-Toy bond option pricing.
%    bdttrans    - Translate and plot Black-Derman-Toy option trees.
%    binprice    - Binomial put and call pricing.
%    blkprice    - Black's option pricing.
%    blsdelta    - Black-Scholes sensitivity to underlying price change.
%    blsgamma    - Black-Scholes sensitivity to underlying delta change.
%    blsimpv     - Black-Scholes implied volatility.
%    blslambd    - Black-Scholes elasticity.
%    blsprice    - Black-Scholes put and call values.
%    blsrho      - Black-Scholes sensitivity to interest rate change.
%    blstheta    - Black-Scholes sensitivity to time to maturity change.
%    blsvega     - Black-Scholes sensitivity to underlying price volatility.
%    opprofit    - Option profit.
%    
%  Volatility analysis (ARCH/GARCH)
%    ugarch      - Univariate ARCH/GARCH parameter estimation.
%    ugarchllf   - Log-likelihood function of univariate GARCH parameters.
%    ugarchpred  - Forecast volatility based on a univariate GARCH process.
%    ugarchsim   - Simulate a univariate GARCH process.
% 
%  Portfolio analysis.
%    cov2corr    - Convert covariance to standard deviation and correlation.
%    corr2cov    - Convert standard deviation and correlation to covariance.
%    ewstats     - Asset return and covariance estimation.
%    portsim     - Simulate multi-asset return time series.
%    ret2tick    - Asset return time series to price series.
%    tick2ret    - Asset price time series to return series.
%    frontcon    - Efficient frontier with basic constraints.
%    portalloc   - Capital allocation.
%    portopt     - Efficient frontier with arbitrary constraint set.
%    portcons    - Specify constraints on portfolio.
%    pcalims     - Portfolio asset allocation bounds.
%    pcglims     - Portfolio asset group allocation bounds.
%    pcgcomp     - Portfolio group to group composition bounds.
%    pcpval      - Portfolio total value.
%    portrand    - Randomized portfolio risks, returns and weights.
%    portstats   - Portfolio risk and expected rate of return.
%    portvrisk   - Portfolio value at risk.
% 
%  ============== Financial calendar functions (help calendar) ==============
% 
%  Current Time And Date.
%    today       - Current date.
%    
%  Date and Time Components and Formats.
%    datefind    - Indices of date numbers in matrix.
%    day         - Day of month.
%    eomdate     - Last date of month.
%    hour        - Hour of date or time.
%    lweekdate   - Date of last occurrence of weekday in month.
%    minute      - Minute of date or time.
%    month       - Month of date.
%    months      - Number of whole months between dates.
%    m2xdate     - MATLAB date to Excel date.
%    nweekdate   - Date of specific occurrence of weekday in month.
%    second      - Second of date or time.
%    x2mdate     - Excel date to MATLAB date.
%    year        - Year of date.
%    yeardays    - Number of days in year.
%    
%  Financial dates.
%    busdate     - Next or previous business day.
%    datemnth    - Date of day in future or past month.
%    datewrkdy   - Date of future or past workday.
%    days360     - Days between dates based on 360 day year.
%    days365     - Days between dates based on 365 day year.
%    daysdif     - Days between dates for any day count basis.
%    daysact     - Days between dates based on actual year.
%    fbusdate    - First business date of month.
%    holidays    - Holidays and non-trading days.
%    isbusday    - True for dates that are business days.
%    lbusdate    - Last business date of month.
%    wrkdydif    - Number of working days between dates.
%    yearfrac    - Fraction of  year between dates.
%    
%  Coupon bond dates.
%    accrfrac    - Accrued interest coupon period fraction.
%    cfamounts   - Cash flow amounts for a security.
%    cfdates     - Cash flow dates for a security.
%    cftimes     - Cash flow time factors for a security.
%    cpncount    - Coupons payable between dates.
%    cpndaten    - Next coupon date after date.
%    cpndatenq   - Next quasi-coupon date after date.
%    cpndatep    - Previous coupon date before date.
%    cpndatepq   - Previous quasi-coupon date before date.
%    cpndaysn    - Number of days between date and next coupon date.
%    cpndaysp    - Number of days between date and previous coupon date.
%    cpnpersz    - Size in days of period containing date.
% 
%   If the previous text just scrolled off your screen, try:
%       more on, help finance, more off
%-------------------------------------------
%
%  Financial Toolbox demonstration functions.
%  
%  Financial charting and display.
%    finchart     - Financial Expo financial charts.  
%    charhelp     - Help for financial charts demonstration.
%    timeser      - Convert XData of time series plot to correct date values.
%    cfplot       - Visualize sets of cash flows.
%    dtaxis       - Sync axis date ticks to plot data.
%    datedisp     - Display a matrix containing date number entries.
%  
%  Option demonstrations.
%    blsdemos     - Gateway to option pricing, hedging, and implied volatility.
%    oneopt       - Option pricing and sensitivities.
%    payoff       - Option portfolio hedging.
%    smile        - Implied volatility from option prices.
%    advgreek     - Financial Expo option portfolio sensitivities.
%    greekdem     - Financial Expo single option sensitivities.
%    seoption     - Calculates sensitivity measures of portfolio of options.
%  
%  Portfolio optimization demonstrations and functions
%    capaldemo    - Capital allocation demo
%    optport      - Portfolio optimization demonstration.
%    portopt.xls  - Excel spreadsheet for portfolio optimization.
%    frontier     - Efficient frontier.
%    portrand     - Randomized portfolio risks, returns and weights.
%    portror      - Portfolio expected rate of return.
%    portvar      - Portfolio variance.
%  
%  Spline Smoothing demonstration.
%    termfit      - Demo function for smoothing rates with splines.
% 
%  Black-Derman-Toy
%    bdtdemo      - Bond option valuation GUI.
%    plotbintree  - Plot a binary tree.
% 
%  GARCH
%    garchgui     - GARCH process simulation and forecasting.
%    ugarchplot   - Plot volatility against time series.
% 
%  Genetic Algorithm demonstration
%    degatool     - Genetic algorithm to optimize a function.
% 
%  Time series object demonstration functions and demos.
%    alltsdemo    - Financial Time Series Demo Wizard.
%    fintsdemo    - Financial Time Series Demo (called by ALLTSDEMO).
% 
%  Time series creation, conversion, and data handling.
%    demtseries   - Create a time series object.
%                 
%    constant     - Create a time series constant.
%    celldec      - Decode cell array of chart data.
%    cellenc      - Encode cell array of chart data.
%    sprmtrx      - Spreadsheet matrix creates a matrix with a column of dates.
%                 
%    tod          - Converts series to Daily type
%    todc         - Converts series to Daily type continuous including weekends
%    tohy         - Converts time series to Half-Yearly type        
%    tom          - Converts time series to Monthly type
%    toq          - Converts time series to Quarterly type
%    tow          - Converts time series to Weekly type
%    tox          - Conversion to specified type, x"      
%    toy          - Converts time series to Yearly type
% 
%    fstvalue     - Gets the first value in the time series 
%    dateft       - First and last dates of data
%    getend       - Gets the last date in the time series   
%    getfreq      - Gets the frequency class of a time series
%    getstart     - Gets the first date in the time series  
%    getstop      - Wrapper for GETEND; Gets the last date in the time series
%    getname      - Get the name of the time series 
%    val          - Get the values and dates in the time series as a vector 
%                 
%  Time series indexing, dates and sorting                
%    append       - Append one time series to another       
%    clcutts      - Cuts time series according to date settings      
%    cutts        - Cuts time series according to date settings; GUI version
%    windowts     - Restricts time series according to a global window
%    lag          - Lag time series by n periods    
%    lastvalue    - Gets the last value in the time series  
%    lead         - Lead time series by n periods   
% 
%    sunion       - Union of 2 sorted vectors       
%    sunique      - Uniques of a sorted vector      
%    dtunion      - Returns union of dates 
%                 
%    fridays      - Generates a vector of Fridays   
%    datenumuk    - Converts ukdate format to a datenum number      
%    uk2usa       - Converts date string format #2 UK to USA format 
%    usa2uk       - Converts date string format #2 USA to UK format 
%    weekdays     - Creates a vector of working days from start to stop dates
%                 
%  Time series display and plotting
%    display      - Command window display of a time series data    
%    barstck      - Plot stacked bar chart of time series data      
%    barts        - Plot bar chart of time series data      
%    plotts       - Plot time series data   
%    semilogy     - Plot time series on a log scale
%    ssplot       - Plot time series data; it adds title automatically      
%    stairs       - Stairstep plot for time series data     
%                 
%  Time series analysis
%    annav        - Calculate the mean of the time series over each year    
%    apch         - Annualized percentage change    
%    arith        - Sets up the date vector for basic arithmetic    
%    arithtrend   - Calculate linear trend for a time series        
%    del          - Calculate the absolute change over n periods    
%    devtrend     - Calculate the deviation from linear or log trend        
%    dfl          - Deflate one time series by another
%    dfmt         - Deviation from the moving trend
%    dfmtrend     - Centered DFMT ignoring crossover
%    exp          - Natural exponential function for the time series        
%    evenlma      - Even Linma Weights Calculator   
%    hender       - Creates a Henderson weighted moving average     
%    index        - Index a time series to a specified base date    
%    interpt      - Fast vector interpolation for use with the time series  
%    linma        - Create a linearly weighted moving average       
%    filter       - Downsample time series
%    flatma       - Linearly weighted moving average, flat end conditions
%    log          - Natural Logarithm for time series       
%    log10        - Logarithm Base 10 for time series       
%    log2         - Logarithm Base 2 for time series        
%    ma           - Creates a matrix for a weighted moving average       
%    max          - Max of time series
%    mav          - Calculates the moving average of a time series  
%    meants       - Calculates the mean of a time series between 2 dates    
%    min          - Min of time series
%    mt           - Moving trend 
%    percnt       - Period percentage change        
%    qoq3m        - 3 month on 3 month change for time series       
%    quadma       - Creates a quadratic weighted moving average     
%    sd           - Calculates Standard Deviation of a time series  
%    seas         - Seasonal adjustment     
%    seas2        - Seasonal adjustment; additive method    
%    trend        - Calculates logarithmic trend for a time series  
%    yoy          - Implements year on year percentage change       
%    zohts        - Zero-order hold for time series data    
%                  
%  Time series arithmetic implementation in @demtseries
%    minus        - Implements ts1 - ts2 for time series    
%    mpower       - Implements ts ^ p for time series       
%    mrdivide     - Implements ts1 / ts2 for time series    
%    mtimes       - Implements ts1 * ts2 for time series    
%    plus         - Implements ts1 + ts2 for time series    
%    power        - Implements ts .^ p for time series      
%    rdivide      - Implements ts1 ./ ts2 for time series   
%    times        - Implements ts1 .* ts2 for time series   
%    uminus       - Implements -ts for time series  
%    uplus        - Implements +ts for time series  
% 
%  Tutorial example files.
%    ftgex1       - Financial Toolbox graphics example 1.
%    ftgex2       - Financial Toolbox graphics example 2.
%    ftgex3       - Financial Toolbox graphics example 3.
%    ftspex1      - Financial Toolbox solving problems example 1.
%    ftspex2      - Financial Toolbox solving problems example 2.
%    ftspex3      - Financial Toolbox solving problems example 3.
%    ftspex4      - Financial Toolbox solving problems example 4.
% 
%-------------------------------------------
%
%  Financial Toolbox calendar functions.
% 
%  Current Time And Date.
%    today       - Current date.
%    
%  Date and Time Components and Formats.
%    datefind    - Indices of date numbers in matrix.
%    day         - Day of month.
%    eomdate     - Last date of month.
%    hour        - Hour of date or time.
%    lweekdate   - Date of last occurrence of weekday in month.
%    minute      - Minute of date or time.
%    month       - Month of date.
%    months      - Number of whole months between dates.
%    m2xdate     - MATLAB date to Excel date.
%    nweekdate   - Date of specific occurrence of weekday in month.
%    second      - Second of date or time.
%    x2mdate     - Excel date to MATLAB date.
%    year        - Year of date.
%    yeardays    - Number of days in year.
%    
%  Financial dates.
%    busdate     - Next or previous business day.
%    datemnth    - Date of day in future or past month.
%    datewrkdy   - Date of future or past workday.
%    days360     - Days between dates based on 360 day year.
%    days365     - Days between dates based on 365 day year.
%    daysdif     - Days between dates for any day count basis.
%    daysact     - Days between dates based on actual year.
%    fbusdate    - First business date of month.
%    holidays    - Holidays and non-trading days.
%    isbusday    - True for dates that are business days.
%    lbusdate    - Last business date of month.
%    wrkdydif    - Number of working days between dates.
%    yearfrac    - Fraction of  year between dates.
%    
%  Coupon bond dates.
%    accrfrac    - Accrued interest coupon period fraction.
%    cfamounts   - Cash flow amounts for a security.
%    cfdates     - Cash flow dates for a security.
%    cftimes     - Cash flow time factors for a security.
%    cpncount    - Coupons payable between dates.
%    cpndaten    - Next coupon date after date.
%    cpndatenq   - Next quasi-coupon date after date.
%    cpndatep    - Previous coupon date before date.
%    cpndatepq   - Previous quasi-coupon date before date.
%    cpndaysn    - Number of days between date and next coupon date.
%    cpndaysp    - Number of days between date and previous coupon date.
%    cpnpersz    - Size in days of period containing date.
% 
%

function Readme
%MATLAB Tour Partial Function Help:  fin_con
%
%  Release Notes, Financial Toolbox.
%  Version 2.0.1 (R11)        14-Aug-1998
% 
%  This Readme.m file lists new features, enhancements, and fixes in the
%  Financial Toolbox.
% 
%  WHAT'S NEW IN FINANCIAL 2.0 (Release 11)
%    The portfolio analysis and optimization functions now support
%    constraints on portfolios, compute asset allocation, and allow a more
%    flexible specification of asset expected returns and covariance.
% 
%    Functions are available for handling asset time series, including
%    conversions between return and price series, expected return and
%    covariance computation, and Monte Carlo simulation.
% 
%    Functions for performing univariate ARCH/GARCH analysis are
%    available.  Parameter estimation, volatility forecasting, and
%    simulation are possible for a GARCH process with Gaussian residuals.
% 
%    Financial toolbox now includes a demonstration time series
%    object.  It has an example implementation of an interface to a
%    charting and analysis package.  Approximately 80 functions and
%    overloaded methods are included.
% 
%    The Black-Derman-Toy model for valuing bond options is
%    included.  The function builds a recombining binary tree from
%    input rate curve, volatility curve, and credit spread.
% 
%    Coupon functions now handle the SIA conventions for bonds with possible
%    odd first and last coupon periods.  The functions also return an
%    expanded set of coupon parameters including lists of cash flow dates and
%    amounts, accrued interest, and time factors.  Description of common
%    function arguments has been moved to separate help files.
%    
% 
%  NEW AND ENHANCED FUNCTIONS FOR 2.0 (Release 11)
%    Functions are listed with the first toolbox version in which they shipped.
%    
%    bndprice   - 2.0 Price of an SIA standard fixed income security
%    bndyield   - 2.0 Yield of an SIA standard fixed income security
%    bnddurp    - 2.0 Duration of an SIA standard fixed income security
%    bnddury    - 2.0 Duration of an SIA standard fixed income security
%    bndconvp   - 2.0 Convexity of an SIA standard fixed income security
%    bndconvy   - 2.0 Convexity of an SIA standard fixed income security
%              
%    bdtbond    - 2.0 Black-Derman-Toy bond option pricing
%    bdttrans   - 2.0 Translate and plot Black-Derman-Toy option trees
% 
%    ugarch     - 2.0 Univariate ARCH/GARCH parameter estimation.
%    ugarchllf  - 2.0 Log-likelihood function of univariate GARCH parameters
%    ugarchpred - 2.0 Forecast volatility based on a univariate GARCH process
%    ugarchsim  - 2.0 Simulate a univariate GARCH process
% 
%    cov2corr   - 2.0 Convert covariance to standard deviation and correlation.
%    corr2cov   - 2.0 Convert standard deviation and correlation to covariance.
%    ewstats    - 2.0 Asset return and covariance estimation.
%    portsim    - 2.0 Simulate multi-asset return time series.
%    ret2tick   - 2.0 Asset return time series to price series.
%    tick2ret   - 2.0 Asset price time series to return series.
%    frontcon   - 2.0 Efficient frontier with basic constraints.
%    portalloc  - 2.0 Capital allocation.
%    portopt    - 2.0 Efficient frontier with arbitrary constraint set.
%    portcons   - 2.0 Specify constraints on portfolio.
%    pcalims    - 2.0 Portfolio asset allocation bounds.
%    pcglims    - 2.0 Portfolio asset group allocation bounds.
%    pcgcomp    - 2.0 Portfolio group to group composition bounds.
%    pcpval     - 2.0 Portfolio total value.
%    portstats  - 2.0 Portfolio risk and expected rate of return.
%    portvrisk  - 2.0 Portfolio value at risk.
%  
%    accrfrac   - 1.1 Accrued interest coupon period fraction.
%    cfamounts  - 2.0 Cash flow amounts for a security.
%    cfdates    - 1.1 Cash flow dates for a security.
%    cftimes    - 2.0 Cash flow time factors for a security.
%    cpncount   - 1.0 Coupons payable between dates.
%    cpndaten   - 1.0 Next coupon date after date.
%    cpndatep   - 1.0 Previous coupon date before date.
%    cpndatenq  - 2.0 Next quasi-coupon date after date.
%    cpndatepq  - 2.0 Previous quasi-coupon date before date.
%    cpndaysn   - 1.0 Number of days between date and next coupon date.
%    cpndaysp   - 1.0 Number of days between date and previous coupon date.
%    cpnpersz   - 1.0 Size in days of period containing date.
% 
%  NEW DEMO FUNCTIONS FOR 2.0 (Release 11)
%    blsdemos   - 2.0 Option pricing, hedging, and implied volatility GUI.
%    oneopt     - 2.0 Option pricing and sensitivities.
%    payoff     - 2.0 Option portfolio hedging.
%    smile      - 2.0 Implied volatility from option prices.
%    capaldemo  - 2.0 Capital allocation demo GUI.
%    bdtdemo    - 2.0 Bond option valuation GUI.
%    degatool   - 2.0 Genetic algorithm demonstration GUI.
%   plotbintree - 2.0 Plot a binary tree.
%    cfplot     - 2.0 Visualize sets of cash flows.
%    dtaxis     - 2.0 Sync axis date ticks to plot data.
%    datedisp   - 2.0 Display a matrix containing date number entries.
%    garchgui   - 2.0 GARCH process simulation and forecasting.
%    ugarchplot - 2.0 Plot volatility against time series.
% 
%    alltsdemo  - 2.0 Demo creating and manipulating a time series object
%    
%    @demtseries  2.0 Demo time series method directory
%    celldec    - 2.0 Demo time series support
%    cellenc    - 2.0 Demo time series support
%    datenumuk  - 2.0 Demo time series support
%    evenlma    - 2.0 Demo time series support
%    fridays    - 2.0 Demo time series support
%    interpt    - 2.0 Demo time series support
%    sunion     - 2.0 Demo time series support
%    sunique    - 2.0 Demo time series support
%    uk2usa     - 2.0 Demo time series support
%    usa2uk     - 2.0 Demo time series support
%    weekdays   - 2.0 Demo time series support
% 
%  MAJOR FIXES IN 2.0 (Release 11)
%    Coupon functions - Whole period errors in coupon dates in leap years or 
%    when settlement falls on a coupon date have been corrected.  Coupon 
%    period size is now correctly returned for Basis = 2 (actual/360).
% 
%    Portfolio analysis - A bug in ewcov which understated covariance values
%    when the decay factor was less than 1 has been corrected.  
%  
%  DEPRECATED FUNCTIONS FOR 2.0 (Release 11)
%    These functions are moved to demos status.  They may be removed
%    in a future release.
% 
%    frontier    - use frontcon or portopt with ewstats
%    ewcov       - use ewstats
%    portror     - use portstats with ewstats
%    portvar     - use portstats with ewstats
%    
%    tmfactor    - Release 11 Beta function replaced by cftimes
%    
% ---------------------------------------------------------------------------
%  NEW AND ENHANCED FUNCTIONS FOR 1.1 (Release 10)
%    Functions are listed with the first toolbox version in which they shipped.
% 
%    disc2zero   - 1.1 Zero curve given a discount curve.
%    fwd2zero    - 1.1 Zero curve given a forward curve.
%    pyld2zero   - 1.1 Zero curve given a par yield curve.
%    tbl2bond    - 1.1 Format treasury bill data.
%    tr2bonds    - 1.1 Format treasury bond data.
%    zbtprice    - 1.1 Bootstrap zero rate curve from market bond prices.
%    zbtyield    - 1.1 Bootstrap zero rate curve from market bond yields.
%    zero2disc   - 1.1 Discount curve given a zero curve.
%    zero2fwd    - 1.1 Forward curve given a zero curve.
%    zero2pyld   - 1.1 Par yield curve given a zero curve.
%    blkprice    - 1.1 Black's option pricing.
% 
%  NEW DEMO FUNCTIONS FOR 1.1 (Release 10)
%    termfit     - 1.1 Spline smoothing of interest term structure
%    portopt.xls - 1.1 Excel interface to portfolio optimization
% 
%  Use the HELP for any of these files for further information

function ftb
%MATLAB Tour Partial Function Help:  fin_con
%
% FTB Financial Toolbox argument help listings
%  Type "help ftpARGUMENT" for help on an argument or term named ARGUMENT.
%  The following help is available:
% 
%  Coupon structure specification
%    ftbSettle              -  Settlement date
% 
%    ftbMaturity            -  Maturity date
%    ftbIssueDate           -  Issue date
%    ftbStartDate           -  Forward starting date of instrument
%    ftbFirstCouponDate     -  First coupon date
%    ftbLastCouponDate      -  Last coupon date
% 
%    ftbPeriod              -  Number of payments per year in market
%    ftbBasis               -  Market basis, e.g. 2 = actual/360
%    ftbEndMonthRule        -  Market end of month rule
% 
%  Bond amount specification
%    ftbCouponRate          -  Coupon rate
%    ftbFace                -  Face value
% 
%  Coupon payment lists
%    ftbCFlowAmounts        -  Amount of cash flow
%    ftbCFlowDates          -  Date of cash flow
%    ftbTFactors            -  Time factor from settlement
%    ftbCFlowFlags          -  Type and context of payment
% 
%  Individual instrument amount and yield parameters
%    ftbAccrfrac            -  Fraction of a coupon payment owed as accrued int.
% 
%  Individual instrument date parameters
%    ftbNumCouponsRemaining -  Number of coupons remaining to maturity
%    ftbNextCouponDate      -  Date of next coupon payment
%    ftbPreviousCoupondate  -  Date of previous or current payment
%    ftbNumDaysPeriod       -  Number of days in current coupon period
%    ftbNumDaysNext         -  Number of days to next payment
%    ftbNumDaysPrevious     -  Number of days since current payment
%  

function calendar
%MATLAB Tour Partial Function Help:  fin_con
%
%  Financial Toolbox calendar functions.
% 
%  Current Time And Date.
%    today       - Current date.
%    
%  Date and Time Components and Formats.
%    datefind    - Indices of date numbers in matrix.
%    day         - Day of month.
%    eomdate     - Last date of month.
%    hour        - Hour of date or time.
%    lweekdate   - Date of last occurrence of weekday in month.
%    minute      - Minute of date or time.
%    month       - Month of date.
%    months      - Number of whole months between dates.
%    m2xdate     - MATLAB date to Excel date.
%    nweekdate   - Date of specific occurrence of weekday in month.
%    second      - Second of date or time.
%    x2mdate     - Excel date to MATLAB date.
%    year        - Year of date.
%    yeardays    - Number of days in year.
%    
%  Financial dates.
%    busdate     - Next or previous business day.
%    datemnth    - Date of day in future or past month.
%    datewrkdy   - Date of future or past workday.
%    days360     - Days between dates based on 360 day year.
%    days365     - Days between dates based on 365 day year.
%    daysdif     - Days between dates for any day count basis.
%    daysact     - Days between dates based on actual year.
%    fbusdate    - First business date of month.
%    holidays    - Holidays and non-trading days.
%    isbusday    - True for dates that are business days.
%    lbusdate    - Last business date of month.
%    wrkdydif    - Number of working days between dates.
%    yearfrac    - Fraction of  year between dates.
%    
%  Coupon bond dates.
%    accrfrac    - Accrued interest coupon period fraction.
%    cfamounts   - Cash flow amounts for a security.
%    cfdates     - Cash flow dates for a security.
%    cftimes     - Cash flow time factors for a security.
%    cpncount    - Coupons payable between dates.
%    cpndaten    - Next coupon date after date.
%    cpndatenq   - Next quasi-coupon date after date.
%    cpndatep    - Previous coupon date before date.
%    cpndatepq   - Previous quasi-coupon date before date.
%    cpndaysn    - Number of days between date and next coupon date.
%    cpndaysp    - Number of days between date and previous coupon date.
%    cpnpersz    - Size in days of period containing date.
% 
%
%
%calendar is both a directory and a function.
%
% CALENDAR Calendar.
%    CALENDAR or CALENDAR(DATE) or CALENDAR(YEAR,MONTH) is a 6-by-7
%    matrix containing a calendar for the current or specified month.
% 
%    The first column of the returned matrix corresponds to Sunday.
% 
%    

function findemos
%MATLAB Tour Partial Function Help:  fin_con
%
%  Financial Toolbox demonstration functions.
%  
%  Financial charting and display.
%    finchart     - Financial Expo financial charts.  
%    charhelp     - Help for financial charts demonstration.
%    timeser      - Convert XData of time series plot to correct date values.
%    cfplot       - Visualize sets of cash flows.
%    dtaxis       - Sync axis date ticks to plot data.
%    datedisp     - Display a matrix containing date number entries.
%  
%  Option demonstrations.
%    blsdemos     - Gateway to option pricing, hedging, and implied volatility.
%    oneopt       - Option pricing and sensitivities.
%    payoff       - Option portfolio hedging.
%    smile        - Implied volatility from option prices.
%    advgreek     - Financial Expo option portfolio sensitivities.
%    greekdem     - Financial Expo single option sensitivities.
%    seoption     - Calculates sensitivity measures of portfolio of options.
%  
%  Portfolio optimization demonstrations and functions
%    capaldemo    - Capital allocation demo
%    optport      - Portfolio optimization demonstration.
%    portopt.xls  - Excel spreadsheet for portfolio optimization.
%    frontier     - Efficient frontier.
%    portrand     - Randomized portfolio risks, returns and weights.
%    portror      - Portfolio expected rate of return.
%    portvar      - Portfolio variance.
%  
%  Spline Smoothing demonstration.
%    termfit      - Demo function for smoothing rates with splines.
% 
%  Black-Derman-Toy
%    bdtdemo      - Bond option valuation GUI.
%    plotbintree  - Plot a binary tree.
% 
%  GARCH
%    garchgui     - GARCH process simulation and forecasting.
%    ugarchplot   - Plot volatility against time series.
% 
%  Genetic Algorithm demonstration
%    degatool     - Genetic algorithm to optimize a function.
% 
%  Time series object demonstration functions and demos.
%    alltsdemo    - Financial Time Series Demo Wizard.
%    fintsdemo    - Financial Time Series Demo (called by ALLTSDEMO).
% 
%  Time series creation, conversion, and data handling.
%    demtseries   - Create a time series object.
%                 
%    constant     - Create a time series constant.
%    celldec      - Decode cell array of chart data.
%    cellenc      - Encode cell array of chart data.
%    sprmtrx      - Spreadsheet matrix creates a matrix with a column of dates.
%                 
%    tod          - Converts series to Daily type
%    todc         - Converts series to Daily type continuous including weekends
%    tohy         - Converts time series to Half-Yearly type        
%    tom          - Converts time series to Monthly type
%    toq          - Converts time series to Quarterly type
%    tow          - Converts time series to Weekly type
%    tox          - Conversion to specified type, x"      
%    toy          - Converts time series to Yearly type
% 
%    fstvalue     - Gets the first value in the time series 
%    dateft       - First and last dates of data
%    getend       - Gets the last date in the time series   
%    getfreq      - Gets the frequency class of a time series
%    getstart     - Gets the first date in the time series  
%    getstop      - Wrapper for GETEND; Gets the last date in the time series
%    getname      - Get the name of the time series 
%    val          - Get the values and dates in the time series as a vector 
%                 
%  Time series indexing, dates and sorting                
%    append       - Append one time series to another       
%    clcutts      - Cuts time series according to date settings      
%    cutts        - Cuts time series according to date settings; GUI version
%    windowts     - Restricts time series according to a global window
%    lag          - Lag time series by n periods    
%    lastvalue    - Gets the last value in the time series  
%    lead         - Lead time series by n periods   
% 
%    sunion       - Union of 2 sorted vectors       
%    sunique      - Uniques of a sorted vector      
%    dtunion      - Returns union of dates 
%                 
%    fridays      - Generates a vector of Fridays   
%    datenumuk    - Converts ukdate format to a datenum number      
%    uk2usa       - Converts date string format #2 UK to USA format 
%    usa2uk       - Converts date string format #2 USA to UK format 
%    weekdays     - Creates a vector of working days from start to stop dates
%                 
%  Time series display and plotting
%    display      - Command window display of a time series data    
%    barstck      - Plot stacked bar chart of time series data      
%    barts        - Plot bar chart of time series data      
%    plotts       - Plot time series data   
%    semilogy     - Plot time series on a log scale
%    ssplot       - Plot time series data; it adds title automatically      
%    stairs       - Stairstep plot for time series data     
%                 
%  Time series analysis
%    annav        - Calculate the mean of the time series over each year    
%    apch         - Annualized percentage change    
%    arith        - Sets up the date vector for basic arithmetic    
%    arithtrend   - Calculate linear trend for a time series        
%    del          - Calculate the absolute change over n periods    
%    devtrend     - Calculate the deviation from linear or log trend        
%    dfl          - Deflate one time series by another
%    dfmt         - Deviation from the moving trend
%    dfmtrend     - Centered DFMT ignoring crossover
%    exp          - Natural exponential function for the time series        
%    evenlma      - Even Linma Weights Calculator   
%    hender       - Creates a Henderson weighted moving average     
%    index        - Index a time series to a specified base date    
%    interpt      - Fast vector interpolation for use with the time series  
%    linma        - Create a linearly weighted moving average       
%    filter       - Downsample time series
%    flatma       - Linearly weighted moving average, flat end conditions
%    log          - Natural Logarithm for time series       
%    log10        - Logarithm Base 10 for time series       
%    log2         - Logarithm Base 2 for time series        
%    ma           - Creates a matrix for a weighted moving average       
%    max          - Max of time series
%    mav          - Calculates the moving average of a time series  
%    meants       - Calculates the mean of a time series between 2 dates    
%    min          - Min of time series
%    mt           - Moving trend 
%    percnt       - Period percentage change        
%    qoq3m        - 3 month on 3 month change for time series       
%    quadma       - Creates a quadratic weighted moving average     
%    sd           - Calculates Standard Deviation of a time series  
%    seas         - Seasonal adjustment     
%    seas2        - Seasonal adjustment; additive method    
%    trend        - Calculates logarithmic trend for a time series  
%    yoy          - Implements year on year percentage change       
%    zohts        - Zero-order hold for time series data    
%                  
%  Time series arithmetic implementation in @demtseries
%    minus        - Implements ts1 - ts2 for time series    
%    mpower       - Implements ts ^ p for time series       
%    mrdivide     - Implements ts1 / ts2 for time series    
%    mtimes       - Implements ts1 * ts2 for time series    
%    plus         - Implements ts1 + ts2 for time series    
%    power        - Implements ts .^ p for time series      
%    rdivide      - Implements ts1 ./ ts2 for time series   
%    times        - Implements ts1 .* ts2 for time series   
%    uminus       - Implements -ts for time series  
%    uplus        - Implements +ts for time series  
% 
%  Tutorial example files.
%    ftgex1       - Financial Toolbox graphics example 1.
%    ftgex2       - Financial Toolbox graphics example 2.
%    ftgex3       - Financial Toolbox graphics example 3.
%    ftspex1      - Financial Toolbox solving problems example 1.
%    ftspex2      - Financial Toolbox solving problems example 2.
%    ftspex3      - Financial Toolbox solving problems example 3.
%    ftspex4      - Financial Toolbox solving problems example 4.
% 

function cur2frac
%MATLAB Tour Partial Function Help:  fin_con
%
% CUR2FRAC Decimal currency values to fractional values. 
%        F = CUR2FRAC(P,D) converts decimal currency values 
%        to fractional values where P is the decimal currency  
%        value and D is the denominator of the fraction.   
%        F is returned as a string value. 
%  
%        For example, f = cur2frac(12.125,8) returns f = 12.1.  
%  
%        

function cur2str
%MATLAB Tour Partial Function Help:  fin_con
%
% CUR2STR Bank formatted text. 
%        T = CUR2STR(P,D) returns the given value in bank format 
%        where P is the value to be formatted and D is the number 
%        of significant digits.  A negative D rounds the value to  
%        the left of the decimal point.  Negative numbers are  
%        displayed in parenthesis and T is returned as a string. 
%        By default, D = 2. 
%  
%        For example, t = cur2str(-8264,2) returns t = ($8264.00). 
%   
%        

function frac2cur
%MATLAB Tour Partial Function Help:  fin_con
%
% FRAC2CUR Fractional currency values to decimal values. 
%        D = FRAC2CUR(P,F) converts a fractional currency value to a 
%        a decimal value where P is the fractional currency value and 
%        F is the denominator of the fraction.  For example, 
%        d = frac2cur('12.1',8) returns d = 12.125. P is entered as a 
%        string value. 
%  
%        

function bolling
%MATLAB Tour Partial Function Help:  fin_con
%
% BOLLING Bollinger Band chart. 
%        BOLLING(ASSET,SAMPLES,ALPHA) plots Bollinger bands for
%        given ASSET data.  SAMPLES specifies the number of samples to use in
%        computing the moving average.  ALPHA is the exponent used to compute
%        the element weights of the moving average.  It does not return any
%        data.
%        
%        [MAV,UBAND,LBAND] = BOLLING(ASSET,SAMPLES,ALPHA) returns MAV
%        with the moving average of the asset data, UBAND with the upper band
%        data, and LBAND with the lower band data.  It does not plot any data. 
%  
%        BOLLING(ASSET,20,1) plots linear 20-day moving average Bollinger  
%        Bands. 
%  
%        [MAV,UBAND,LBAND] = BOLLING(ASSET,20,1) returns the data used to  
%        plot the linear 20-day moving average Bollinger Bands without  
%        plotting the data. 
%  
%        

function candle
%MATLAB Tour Partial Function Help:  fin_con
%
% CANDLE Candlestick chart. 
% 	CANDLE(HI,LO,CL,OP,COLOR) plots a candlestick chart given
% 	the high HI, low LO, closing CL, and opening OP, prices of a security.
% 	If the closing price is greater than the opening price, the body (the
% 	region between the opening and closing price) is filled.  If the
% 	opening price is greater than the closing price, the body is empty.
% 	color specifies the candlestick color; enter it as a string.  MATLAB
% 	supplies a default color if none is specified.  The default color
% 	differs depending on the background color of the figure window.  See
% 	COLORSPEC in the MATLAB Reference Guide for color names.
%  
% 	

function dateaxis
%MATLAB Tour Partial Function Help:  fin_con
%
% DATEAXIS Date axis labels. 
% 	DATEAXIS(AKSIS,DATEFORM,STARTDATE) replaces axis 
% 	tick labels with date labels.  AKSIS determines which 
% 	axis tick labels, X, Y, or Z, should be converted.  The 
% 	default AKSIS argument is 'x'.  DATEFORM specifies which  
% 	date format to use.  If no DATEFORM argument is entered, 
% 	this function determines the date format based on the span 
% 	of the axis limits.   For example, if the difference  
% 	between the axis minimum and maximum is less than 15, the 
% 	tick labels will be converted to 3 letter day of the week 
% 	abbreviations.  STARTDATE determines which date should be 
% 	assigned to the first axis tick value.  The tick values 
% 	are treated as serial date numbers.  The default STARTDATE 
% 	is the lower axis limit converted to the appropriate date 
% 	value.  For example, a tick value of 1 is converted to the 
% 	date 01-Jan-0000.  By entering STARTDATE as '06-Apr-1995', 
% 	the first tick value is assigned the date April 6, 1995 and 
% 	the axis tick labels will be set accordingly. 
%       
%        DATEFORM    Format                Description 
%  
%           0        01-Mar-1995 15:45:17  (day-month-year, hour:minute) 
%           1        01-Mar-1995           (day-month-year) 
%           2        03/01/95              (month/day/year) 
%           3        Mar                   (month, three letter) 
%           4        M                     (month, single letter) 
%           5        3                     (month) 
%           6        03/01                 (month/day) 
%           7        1                     (day of month) 
%           8        Wed                   (day of week, three letter) 
%           9        W                     (day of week, single letter) 
%           10       1995                  (year, four digit) 
%           11       95                    (year, two digit) 
%           12       Mar95                 (month year) 
%           13       15:45:17              (hour:minute:second) 
%           14       03:45:17              (hour:minute:second AM or PM) 
%           15       15:45                 (hour:minute) 
%           16       03:45 PM              (hour:minute AM or PM) 
%  
% 	DATEAXIS('X') or DATEAXIS converts the X-axis labels to an 
% 	automatically determined date format. 
%  
% 	DATEAXIS('Y',6) converts the Y-axis labels to the 
% 	month/day format. 
%      
% 	DATEAXIS('X',2,'03/03/1995') converts the X-axis 
% 	labels to the month/day/year format.  The minimum Xtick  
% 	value is treated as March 3, 1995. 

function pointfig
%MATLAB Tour Partial Function Help:  fin_con
%
% POINTFIG Point and figure chart.
%        POINTFIG(ASSET) plots a point and figure chart for given data, ASSET.
%        Upward price movements are plotted as X's and downward price
%        movements are plotted as O's.
% 
%        

function highlow
%MATLAB Tour Partial Function Help:  fin_con
%
% HIGHLOW High, low, open, close chart.  
% 	HIGHLOW(HI,LO,CL,OP,COLOR) displays the high, low, opening,   
% 	and closing price of an asset.  Plots are vertical lines whose top is the high,
% 	bottom is the low, open is a left tick, and close is a right tick.  HI is the high 
% 	price of asset, LO is the low price of asset, CL is the closing price of asset,  
% 	OP is the opening price of asset, and COLOR is the line color.   
% 	MATLAB supplies a default color if none is specified.   The default color
% 	differs depending on the background color of the figure window.  See
% 	COLORSPEC in the MATLAB Reference Guide for COLOR names.
% 
% 	OP is optional.  To specify COLOR when OP is unknown, enter OP as an
% 	empty matrix, []. 
% 
% 	HIGHLOW(HI,LO,CL,OP,COLOR)  plots the figure and returns the handles
% 	H of the lines.  See the MATLAB User's Guide for information on Handle 
% 	Graphics.
%  
% 	For example, if the high, low, and closing prices for an asset are   
% 	stored in the vectors asseth, assetl, and assetc, respectively, the   
% 	High-Low-Close plot is displayed with the command  
% 	highlow(asseth,assetl,assetc).  
%   
% 	

function movavg
%MATLAB Tour Partial Function Help:  fin_con
%
% MOVAVG  Leading and lagging moving averages chart. 
%        [SHORT,LONG] = MOVAVG(ASSET,LEAD,LAG,ALPHA) plots leading  
%        and lagging moving averages.  ASSET is the security data,  
%        LEAD is the number of samples to use in leading average  
%        calculation, and LAG is the number of samples to use in the  
%        lagging average calculation.  ALPHA is the control parameter 
%        which determines what type of moving averages are calculated.   
%        ALPHA = 0 (default) corresponds to a simple moving average,  
%        ALPHA = 0.5 to a square root weighted moving average, ALPHA = 1  
%        to a linear moving average, ALPHA = 2 to a square weighted moving  
%        average, etc.  To calculate the exponential moving averages,  
%        let ALPHA = 'e'.  
%  
%        MOVAVG(ASSET,3,20,1) plots linear 3 sample leading and 20 sample  
%        lagging moving averages.   
%  
%        [SHORT,LONG] = MOVAVG(ASSET,3,20,1) returns the leading and lagging  
%        average data without plotting it. 
%  
%        

function pvfix
%MATLAB Tour Partial Function Help:  fin_con
%
% PVFIX Present value with fixed periodic payments. 
%        P = PVFIX(RATE,NPER,P,FV,DUE) returns the present  
%        value of a series of equal payments.  RATE is the  
%        periodic interest rate, NPER is the number of periods,  
%        P is the periodic payment, FV is a payment received  
%        other than P in the last period, and DUE specifies whether  
%        the payments are made at the beginning (DUE = 1) or end  
%        (DUE = 0) of the period.  The default arguments are  
%        FV = 0 and DUE = 0.   
%  
%        For example, a $200 payment is made monthly into  
%        a savings account earning 6%.  The payments are  
%        made at the end of the month for 5 years.  To  
%        calculate the present value of these payments,  
%        use pv = pvfix(.06/12,5*12,200,0,0) which returns  
%        pv = 10345.11. 
%       
%        

function pvvar
%MATLAB Tour Partial Function Help:  fin_con
%
% PVVAR  Present value of varying cash flow. 
%        PV = PVVAR(CF,RATE,DF) returns the net present value, PV, of a  
%        cash flow, CF, given the periodic interest rate, RATE.   
%        Include the initial investment as the initial cash flow value.   
%  
%        Suppose an initial investment of $10,000 is made.  The following  
%        cash flow represents the yearly income realized by the investment. 
%        The annual discount rate is 8%. 
%  
%                       Year 1       $2000 
%                       Year 2       $1500 
%                       Year 3       $3000 
%                       Year 4       $3800 
%                       Year 5       $5000 
%  
%        To calculate the net present value of the periodic cash flow,  
%        use pv = pvvar([-10000 2000 1500 3000 3800 5000],.08)  
%        which returns pv = 1715.39. 
%  
%        An investment of $10,000 returns the following series of cash flows. 
%        Note that the original investment payment is included as the first 
%        cash flow value. 
%  
%                      Cash Flow            Dates 
%                       -10000           January 12, 1987 
%                         2500           February 14, 1988 
%                         2000           March 3, 1988 
%                         3000           June 14, 1988 
%                         4000           December 1, 1988 
%  
%        The variables CF and DF are defined as follows and the discount rate 
%        is 9%. 
%  
%        cf = [-10000,2500,2000,3000,4000]; 
%               df = ['01/12/1987'
%                     '02/14/1988'
%                     '03/03/1988'
%                     '06/14/1988'
%                     '12/01/1988'];
%  
%        The net present value of the cash flow is pv = pvvar(cf,.09,df) or 
%        pv = 142.16. 
%  
%        

function fvfix
%MATLAB Tour Partial Function Help:  fin_con
%
% FVFIX  Future value with fixed periodic payments. 
%        F = FVFIX(RATE,NPER,P,PV,DUE) returns the future  
%        value of a series of equal payments.  RATE is the  
%        periodic interest rate, NPER is the number of periods,  
%        P is the periodic payment, PV is the initial value, and 
%        DUE specifies whether the payments are made at the beginning  
%        (DUE = 1) or end (DUE = 0) of the period.  By default, DUE = 0 
%        and PV = 0. 
%  
%        For example, a savings account has a starting balance  
%        of $1500.  $200 is added at the end of each month for  
%        10 years and the account pays 9% interest compounded  
%        monthly.  Using this data, f = fvfix(.09/12,12*10,200,1500,0)  
%        returns f = 42379.89. 
%  
%        

function fvvar
%MATLAB Tour Partial Function Help:  fin_con
%
% FVVAR  Future value of varying cash flow. 
%        FV = FVVAR(CF,RATE,DF) returns the future value, FV, of a 
%        varying cash flow payments, CF, given the periodic interest  
%        rate, RATE.  FV is the future value of the cash flow.  Include  
%        the initial investment as the initial cash flow value.  For  
%        non-periodic cash flows, DF is the vector dates at which the 
%        cash flows occur. 
%  
%        Suppose an initial investment of $10,000 is made.  The following  
%        cash flow represents the yearly income realized by the investment. 
%        The annual discount rate is 8%. 
%  
%                       Year 1       $2000 
%                       Year 2       $1500 
%                       Year 3       $3000 
%                       Year 4       $3800 
%                       Year 5       $5000 
%  
%        To calculate the future value of this periodic cash flow, use  
%        fv = fvvar([-10000 2000 1500 3000 3800 5000],.08)  
%        which returns fv = 2722.10.   
%  
%        An investment of $10,000 returns the following series of cash flows. 
%        Note that the original investment payment is included as the first 
%        cash flow value. 
%  
%                      Cash Flow            Dates 
%                       -10000           January 12, 1987 
%                         2500           February 14, 1988 
%                         2000           March 3, 1988 
%                         3000           June 14, 1988 
%                         4000           December 1, 1988 
%  
%        The variables CF and DF are defined as follows and the discount rate 
%        is 9%. 
%  
%        cf = [-10000,2500,2000,3000,4000]; 
%               df = ['01/12/1987'
%                     '02/14/1988'
%                     '03/03/1988'
%                     '06/14/1988'
%                     '12/01/1988'];
%  
%        The future value of the cash flow is fv = fvvar(cf,.09,df) or 
%        pv = 167.28. 
%  
%        

function fvdisc
%MATLAB Tour Partial Function Help:  fin_con
%
% FVDISC Future value of discounted security. 
%        RV = FVDISC(SD,MD,PRICE,DISC,BASIS) finds the amount
%        received at maturity RV for a fully vested security given the
%        settlement date SD, the maturity date MD, present value PRICE,
%        discount rate DISC, and day-count basis BASIS.  For BASIS, 0 =
%        actual/actual (default), 1 = 30/360, 2 = actual/360, 3 = actual/365.
%        Enter dates as serial date numbers or date strings. 
%  
%        Using the following data, 
%  
%        SD = '02/15/1991' 
%        MD = '05/15/1991' 
%        PRICE = 100 
%        DISC = .0575 
%        BASIS = 2 
%  
%        $101.44 is returned at maturity of the security. 
%  
%        

function annurate
%MATLAB Tour Partial Function Help:  fin_con
%
% ANNURATE Periodic interest rate of annuity.  
%        R = ANNURATE(NPER,P,PV,FV,DUE) returns the periodic   
%        interest rate paid of a loan or annuity.  NPER is the number of  
%        periods, P is the periodic payment, PV is the present value of the  
%        annuity, FV is the future value of the annuity, and DUE specifies  
%        whether the payments are made at the beginning (due = 1) or end (due =  
%        0) of the period.  The default values are fv = 0 and due = 0.  
%   
%        For example, to find the period interest rate of 4 year   
%        $5000 loan with $130 monthly payments made at the end of   
%        each month, use the command r = annurate(4*12,130,5000,0,0).    
%        The periodic interest rate returned in this example is r = .94%   
%        which, when multiplied by 12, gives an annual interest rate of   
%        11.3% on the loan.  
%   
%        

function annuterm
%MATLAB Tour Partial Function Help:  fin_con
%
% ANNUTERM Number of periods to obtain value.  
%        NPER = ANNUTERM(RATE,P,PV,FV,DUE) calculates the number of   
%        periods needed to obtain a future value.  RATE is the periodic  
%        interest rate, P is the periodic payment, PV is the present value, FV  
%        is the future value, and DUE specifies whether the payments are made  
%        at the beginning (due = 1) or end (due = 0) of the period.  The  
%        default values are fv = 0 and due = 0.  To calculate the number of  
%        periods needed to pay off a loan, enter the payment or the present  
%        value as a negative value.  
%   
%        For example, a savings account has a starting balance of $1500.   
%        $200 is added at the end of each month and the account pays 9%   
%        interest, compounded monthly.  How many years will it take to save  
%        $5,000?  Using the command   
%   
%                 nper = annuterm(.09/12,200,1500,5000,0)  
%          
%        returns nper = 15.68 which is 15.68 months or 1.31 years.   
%        To calculate the number of periods needed to pay off a loan,  
%        enter the payment or the present value as a negative value.  
%   
%        

function acrubond
%MATLAB Tour Partial Function Help:  fin_con
%
% ACRUBOND Accrued interest of security with periodic interest payments.  
%        INT = ACRUBOND(ID,SD,FD,RV,CPN,PER,BASIS) returns the  
%        accrued interest for a security with periodic interest payments.  This  
%        function computes the accrued interest for securities with standard,  
%        short, and long first coupon periods.  ID is the issue date, SD is the  
%        settlement date, FD is the first coupon date, RV is the par value, CPN  
%        is the coupon rate, PER is the number of periods per year (default =  
%        2), and BASIS is the day-count basis: 0 = actual/actual (default), 1 =  
%        30/360, 2 = actual/360, 3 = actual/365.  Enter dates as serial date  
%        numbers or date strings.  
%        
%        For example,   
%   
%        int = acrubond('31-jan-1983', '1-mar-1993',...  
%                             '31-jul-1983', 100, 0.1, 2, 0)  
%    
%        returns  int = 0.8011.  
%   
%        

function acrudisc
%MATLAB Tour Partial Function Help:  fin_con
%
% ACRUDISC Accrued interest of discount security paying at maturity.   
%        INT = ACRUDISC(SD,MD,RV,DISC,PER,BASIS) returns the   
%        accrued interest of a discount security paid at maturity.  SD is the   
%        settlement date, MD is the maturity date, RV is the par value of the   
%        security, DISC is the discount rate of the security, PER is the number   
%        of coupon periods per year (default = 2), and BASIS is the day-count   
%        basis: 0 = actual/actual (default), 1 = 30/360, 2 = actual/360, 3 =   
%        actual/365.  Enter dates as serial date numbers or date strings.   
%    
%        For example,    
%    
%        int = acrudisc('05/01/1992','07/15/1992',100, 0.1, 2, 0)   
%    
%        returns int = 2.0604.   
%    
%        

function bndprice
%MATLAB Tour Partial Function Help:  fin_con
%
% BNDPRICE Price a fixed income security from yield to maturity.
%  Given NumBonds with SIA date parameters and semi-annual yields to
%  maturity, return the clean prices and the accrued interest due.
%          
%  [Price, AccruedInt] = bndprice(Yield, CouponRate, Settle, Maturity, Period,
%          Basis, EndMonthRule, IssueDate, FirstCouponDate, LastCouponDate,
%          StartDate, Face)
% 
%  Inputs: All inputs are scalar or NumBonds by 1 vectors.  Dates
%  can be serial date numbers or date strings.  Fill unspecified entries
%  in input vectors with the value NaN.  Optional arguments can be
%  passed as the empty matrix [].
% 
%     Yield : (required) Bond equivalent yield to maturity with
%     semi-annual compounding. 
% 
%     CouponRate: (required) Decimal annual rate
%     Settle: (required) Settlement date
%     Maturity: (required) Maturity date
%     Period: Coupons per year. Default is 2
%     Basis: Day-count basis.  Default is 0 (actual/actual)
%     EndMonthRule: End-of-month rule.  Default is 1 (in effect)
%     IssueDate: Bond issue date
%     FirstCouponDate: Irregular first coupon date
%     LastCouponDate: Irregular last coupon date
%     StartDate: Forward starting date of payments (Input ignored in 2.0)
%     Face: Face value.  Default is 100
% 
%  Outputs: NumBonds by 1 vectors
%     Price : Clean price of the bond. 
%     AccruedInt : Accrued interest payable at settlement.
% 
%     The dirty price of the bond is the clean price plus the
%     accrued interst.  It is equal to the present value of the bond
%     cash flows.
%     
%     The Price and Yield are related by the formula:
%     Price + Accrued Interest = sum( Cash Flow*(1+Yield/2)^(-Time) )
%     where the sum is over the bond's cash flows and corresponding
%     times in units of semi-annual coupon periods.
% 
%  

function prbond
%MATLAB Tour Partial Function Help:  fin_con
%
% PRBOND  Price of security with regular periodic interest payments. 
%        [P,AI] = PRBOND(SD,MD,RV,CPN,YLD,PER,BASIS) returns the
%        price P and accrued interest AI of a security with regular periodic
%        interest payments.  SD is the settlement date, MD is the maturity
%        date, RV is the par value, CPN is the coupon rate, YLD is the yield,
%        per is the number of coupon periods per year (default = 2), and BASIS
%        is the day-count basis: 0 = actual/actual (default), 1 = 30/360, 2 =
%        actual/360, 3 = actual/365.  Enter dates as serial date numbers or
%        date strings.  This function also applies to zero-coupon bonds or pure
%        discount securities by letting CPN = 0. 
%  
%        Using the following data, 
%    
%               SD = '02/01/1960'
%               MD = '01/01/1990'
%               RV = 1000
%               CPN = 0.08
%               YLD = 0.06
%               PER = 2
%               BASIS = 0
%        
%               [p,ai] = prbond(sd,md,rv,cpn,yld,per,basis)
%        
%               returns p = 1276.39 and ai = 6.81.
%  
%        

function prmat
%MATLAB Tour Partial Function Help:  fin_con
%
% PRMAT  Price with interest at maturity. 
%        [P,AI] = PRMAT(SD,MD,ID,RV,CPN,YLD,BASIS) returns the
%        price p and accrued interest AI of a security that pays interest at
%        maturity.  SD is the settlement date, MD is the maturity date, ID is
%        the issue date, RV is the par value, CPN is the coupon rate, YLD is
%        the yield, and BASIS is the day-count basis: 0 = actual/actual
%        (default), 1 = 30/360, 2 = actual/360, 3 = actual/365.  Enter dates as
%        serial date numbers or date strings.  This function also applies to
%        zero-coupon bonds or pure discount securities by letting CPN = 0. 
%  
%        Using the following data, 
%  
%               SD = '02/07/1992'
%               MD = '04/13/1992'
%               id = '10/11/1991'
%               RV = 100
%               CPN = 0.0608
%               YLD = 0.0608
%               BASIS = 1
%        
%               [p,ai] = prmat(sd,md,id,rv,cpn,yld,basis)
%        
%               returns p = 99.98 and ai = 1.96
%  
%        

function proddf
%MATLAB Tour Partial Function Help:  fin_con
%
% PRODDF Price with odd first period. 
%        [P,AI] = PRODDF(SD,MD,ID,FD,RV,CPN,YLD,PER,BASIS) returns
%        the price P and accrued interest AI of a security with an odd first
%        period and the settlement date in the first period.  SD is the
%        settlement date, MD is the maturity date, ID is the issue date, FD is
%        the first coupon date, RV is the par value, CPN is the coupon rate,
%        YLD is the yield, PER is the number of coupon periods per year
%        (default = 2), and BASIS is the day-count basis: 0 = actual/actual
%        (default), 1 = 30/360, 2 = actual/360, 3 = actual/365.  Enter dates as
%        serial date numbers or date strings. 
%  
%        The data  
%  
%               SD = '11/11/1992'
%               MD = '03/01/2005'
%               ID = '10/15/1992'
%               FD = '03/01/1993'
%               RV = 100
%               CPN = 0.0785
%               YLD = 0.0625
%               PER = 2
%               BASIS = 0
%        
%               [p,ai] = proddf(sd,md,id,fd,rv,cpn,yld,per,basis)
%        
%               returns p = 113.60 and ai = 0.59
%  
%        

function proddfl
%MATLAB Tour Partial Function Help:  fin_con
%
% PRODDFL Price with odd first and last periods and settlement in first period. 
%        [P,AI] = PRODDFL(SD,MD,ID,FD,LCD,RV,CPN,YLD,PER,BASIS)  
%        returns the price P and accrued interest AI of a security with odd
%        first and last periods and the settlement date in the first period.
%        SD is the settlement date, MD is the maturity date, ID is the issue
%        date, FD is the first coupon date, LCD is the last coupon date, RV is
%        the par value, CPN is the coupon rate, YLD is the yield, PER is the
%        number of coupon periods per year (default = 2), and BASIS is the
%        day-count basis: 0 = actual/actual (default), 1 = 30/360, 2 =
%        actual/360, 3 = actual/365.  Enter dates as serial date numbers or
%        date strings.
%  
%        Using the following data, 
%    
%               SD = '03/15/1993'
%               MD = '03/01/2020'
%               ID = '03/01/1993'
%               FD = '07/01/1993'
%               LCD = '01/01/2020'
%               RV = 100
%               CPN = 0.04
%               YLD = 0.0427
%               PER = 2
%               BASIS = 1
%        
%               [p,ai] = proddfl(sd,md,id,fd,lcd,rv,cpn,yld,per,basis)
%        
%               returns p = 95.71 and ai = 0.16.
%  
%        

function proddl
%MATLAB Tour Partial Function Help:  fin_con
%
% PRODDL Price with odd last period. 
%        [P,AI] = PRODDL(SD,MD,LCD,RV,CPN,YLD,PER,BASIS) returns
%        the price P and accrued interest AI of a security with odd last
%        period.  SD is the settlement date, MD is the maturity date, LCD is
%        the last coupon date, RV is the par value, CPN is the coupon rate, YLD
%        is the yield, PER is the number of coupon periods per year (default =
%        2), and BASIS is the day-count basis: 0 = actual/actual (default), 1 =
%        30/360, 2 = actual/360, 3 = actual/365.  Enter dates as serial date
%        numbers or date strings. 
%  
%        The data 
%  
%               SD = '02/07/1993'
%               MD = '08/01/1993'
%               LCD = '02/04/1993'
%               RV = 100
%               CPN = 0.0650
%               YLD = 0.0535
%               PER = 2
%               BASIS = 1
%        
%               [p,ai] = proddl(sd,md,lcd,rv,cpn,yld,per,basis)
%        
%               returns p = 100.54 and ai = 0.05.
%  
%        

function prtbill
%MATLAB Tour Partial Function Help:  fin_con
%
% PRTBILL Price of treasury bill. 
%        P = PRTBILL(SD,MD,RV,DISC) returns the price for 
%        a Treasury bill.  SD is the settlement date, MD 
%        is the maturity date, RV is the redemption value  
%        and DISC is the discount rate. Enter the settlement
%        and maturity dates as serial date numbers or date strings. 
%  
%        For 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 redemption value is  
%        $1000.  The treasury bill price is  
%        p = prtbill('2/10/1992', '8/6/1992', 1000, 0.0377) 
%        or p = 981.36.  
%   
%        

function prdisc
%MATLAB Tour Partial Function Help:  fin_con
%
% PRDISC Price of discounted security. 
%        P = PRDISC(SD,MD,RV,DISC,BASIS) returns the price of a
%        discounted security given the settlement date SD, the maturity date
%        MD, redemption value RV, discount rate DISC, and day-count basis.  For
%        BASIS, 0 = actual/actual (default), 1 = 30/360, 2 = actual/360, 3 =
%        actual/365.  Enter dates as serial date numbers or date strings. 
%  
%        Using the following data, 
%    
%               SD = '10/14/1988'
%               MD = '03/17/1989'
%               RV = 100
%               disc = 0.087
%               basis = 2
%        
%               p = prdisc(sd,md,rv,disc,basis)
%        
%               returns p = 96.28
%  
%        

function disc2zero
%MATLAB Tour Partial Function Help:  fin_con
%
% DISC2ZERO Zero Curve Given a Discount Curve
% 
%    [ZeroRates, CurveDates] = disc2zero(DiscRates, CurveDates, Settle,...
%         OutputCompounding, OutputBasis)
% 
% Summary: Given a discount curve and a set of maturity dates as inputs,
%          this function generates a zero curve for the investment horizon
%          represented by those maturity dates; zero rates are the yields
%          to maturity on theoretical zero coupon bonds.
% 
%  Inputs: DiscRates - (required) an Nx1 vector of discount factors in
%               decimal form which in aggregate represent a discount curve
%               for a given investment horizon
% 
%          CurveDates - (required) an Nx1 vector of maturity dates in serial
%               date number form which correspond to the discount factors
% 
%          MSettle - (required) scalar value in serial date number form
%               representing the settlement date for the discount factors
% 
%          OutputCompounding - (optional) scalar value representing the rate
%               at which the output zero rates are compounded when annualized;
%               possible values include:
%               OutputCompounding = 1 - annual compounding
%               OutputCompounding = 2 - (default) semi-annual compounding
%               OutputCompounding = 3 - compounding three times per year
%               OutputCompounding = 4 - quarterly compounding
%               OutputCompounding = 6 - bi-monthly compounding
%               OutputCompounding = 12 - monthly compounding
%               OutputCompounding = 365 - daily compounding
%               OutputCompounding = -1 - continuous compounding
% 
%          OutputBasis - (optional) scalar value representing the basis to be
%               used in annualizing the output zero rates; possible values
%               include:
%               1) Basis = 0 - actual/actual(default)
%               2) Basis = 1 - 30/360
%               3) Basis = 2 - actual/360
%               4) Basis = 3 - actual/365
% 
% Outputs: ZeroRates - an Nx1 column vector of zero rates in decimal form
%          CurveDates - an Nx1 column vector of maturity dates in serial date
%               number form representing the maturity date for each zero rate
%               contained in ZeroRates
% 
% 

function fwd2zero
%MATLAB Tour Partial Function Help:  fin_con
%
% FWD2ZERO Zero Curve Given an Implied Forward Curve
% 
%      [ZeroRates, CurveDates] = fwd2zero(ForwardRates, CurveDates, Settle,...
%           OutputCompounding, OutputBasis, InputCompounding, InputBasis)
% 
% Summary: Given an implied forward curve and a set of maturity dates as
%          inputs, this function returns a zero curve for the investment
%          horizon represented by those maturity dates.
% 
%  Inputs: ForwardRates - (required) an Nx1 vector of annualized implied
%               forward rates in decimal form which in aggregate represent
%               an implied forward curve for a given investment horizon
% 
%          CurveDates - (required) an Nx1 vector of maturity dates in serial
%               date number form which correspond to the input forward rates
% 
%          MSettle - (required) scalar value in serial date number form
%               representing the settlement date for the input implied
%               forward curve
% 
%          OutputCompounding - (optional) scalar value representing the rate
%               at which the output zero rates are compounded when annualized;
%               possible values include:
%               OutputCompounding = 1 - annual compounding
%               OutputCompounding = 2 - (default) semi-annual compounding
%               OutputCompounding = 3 - compounding three times per year
%               OutputCompounding = 4 - quarterly compounding
%               OutputCompounding = 6 - bi-monthly compounding
%               OutputCompounding = 12 - monthly compounding
%               OutputCompounding = 365 - daily compounding
%               OutputCompounding = -1 - continuous compounding
% 
%          OutputBasis - (optional) scalar value representing the basis to be
%               used in annualizing the output zero rates; possible values
%               include:
%               1) Basis = 0 - actual/actual(default)
%               2) Basis = 1 - 30/360
%               3) Basis = 2 - actual/360
%               4) Basis = 3 - actual/365
% 
%          InputCompounding - (optional) scalar value representing the rate
%               at which the input implied forward rates were compounded when
%               annualized; the default is the value for OutputCompounding
% 
%          InputBasis - (optional) scalar value representing the basis that
%               was used when annualizing the input forward rates; the
%               default is the value for OutputBasis
% 
% Outputs: ZeroRates - an Nx1 column vector of zero rates in decimal form
%          CurveDates - an Nx1 column vector of maturity dates in serial date
%               number form representing the maturity date for each zero rate
%               contained in ZeroRates
% 
% 

function pyld2zero
%MATLAB Tour Partial Function Help:  fin_con
%
% PYLD2ZERO Zero curve given a par yield curve.
% 
%      [ZeroRates, CurveDates] = pyld2zero(ParRates, CurveDates, Settle,...
%           OutputCompounding, OutputBasis, InputCompounding, InputBasis)
% 
% Summary: Given a par yield curve and a set of maturity dates as inputs,
%          this function returns a zero curve for the investment horizon
%          represented by those maturity dates.
% 
%  Inputs: ParRates - (required) an Nx1 vector of annualized par yields (par
%               yields = coupon rates) in decimal form where N is the number
%               of par bond maturities
% 
%          CurveDates - (required) an Nx1 vector of maturity dates in serial
%               date number form which correspond to the input par rates
% 
%          Settle - (required) scalar value in serial date number form
%               representing the settlement date for the bonds
% 
%          OutputCompounding - (optional) scalar value representing the rate
%               at which the output zero rates are compounded when annualized;
%               possible values include:
%               OutputCompounding = 1 - annual compounding or one payment per
%                    year
%               OutputCompounding = 2 - (default) semi-annual compounding
%               OutputCompounding = 3 - compounding three times per year
%               OutputCompounding = 4 - quarterly compounding
%               OutputCompounding = 6 - bi-monthly compounding
%               OutputCompounding = 12 - monthly compounding
% 
%          OutputBasis - (optional) scalar value representing the basis to be
%               used in annualizing the output zero rates; possible values
%               include:
%                   1) Basis = 0 - actual/actual(default)
%                   2) Basis = 1 - 30/360
%                   3) Basis = 2 - actual/360
%                   4) Basis = 3 - actual/365
% 
%          InputCompounding - (optional) scalar value representing the rate at
%               which the input par yields were compounded when annualized; the
%               default is OutputCompounding
% 
%          InputBasis - (optional) scalar value representing the basis that
%               was used in annualizing the input par yields; the default is 
%               OutputBasis
% 
% Outputs: ZeroRates - an Nx1 column vector of zero rates in decimal form
%          CurveDates - an Nx1 column vector of maturity dates in serial date
%               number form representing the maturity date for each zero rate
%               contained in ZeroRates
% 
% 

function termfit
%MATLAB Tour Partial Function Help:  fin_con
%
% TERMFIT Fitted smoothed zero curve from coupon bond prices
% 
%  [ZeroRates, CurveDates, BootZeros, BootDates, BreakDates] = termfit(...
%     Smoothing, Bonds, Prices, Settle, ...
%     OutputCompounding, OutputBasis, CurveDates, BreakDates)
% 
%  Summary: TERMFIT fits a smooth curve to the interest term structure
%           implied by the market prices of a collection of bonds.  The
%           fitted term structure does not price the bonds exactly, but
%           rather assumes some noise in the market prices.  The parameter
%           SMOOTHING controls the tradeoff between the smoothness of the
%           forward curve and the error in pricing the input bonds.
%  
%  Inputs: Smoothing - scalar value, 0 <= Smoothing <= 1, indicating how much
%              smoothing to use.  Smoothing = 0 results in the least error in
%              pricing the bonds.  Smoothing = 1 results in the straightest fit.
% 
%          Bonds - the portfolio of coupon bonds from which the zero curve
%          will be derived; specifically, an NxM matrix of bond parameters
%          where each row of the matrix corresponds to an individual bond
%          and each column corresponds to a particular parameter; the
%          required columns (parameters) for this matrix are:
%              Maturity - (Column 1) the maturity for each bond in the
%                 portfolio in serial date number form
%              CouponRate - (Column 2) the coupon rate for each bond in the
%                 portfolio in decimal form
%              Optional columns (parameters) are:
%              Face - (Column 3) face value of each bond in the portfolio;
%                 default is $100
%              Period - (Column 4) the number of coupon payments per year in
%                 integer form; possible values are 1, 2 (default), 3, 4, 6, 12
%              Basis - (Column 5) values specifying the basis for each bond
%                 in the portfolio; possible values are:
%                    1) Basis = 0 - actual/actual(default)
%                    2) Basis = 1 - 30/360
%                    3) Basis = 2 - actual/360
%                    4) Basis = 3 - actual/365
%              EndMonthRule - (Column 6) value specifying whether or no the
%                 "end of month rule" is in effect for each bond contained in
%                 the portfolio; possible values are:
%                    1) EndMonthRule = 1 (default) - rule is in effect for
%                       the bond (meaning that a security which pays coupon
%                       interest on the last day of the month will always
%                       make payment on the last day of the month)
%                    2) EndMonthRule = 0 - rule is NOT in effect for the bond
% 
%          Prices -  Nx1 column vector containing price values for each bond
%              in the portfolio represented by the Bonds matrix
% 
%          Settle - scalar value representing time zero in derivation of the
%              zero curve; normally this is also the settlement date for the
%              bonds in the portfolio
% 
%          OutputCompounding - scalar value representing the period by which
%              the output zero rates will be compounded; the default value is
%              semi-annual (i.e. "2") compounding 
% 
%          OutputBasis - scalar value representing the basis used to map cash
%              flow dates to years in determining the output zero rates;
%              possible values are:
%               1) Basis = 0 - actual/actual(default)
%               2) Basis = 1 - 30/360
%               3) Basis = 2 - actual/360
%               4) Basis = 3 - actual/365
% 
%          CurveDates -  NumOut x 1 column vector of serial dates at which to
%               report the fitted zero rates.  The default is the set of
%               dates on which any bond in the portfolio has a cash flow.
% 
%          BreakDates -  NumBreaks x 1 column vector of dates between
%               settlement and the longest bond maturity.  The instantaneous
%               forward curve is piecewise cubic in the intervals between
%               BreakDates.  The settlement date and the last maturity date
%               are automatically included in the set of breaks if they are
%               not in BreakDates.
% 
% Outputs: ZeroRates - NumOut x 1 vector containing the values for the fitted
%               zero rates for each point along the investment horizon
%               defined by a maturity date
%          CurveDates - NumOut x 1 vector containing the maturity date for each 
%               zero rate along the investment horizon (from time T = Settle
%               to time T = maturity of the longest dated bond in the source
%               portfolio) 
% 
%          BootZeros - NumBootx1 vector containing bootstrapped zero rates at
%               the bond maturities which price the input portfolio
%               correctly.  The BootZeros curve is not smoothed at all.  See
%               ZBTPRICE for the description of the bootstrapping method.
%          BootDates - NumBoot x 1 vector containing the maturity dates for
%               the bootstrapped zero curve.
% 
%          BreakDates -  Vector of breaks which were used to construct the
%              spline representation of the forward curve.
% 
%   Notes: TERMFIT fits a smoothed cubic spline to the forward rate curve.  
%          Getting a good curve depends on a judicious choice of SMOOTHING
%          and the breakpoints between cubic sections.  Experimentation is
%          in order to set the parameters for a particular data set.
% 
%          The curve-fitting model embodied in this program is that 
%          described by Mark Fisher, Douglas Nychka and David 
%          Zervos in Finance and Economics Discussion Series Working 
%          Paper # 95-1, published by the Division of Research and 
%          Statistics, Division of Monetary Affairs, Federal Reserve
%          Board, Washington, D.C.
% 
% 

function tbl2bond
%MATLAB Tour Partial Function Help:  fin_con
%
% TBL2BOND Treasury Bill to Equivalent Treasury Bond Parameters
% 
%      [TBondMatrix, Settle] = tbl2bond(TBillMatrix)
% 
% Summary: This function takes market parameters for U.S. Treasury Bills
%          restates them in U.S. Treasury Bond form as zero coupon bonds. This
%          makes the T-Bills directly comparable to Treasury notes and bonds.
% 
%  Inputs: TBillMatrix - Nx5 matrix containing the following column vectors
%               (all required):
%          Maturity - Nx1 column vector containing value representing the
%               maturity date of the T-Bills contained in the portfolio in
%               serial date number form
%          DaysMaturity - Nx1 column vector containing values for the number of
%               days to maturity for each T-Bill in the portfolio in integer
%               form.  Days to Maturity is quoted on a skip-day basis; the
%               actual number of days from settlement to maturity is
%               DaysMaturity + 1.
%          Bid - Nx1 column vector containing values for the bid bank discount
%               yield (the percentage discount from face value at which the
%               instrument would be bought by a dealer annualized on a simple
%               interest basis over a 360-day year)in decimal form
%          Asked - Nx1 column vector containing values for the asked bank
%               discount yield in decimal form
%          AskYield - Nx1 column vector containing the values, in decimal form,
%               for the bond-equivalent yield (i.e. the holding period return,
%               annualized on a simple interest basis and assuming a 365-day
%               year) that the investor will realize by purchasing the bill
%               and holding it to maturity
% 
% Outputs: TBondMatrix - Nx5 matrix containing the following column vectors:
%          CouponRate - Nx1 column vector containing the equivalent coupon
%               rate in which will be zero for all T-Bills since they are by
%               definition a zero coupon instrument (this is vector serves as
%               a placeholder in the matrix)
%          Maturity - Nx1 column vector containing the maturity date for each
%               T-Bill in serial date number form
%          Bid - Nx1 column vector containing the bid price for the T-Bill in
%               decimal form in terms of $100 of face value
%          Asked - Nx1 column vector containing the ask price for the T-Bill in
%               decimal form in terms of $100 of face value
%          AskYield - Nx1 bond equivalent yield.
%          
%          Settle - Nx1 vector of settlement dates implied by the maturity
%               dates and the number of days to maturity quote.
% 
% 

function tr2bonds
%MATLAB Tour Partial Function Help:  fin_con
%
% TR2BONDS Bonds Matrix, Prices Vector, and Yields Vector Given a Standard
%      Treasury Matrix
% 
%      [Bonds, Prices, Yields] = tr2bonds(TreasuryMatrix, Settle)
% 
% Summary: This function creates a sorted Bonds matrix, Prices vector, and
%          Yields vector of the form required by the ZBTPRICE and ZBTYIELD
%          bootstrapping functions given a standard matrix of Treasury note
%          and bond data
% 
%  Inputs: TreasuryMatrix - Nx5 matrix of U.S. Treasury Bond data comprised
%          of the following parameters:
%          CouponRate - Nx1 column vector of values in decimal form
%               representing the coupon rates for each bond in the portfolio
%          Maturity - Nx1 column vector of values representing the maturity
%               dates in serial date number form for each bond in the portfolio
%          Bid - Nx1 column vector of bid prices in integer-decimal form for
%               each for each bond in the portfolio
%          Asked - Nx1 column vector of asked prices in integer-decimal form
%               for each bond in the portfolio
%          AskYield - Nx1 column vector of values in decimal form representing
%               the quoted ask yield for each bond in the portfolio
% 
%          Settle - (optional) Date string or serial date number of the
%               settlement date for the analysis.
% 
% Outputs: Bonds - the portfolio of coupon bonds from which the zero curve will
%               be derived; specifically, an NxM matrix of bond parameters
%               where each row of the matrix corresponds to an individual bond
%               and each column corresponds to a particular parameter; the
%               required columns (parameters) for this matrix are:
%          Maturity - (Column 1) the maturity for each bond in the portfolio in
%               serial date number form
%          CouponRate - (Column 2) the coupon rate for each bond in the
%               portfolio in decimal form
%          Optional columns (parameters) are:
%          Face - (Column 3) face value of each bond in the portfolio; default
%                is $100
%          Period - (Column 4) the number of coupon payments per year in
%                integer form; possible values are 1, 2 (default), 3, 4, 6
%                and 12
%          Basis - (Column 5) values specifying the basis for each bond in the
%                portfolio; possible values include:
%                1) Basis = 0 - actual/actual(default)
%                2) Basis = 1 - 30/360
%                3) Basis = 2 - actual/360
%                4) Basis = 3 - actual/365
%          EndMonthRule - (Column 6) value specifying whether or no the "end
%                of month rule" is in effect for each bond contained in the
%                portfolio possible values include:
%                1) EndMonthRule = 1 (default) - rule is in effect for the bond
%                     (meaning that a security which pays coupon interest on
%                     the last day of the month will always make payment on the
%                     last day of the month)
%                2) EndMonthRule = 0 - rule is NOT in effect for the bond
% 
%          Prices -  Nx1 column vector containing price values for each bond
%               contained in the portfolio represented by the Bonds matrix
%          Yields - Nx1 column vector containing yield values for each bond
%               contained in the portfolio represented by the Bonds matrix.
%               If Settle is passed in, Yields will be computed as a
%               semi-annual yield to maturity.  If Settle is not passed in,
%               the quoted input yields will be used.
% 
% 	

function zbtprice
%MATLAB Tour Partial Function Help:  fin_con
%
% ZBTPRICE Zero Curve Bootstrapping from Coupon Bond Data Given Price
% 
%          [ZeroRates, CurveDates] = zbtprice(Bonds, Prices, Settle,...
%               OutputCompounding, OutputBasis, MaxIterations) 
% 
% Summary: This function derives a zero curve given basic parameters and
%          price values for a source portfolio of coupon bonds using the
%          "bootstrap" methodology. The zero curve is defined as the
%          collective yields to maturity on a portfolio of theoretical
%          zero coupon bonds which are in turn derived from the source 
%          portfolio. The bootstrapping method used by this function does
%          NOT require alignment among the cash flow dates of the bonds 
%          contained in the source portfolio. Instead it uses theoretical 
%          par bond arbitrage and yield interpolation to derive all zero
%          rates.
% 
%  Inputs: Bonds - the portfolio of coupon bonds from which the zero curve
%               will be derived; specifically, an NxM matrix of bond
%               parameters where each row of the matrix corresponds to an 
%               individual bond and each column corresponds to a particular
%               parameter; the required columns (parameters) for this matrix
%               are:
%          Maturity - (Column 1) the maturity for each bond in the portfolio
%               in serial date number form
%          CouponRate - (Column 2) the coupon rate for each bond in the 
%               portfolio in decimal form
%          Optional columns (parameters) are:
%          Face - (Column 3) face value of each bond in the portfolio; default
%               is $100
%          Period - (Column 4) the number of coupon payments per year in 
%               integer form; possible values are 0, 1, 2 (default), 3, 4, 6 
%               and 12
%          Basis - (Column 5) values specifying the basis for each bond in the
%               portfolio; possible values are:
%               1) Basis = 0 - actual/actual(default)
%               2) Basis = 1 - 30/360
%               3) Basis = 2 - actual/360
%               4) Basis = 3 - actual/365
%          EndMonthRule - (Column 6) value specifying whether or no the "end
%               of month rule" is in effect for each bond contained in the
%               portfolio possible values are:
%               1) EndMonthRule = 1 (default) - rule is in effect for the bond
%                    (meaning that a security which pays coupon interest on the
%                    last day of the month will always make payment on the
%                    last day of the month)
%               2) EndMonthRule = 0 - rule is NOT in effect for the bond
% 
%          Prices -  Nx1 column vector containing price values for each bond
%               contained in the portfolio represented by the Bonds matrix
% 
%          Settle - scalar value representing time zero in derivation of the 
%               zero curve; normally this is also the settlement date for 
%               the bonds contained in the portfolio from which the zero 
%               curve will be derived
% 
%          OutputCompounding - scalar value representing the period by which 
%               the output zero rates will be compounded; the default value
%               is semi-annual (i.e. "2") compounding 
% 
%          OutputBasis - scalar value representing the basis used to map cash 
%               flow dates to years in determining the output zero rates;
%               possible values include:
%               1) Basis = 0 - actual/actual(default)
%               2) Basis = 1 - 30/360
%               3) Basis = 2 - actual/360
%               4) Basis = 3 - actual/365
% 
%          MaxIterations - scalar value for the maximum number of iterations 
%               to be used in deriving yield to maturity value for each bond 
%               contained in the Bonds matrix; default value is 50
% 
% Outputs: ZeroRates - Nx1 vector containing the values for the implied zero
%               rates for each point along the investment horizon defined
%               by a maturity date
%          CurveDates - Nx1 vector containing the maturity date for each 
%               zero rate along the investment horizon (from time T = Settle
%               to time T = maturity of the longest dated bond in the source
%               portfolio)         
% 
%   Notes: 1) In cases where the source portfolio of bonds contains more 
%               than one bond with the same maturity date, the mean zero rate
%               is calculated for that maturity date.                  
%          2) Ensuring that the source portfolio contains a sufficient number
%               of bonds and that those bonds are evenly distributed with 
%               respect to maturity date will significantly enhance the 
%               performance of this function.
% 
% 

function zbtyield
%MATLAB Tour Partial Function Help:  fin_con
%
% ZBTYIELD Zero Curve Bootstrapping from Coupon Bond Data Given Yield
% 
%      [ZeroRates, CurveDates] = zbtyield(Bonds, Prices, Settle,...
%          OutputCompounding, OutputBasis, MaxIterations) 
% 
% Summary: This function derives a zero curve given basic parameters and
%          price values for a source portfolio of coupon bonds using the
%          "bootstrap" methodology. The zero curve is defined as the
%          collective yields to maturity on a portfolio of theoretical
%          zero coupon bonds which are in turn derived from the source 
%          portfolio. The bootstrapping method used by this function does
%          NOT require alignment among the cash flow dates of the bonds 
%          contained in the source portfolio. Instead it uses theoretical 
%          par bond arbitrage and yield interpolation to derive all zero
%          rates.
% 
%  Inputs: Bonds - the portfolio of coupon bonds from which the zero curve
%               will be derived; specifically, an NxM matrix of bond
%               parameters where each row of the matrix corresponds to an 
%               individual bond and each column corresponds to a particular
%               parameter; the required columns (parameters) for this matrix
%               are:
%          Maturity - (Column 1) the maturity for each bond in the portfolio
%               in serial date number form
%          CouponRate - (Column 2) the coupon rate for each bond in the 
%               portfolio in decimal form
%          Optional columns (parameters) are:
%          Face - (Column 3) face value of each bond in the portfolio; default
%               is $100
%          Period - (Column 4) the number of coupon payments per year in 
%               integer form; possible values are 0, 1, 2 (default), 3, 4, 6 
%               and 12
%          Basis - (Column 5) values specifying the basis for each bond in the
%               portfolio; possible values are:
%               1) Basis = 0 - actual/actual(default)
%               2) Basis = 1 - 30/360
%               3) Basis = 2 - actual/360
%               4) Basis = 3 - actual/365
%          EndMonthRule - (Column 6) value specifying whether or no the "end
%               of month rule" is in effect for each bond contained in the
%               portfolio possible values are:
%               1) EndMonthRule = 1 (default) - rule is in effect for the bond
%                    (meaning that a security which pays coupon interest on the
%                    last day of the month will always make payment on the
%                    last day of the month)
%               2) EndMonthRule = 0 - rule is NOT in effect for the bond
% 
%          Yields -  Nx1 column vector containing yield to maturity values
%               for each bond contained in the source portfolio represented 
%               by the Bonds matrix
% 
%          Settle - scalar value representing time zero in derivation of the 
%               zero curve; normally this is also the settlement date for 
%               the bonds contained in the portfolio from which the zero 
%               curve will be derived
% 
%          OutputCompounding - scalar value representing the period by which 
%               the output zero rates will be compounded; the default value
%               is semi-annual (i.e. "2") compounding 
% 
%          OutputBasis - scalar value representing the basis used to map cash 
%               flow dates to years in determining the output zero rates;
%               possible values include:
%               1) Basis = 0 - actual/actual(default)
%               2) Basis = 1 - 30/360
%               3) Basis = 2 - actual/360
%               4) Basis = 3 - actual/365
% 
%          MaxIterations - scalar value for the maximum number of iterations 
%               to be used in deriving yield to maturity value for each bond 
%               contained in the Bonds matrix; default value is 50
% 
% Outputs: ZeroRates - Nx1 vector containing the values for the implied zero
%               rates for each point along the investment horizon defined
%               by a maturity date
%          CurveDates - Nx1 vector containing the maturity date for each 
%               zero rate along the investment horizon (from time T = Settle
%               to time T = maturity of the longest dated bond in the source
%               portfolio)         
% 
%   Notes: 1) In cases where the source portfolio of bonds contains more 
%               than one bond with the same maturity date, the mean zero rate
%               is calculated for that maturity date.                  
%          2) Ensuring that the source portfolio contains a sufficient number
%               of bonds and that those bonds are evenly distributed with 
%               respect to maturity date will significantly enhance the 
%               performance of this function.
% 
% 

function zero2disc
%MATLAB Tour Partial Function Help:  fin_con
%
% ZERO2DISC Discount Curve Given a Zero Curve
% 
%    [DiscRates, CurveDates] = zero2disc(ZeroRates, CurveDates, Settle,...
%         InputCompounding, InputBasis)
% 
% Summary: Given a zero curve and a set of maturity dates as inputs, this
%          function generates a set of discount factors, or discount curve,
%          for the investment horizon represented by those maturity dates.
% 
%  Inputs: ZeroRates - (required) an Nx1 vector of zero rates in decimal form
%          which in aggregate represent a zero curve for a given investment
%          horizon
% 
%          CurveDates - (required) an Nx1 vector of maturity dates in serial
%          date number form which correspond to the input zero rates
% 
%          MSettle - (required) scalar value in serial date number form
%               representing the settlement date for the input zero curve
%               (i.e. the settlement date for the bonds from which the zero
%               curve was bootstrapped)
% 
%          InputCompounding - (optional) scalar value representing the rate at
%               which the input zero rates were compounded when annualized;
%               possible values include:
%               InputCompounding = 1 - annual compounding or one payment per
%                    year
%               InputCompounding = 2 - (default) semi-annual compounding
%               InputCompounding = 3 - compounding three times per year
%               InputCompounding = 4 - quarterly compounding
%               InputCompounding = 6 - bi-monthly compounding
%               InputCompounding = 12 - monthly compounding
%               InputCompounding = 365 - daily compounding
%               InputCompounding = -1 - continuous compounding
% 
%          InputBasis - (optional) scalar value representing the basis that
%               was used in annualizing the input zero rates; possible values
%               include:
%                   1) Basis = 0 - actual/actual(default)
%                   2) Basis = 1 - 30/360
%                   3) Basis = 2 - actual/360
%                   4) Basis = 3 - actual/365
% 
%  Outputs: DiscRates - an Nx1 column vector of discount factors in decimal
%                form
%           CurveDates - an Nx1 column vector of maturity dates in serial
%                date number form representing the maturity date for each
%                discount factor contained in DiscRates
% 
% 

function zero2fwd
%MATLAB Tour Partial Function Help:  fin_con
%
% ZERO2FWD Implied Forward Rate Curve Given a Zero Curve
% 
%      [ForwardRates, CurveDates] = zero2fwd(ZeroRates, CurveDates, Settle,...
%           OutputCompounding, OutputBasis, InputCompouding, InputBasis)
% 
% Summary: Given a zero curve and a set of maturity dates as inputs, this
%          function returns an implied forward rate curve for the investment
%          horizon represented by those maturity dates.
% 
%  Inputs: ZeroRates - (required) an Nx1 vector of annualized zero rates in
%               decimal form which in aggregate represent a zero curve for
%               a given investment horizon
% 
%          CurveDates - (required) an Nx1 vector of maturity dates in serial
%               date number form which correspond to the input zero rates
% 
%          MSettle - (required) scalar value in serial date number form
%               representing the settlement date for the input zero curve
%               (i.e. the settlement date for the bonds from which the zero
%               curve was bootstrapped)
% 
%          OutputCompounding - (optional) scalar value representing the rate
%               at which the output implied forward rates are compounded when
%               annualized; possible values include:
%                OutputCompounding = 1 - annual compounding or one payment per
%                     year
%                OutputCompounding = 2 - (default) semi-annual compounding
%                OutputCompounding = 3 - compounding three times per year
%                OutputCompounding = 4 - quarterly compounding
%                OutputCompounding = 6 - bi-monthly compounding
%                OutputCompounding = 12 - monthly compounding
%                OutputCompounding = 365 - daily compounding
%                OutputCompounding = -1 - continuous compounding
% 
%          OutputBasis - (optional) scalar value representing the basis to be
%               used in annualizing the output implied forward rates; possible
%               values include:
%               1) Basis = 0 - actual/actual(default)
%               2) Basis = 1 - 30/360
%               3) Basis = 2 - actual/360
%               4) Basis = 3 - actual/365
% 
%          InputCompounding - (optional) scalar value representing the rate at
%               which the input zero rates were compounded when annualized;
%               the default is the value for OutputCompounding
% 
%          InputBasis - (optional) scalar value representing the basis used
%               in annualizing the input zero rates; the
%               default is the value for OutputBasis
% 
% Outputs: ForwardRates - an Nx1 column vector of implied forward rates in
%               decimal form
%          CurveDates - an Nx1 column vector of maturity dates in serial date
%               number form representing the maturity date for each implied
%               forward rate contained in ForwardRates
% 
% 

function zero2pyld
%MATLAB Tour Partial Function Help:  fin_con
%
% ZERO2PYLD Par curve given a zero yield curve.
%      [ParRates, CurveDates] = zero2pyld(ZeroRates, CurveDates, Settle,...
%           OutputCompounding, OutputBasis, InputCompounding, InputBasis)
% 
% Summary: Given a zero curve and a set of maturity dates, this function
%          returns a par yield curve for the investment horizon represented
%          by those maturity dates.
% 
%  Inputs: ZeroRates - (required) an Nx1 vector of annualized zero rates in
%               decimal form.
% 
%          CurveDates - (required) an Nx1 vector of maturity dates in serial 
%               date number form which correspond to the input zero rates.
% 
%          Settle - (required) scalar value in serial date number form 
%               representing the settlement date for the bonds.
% 
%          OutputCompounding - (optional) scalar value representing the 
%               coupon frequency of the par bonds; possible values include:
%               OutputCompounding = 1 - annual compounding or one payment per
%                    year
%               OutputCompounding = 2 - (default) semi-annual compounding
%               OutputCompounding = 3 - compounding three times per year
%               OutputCompounding = 4 - quarterly compounding
%               OutputCompounding = 6 - bi-monthly compounding
%               OutputCompounding = 12 - monthly compounding
% 
%          OutputBasis - (optional) scalar value representing the basis of
%               the par bonds; possible values include:
%                   1) Basis = 0 - actual/actual(default)
%                   2) Basis = 1 - 30/360
%                   3) Basis = 2 - actual/360
%                   4) Basis = 3 - actual/365
% 
%          InputCompounding - (optional) scalar value representing the rate 
%               at which the input zero rates are compounded when annualized.  
%               The default is OutputCompounding
% 
%          InputBasis - (optional) scalar value representing the basis used
%               in annualizing the input zero rates.  
%               The default is OutputBasis
% 
% Outputs: ParRates - an Nx1 column vector of par bond coupon rates (yields)
%          CurveDates - an Nx1 column vector of maturity dates in serial
%               date number form representing the maturity date for each
%               par bond
% 
% 

function bndyield
%MATLAB Tour Partial Function Help:  fin_con
%
% BNDYIELD Yield to maturity for a fixed income security
%  Given NumBonds bonds with SIA date parameters and clean prices,
%  returns the yields to maturity.
%          
%  Yield = bndyield(Price, CouponRate, Settle, Maturity, Period,
%     Basis, EndMonthRule, IssueDate, FirstCouponDate, LastCouponDate,
%     StartDate, Face)
% 
%  Inputs: All inputs are scalar or NumBonds by 1 vectors.  Dates
%  can be serial date numbers or date strings.  Fill unspecified entries
%  in input vectors with the value NaN.  Optional arguments can be
%  passed as the empty matrix [].
% 
%     Price: (required) Clean price of the bond
%     CouponRate: (required) Decimal annual rate
%     Settle: (required) Settlement date
%     Maturity: (required) Maturity date
%     Period: Coupons per year. Default is 2
%     Basis: Day-count basis.  Default is 0 (actual/actual)
%     EndMonthRule: End-of-month rule.  Default is 1 (in effect)
%     IssueDate: Bond issue date
%     FirstCouponDate: Irregular first coupon date
%     LastCouponDate: Irregular last coupon date
%     StartDate: Forward starting date of payments (Input ignored in 2.0)
%     Face: Face value.  Default is 100
% 
%  Output: NumBonds by 1 vector
%     Yield : Yield to maturity with semi-annual compounding. 
% 
%     The Price and Yield are related by the formula:
%     Price + Accrued Interest = sum( Cash Flow*(1+Yield/2)^(-Time) )
%     where the sum is over the bond's cash flows and corresponding
%     times in units of semi-annual coupon periods.
% 
%  

function beytbill
%MATLAB Tour Partial Function Help:  fin_con
%
% BEYTBILL Bond equivalent yield for treasury bill.  
%        Y = BEYTBILL(SD,MD,DISC) returns the bond equivalent yield for a 
%        Treasury bill. SD is the settlement date, MD is the maturity date,
%        and DISC is the discount rate. Enter the settlement and maturity
%        dates as serial date numbers or date strings.  The number of days to
%        maturity is typically quoted as md - sd - 1.  NaN (Not-a-Number) is
%        returned for all cases in which negative prices are implied by the 
%        discount rate DISC and the number of days between settlement 
%        and maturity.
%   
%        For example, the settlement date of a Treasury bill is 
%        February 10, 1992, the maturity date is August 6, 1992, and 
%        the discount rate is 3.77%.   
%        Computing the bond equivalent yield:  
%          
%               y = beytbill('2/10/1992', '8/6/1992', 0.0377)  
%          
%               returns y = 0.0389
%   
%        

function discrate
%MATLAB Tour Partial Function Help:  fin_con
%
% DISCRATE Discount rate of security. 
%        D = DISCRATE(SD,MD,RV,PRICE,BASIS) finds the discount rate
%        of a security given the settlement date SD, the maturity date MD, par
%        value RV, and PRICE.  basis is the day-count basis: 0 = actual/actual
%        (default), 1 = 30/360, 2 = actual/360, 3 = actual/365.  Enter dates as
%        serial date numbers or date strings. 
%  
%        For example,  
%        d = discrate('12-jan-1994', '25-jun-1994', 100, 97.74, 0) 
%        returns d = 0.0503 or a discount rate of 5.03%.  
%  
%        

function yldbond
%MATLAB Tour Partial Function Help:  fin_con
%
% YLDBOND Yield to Maturity for a Bond 
% 
%      Yield = yldbond(Settle, Maturity, Face, Price, CouponRate, Period,...
%      Basis, MaxIterations, EndMonthRule)
% 
% Summary: Given standard bond parameters this function determines the yield
%          to maturity for both coupon and zero-coupon bonds using a Newton-
%          Ralphson iterative method.
% 
%  Inputs: Settle - (required) Nx1 or 1xN vector of values in serial date
%               number form representing the settlement date for the bond(s)
%          Maturity - (required) Nx1 or 1xN vector of values in serial date
%               number form representing the maturity date for the bond(s)
%          Face - (required) Nx1 or 1xN vector of values for the face value of
%               the bond(s)
%          Price - (required) Nx1 or 1xN vector of values for the price of the
%               bond(s)
%          CouponRate - (optional) Nx1 or 1xN vector of values for the coupon
%               rate of the bond(s).  The default is zero
%          Period - (optional) Nx1 or 1xN vector of values representing the
%               frequency of coupon payments for the bond(s); possible values
%               include:
%               Period = 0 - zero coupon bond
%               Period = 1 - annual coupon payments
%               Period = 2 - semi-annual coupon payments (default)
%               Period = 3 - three coupon payments per year
%               Period = 4 - quarterly coupon payments
%               Period = 6 - bi-monthly coupon payments
%               Period = 12 - monthly coupon payments
%          Basis - Nx1 or 1xN vector or scalar value specifying the basis for
%               the bond(s); possible values include:
%               1) Basis = 0 - actual/actual(default)
%               2) Basis = 1 - 30/360
%               3) Basis = 2 - actual/360
%               4) Basis = 3 - actual/365
%          MaxIterations - scalar value representing the number of iterations
%               to be used in Newton's method when deriving the yield to
%               maturity for the bond(s); the default is 5 (Note: MaxIterations
%               may also be passed as an empty matrix in cases where the user
%               wants to use the default value but also wants to pass the end
%               of month rule flag to the function.)
%          EndMonthRule - Nx1 or 1xN vector or scalar value specifying whether
%               or not the "end of month rule" is in effect for the bond(s);
%               possible values include:
%               1) EndMonthRule = 1 (default) - rule is in effect for the
%                    bond(s) (meaning that a security that pays coupon 
%                    interest on the last day of the month will always
%                    make payment on the last day of the month)
%               2) EndMonthRule = 0 - rule is NOT in effect for the bond(s)
%  
%      Example: Settle = '01-Jan-1960';
%               Maturity = '01-Jan-1990';
%               Face = 1000;
%               Price = 1276.76;
%               CouponRate = 0.08;
%               Period = 2;
%               Basis = 0;
%               EndMonthRule = 1;
%        
%               Yield = yldbond(Settle, Maturity, Face, Price, ...
%                    CouponRate, Period, Basis)
%        
%               returns:
% 
%               Yield = 0.0599
% 
% 

function yldmat
%MATLAB Tour Partial Function Help:  fin_con
%
% YLDMAT Yield with interest at maturity. 
%        YLDMAT(SD,MD,ID,RV,PRICE,CPN,BASIS) returns the yield of a 
%        security paying interest at maturity.  SD is the settlement  
%        date, MD is the maturity date, ID is the issue date, RV is  
%        the redemption value, PRICE is the price, CPN is the coupon 
%        rate, and BASIS is the day count basis: 0 = actual/actual (default), 
%        1 = 30/360, 2 = actual/360, 3 = actual/365.  Enter dates as serial date 
%        numbers or date strings. 
%  
%        The data 
%  
%               SD = '02/07/1992'
%               MD = '04/13/1992'
%               ID = '10/11/1991'
%               RV = 100
%               PRICE = 99.98
%               CPN = 0.0608
%               BASIS = 1
%        
%               y = yldmat(sd,md,id,rv,price,cpn,basis)
%        
%               returns y = 0.0607 or 6.07%.
%  
%        

function yldoddf
%MATLAB Tour Partial Function Help:  fin_con
%
% YLDODDF Yield of security with odd first period. 
%        YLD = YLDODDF(SD,MD,ID,FD,RV,PRICE,CPN,PER,BASIS,MAXITER)  
%        returns the yield of a security with an odd first period and the
%        settlement date in the first period.  SD is the settlement date, MD is
%        the maturity date, ID is the issue date, FD is the first coupon date,
%        RV is the par value, PRICE is the security price, CPN is the coupon
%        rate, PER is the number of coupon periods per year (default = 2), and
%        BASIS is the day-count basis: 0 = actual/actual (default), 1 = 30/360,
%        2 = actual/360, 3 = actual/365.  MAXITER specifies the number of
%        iterations used by Newton’s method to solve for YLD.  By default,
%        MAXITER = 50.  Enter dates as serial date numbers or date strings.
%  
%        The data 
%  
%               SD = '11/11/1992'
%               MD = '03/01/2005'
%               ID = '10/15/1992'
%               FD = '03/01/1993'
%               RV = 100
%               PRICE = 113.60
%               CPN = 0.0785
%               PER = 2
%               BASIS = 0
%        
%               yld = yldoddf(sd,md,id,fd,rv,price,cpn,per,basis)
%        
%               returns yld = 0.0625 or 6.25%.
%  
%        

function yldoddfl
%MATLAB Tour Partial Function Help:  fin_con
%
% YLDODDFL Yield with odd first and last periods and settlement in first period. 
%        YLD = YLDODDFL(SD,MD,ID,FD,LCD,RV,PRICE,CPN,PER,BASIS,MAXITER) returns the
%        yield of a security with odd first and last periods and the settlement
%        date in the first period.  SD is the settlement date, MD is the
%        maturity date, ID is the issue date, FD is the first coupon date, LCD
%        is the last coupon date, RV is the par value, PRICE is the security
%        price, CPN is the coupon rate, PER is the number of coupon periods per
%        year (default = 2), and BASIS is the day-count basis: 0 =
%        actual/actual (default), 1 = 30/360, 2 = actual/360, 3 = actual/365.
%        MAXITER specifies the number of iterations used by Newton's method
%        to solve for YLD.  By default, MAXITER = 50.  Enter dates as serial
%        date numbers or date strings.
%  
%        Using the following data, 
%    
%               SD = '03/15/1993'
%               MD = '03/01/2020'
%               ID = '03/01/1993'
%               FD = '07/01/1993'
%               LCD = '01/01/2020'
%               RV = 100
%               PRICE = 95.71
%               CPN = 0.04
%               PER = 2
%               BASIS = 1
%        
%               yld = yldoddfl(sd,md,id,fd,lcd,rv,price,cpn,per,basis)
%        
%               returns yld = 0.0427 or 4.27%.
%  
%        

function yldoddl
%MATLAB Tour Partial Function Help:  fin_con
%
% YLDODDL Yield with odd last period. 
%        YLD = YLDODDL(SD,MD,LCD,RV,PRICE,CPN,PER,BASIS,MAXITER)  
%        returns the yield of a security with odd last period.  SD is the
%        settlement date, MD is the maturity date, LCD is the last coupon date,
%        RV is the par value, PRICE is the security price, CPN is the coupon
%        rate, PER is the number of coupon periods per year (default = 2), and
%        BASIS is the day-count basis: 0 = actual/actual (default), 1 = 30/360,
%        2 = actual/360, 3 = actual/365.  MAXITER specifies the number of
%        iterations used by Newton's method to solve for YLD.  By default,
%        MAXITER = 50.  Enter dates as serial date numbers or date strings.
%  
%        The data 
%   
%               SD = '02/07/1993'
%               MD = '06/15/1993'
%               LCD = '10/15/1992'
%               RV = 100
%               PRICE = 99.878
%               CPN = 0.0375
%               PER = 2
%               BASIS = 1
%        
%               yld = yldoddl(sd,md,lcd,rv,price,cpn,per,basis)
%        
%               returns yld = 0.0405 or 4.05%.
%  
%        

function yldtbill
%MATLAB Tour Partial Function Help:  fin_con
%
% YLDTBILL Yield of treasury bill. 
%        Y = YLDTBILL(SD,MD,RV,PRICE) returns the yield for a
%        Treasury bill.  SD is the settlement date, MD is the maturity date, RV
%        is the par value, and PRICE is the price of the Treasury bill.  Enter
%        the settlement and maturity dates as serial date numbers or date
%        strings. 
%  
%        For example, the settlement date of a treasury bill is 
%        February 10, 1992, the maturity date is August 6, 1992, 
%        the redemption value is $1000, and the price is $981.36. 
%        The annual equivalent yield is  
%  
%        y = yldtbill('2/10/1992', '8/6/1992', 1000, 981.36)
%        or y = 0.0384 or 3.84%.
%  
%        

function ylddisc
%MATLAB Tour Partial Function Help:  fin_con
%
% YLDDISC Yield of discounted security. 
%        Y = YLDDISC(SD,MD,RV,PRICE,BASIS) finds the yield of a discounted 
%        security given the settlement date, SD, the maturity date, MD,  
%        redemption value, RV, discounted price, PRICE, and day count 
%        basis, BASIS.  For BASIS, 0 = actual/actual (default), 1 = 30/360, 
%        2 = actual/360, 3 = actual/365.  Enter dates as serial date numbers or
%        date strings.
%  
%        The data 
%    
%               SD = '10/14/1988'
%               MD = '03/17/1989'
%               RV = 100
%               PRICE = 96.28
%               BASIS = 2
%        
%               y = ylddisc(sd,md,rv,price,basis)
%        
%               returns y = 0.0903 or 9.03%
%  
%        

function effrr
%MATLAB Tour Partial Function Help:  fin_con
%
% EFFRR Effective rate of return. 
%        R = EFFRR(APR,PER) calculates the annual effective rate 
%        of return based on the annual percentage rate, APR,  
%        and the number of compounding periods per year, PER. 
%  
%        For example, the effective annual rate of return based  
%        on an annual percentage rate of 9% compounded monthly  
%        is represented as  
%  
%        r = effrr(.09,12) returning r = 0.0938 or 9.38%.   
%  
%        Compounding continuously returns r equivalent to (e^apr-1). 
%  
%        

function irr
%MATLAB Tour Partial Function Help:  fin_con
%
% IRR    Internal rate of return. 
%        R = IRR(CF) calculates the internal rate of return for 
%        a series of periodic cash flows.  CF is the cash flow  
%        vector.  The first entry in CF is the initial investment. 
%         If CF is entered as a matrix, each column of CF is treated 
%        as a separate cash flow. 
%  
%        Suppose an initial investment of $100,000 is made.   
%        The following cash flow represents the yearly income  
%        realized by the investment. 
%   
%                       Year 1       $10,000 
%                       Year 2       $20,000 
%                       Year 3       $30,000 
%                       Year 4       $40,000 
%                       Year 5       $50,000 
%  
%        To calculate the internal rate of return on the investment,  
%        use r = irr([-100000 10000 20000 30000 40000 50000]) which  
%        returns r = 12%.  If the cash flow payments were monthly,  
%        the resulting rate of return would be multiplied by 12 for  
%        the annual rate of return. 
%  
%        

function mirr
%MATLAB Tour Partial Function Help:  fin_con
%
% MIRR   Modified internal rate of return. 
%        R = MIRR(CF,SRATE,RRATE) calculates the modified internal  
%        rate of return for a series of periodic cash flows.  CF  
%        is the cash flow vector, SRATE is the finance rate for  
%        negative cash flow values,  and RRATE is the reinvestment  
%        rate for positive cash flow values.  If CF is entered 
%        as a matrix, each column is treated as a separate cash 
%        flow.  SRATE and RRATE can be entered as row vectors 
%        where each column corresponds to a column of CF or as 
%        scalar values applying the same rate to each cash flow. 
%  
%        Suppose an initial investment of $100,000 is made.   
%        The following cash flow represents the yearly income  
%        realized by the investment.  The finance rate is 9% and  
%        the reinvestment rate is 12%. 
%   
%                       Year 1       $20,000 
%                       Year 2      ($10,000) 
%                       Year 3       $30,000 
%                       Year 4       $38,000 
%                       Year 5       $50,000 
%  
%        To calculate the modified internal rate of return on the  
%        investment, use  
%  
%        r = mirr([-100000 20000 -10000 30000 38000 50000],.09,.12)  
%  
%        which returns r = 8.32%.   
%  
%        

function nomrr
%MATLAB Tour Partial Function Help:  fin_con
%
% NOMRR Nominal rate of return.
%        APR = NOMRR(ER,PER) returns the nominal rate 
%        of return based the effective annual percentage 
%        rate, ER, and the number of compounding periods per
%        year, PER.
% 
%        For example, the nominal annual rate of return based on
%        an effective annual percentage rate of 9.38% compounded 
%        monthly is represented as 
% 
%        apr = nomrr(.0938,12) returning apr = 0.09 or 9%.  
% 
%        

function taxedrr
%MATLAB Tour Partial Function Help:  fin_con
%
% TAXEDRR After-tax rate of return. 
%        R = TAXEDRR(RTN,TAX) calculates the after-tax rate of
%        return given the nominal rate of return, RTN, and tax rate, TAX. 
%  
%        For example, an investment has a rate of return of  
%        12% and is taxed at a rate of 30%.  The rate of  
%        return diminished by the tax rate is r = taxedrr(.12,.30)  
%        which returns r = 8.4%. 
% 
%        

function xirr
%MATLAB Tour Partial Function Help:  fin_con
%
% XIRR   Internal rate of return for nonperiodic cash flow. 
%        YLD = XIRR(CF,DF,GUESS,MAXITER) returns the internal rate of return  
%        for a nonperiodic schedule of cash flows.  CF is the cash flow data,  
%        DF is the corresponding date data, and GUESS is an initial estimate  
%        of the expected return.  MAXITER specifies the number of
%        iterations used by Newton’s method to solve for YLD.  By default,
%        guess = 0.1 and MAXITER = 50.  Include the initial investment as the
%        initial cash flow value (a negative number) in cf.  Enter dates in df
%        as serial date numbers or date strings. 
%  
%        An investment of $10,000 returns the following series of cash flows. 
%        Note that the original investment payment is included as the first 
%        cash flow value. 
%  
%                      Cash Flow              Dates 
%                       -10000           January 12, 1987 
%                         2500           February 14, 1988 
%                         2000           March 3, 1988 
%                         3000           June 14, 1988 
%                         4000           December 1, 1988 
%  
%        The variables CF and DF are defined as follows. 
%  
%        cf = [-10000,2500,2000,3000,4000]; 
%               df = ['01/12/1987'
%                     '02/14/1988'
%                     '03/03/1988'
%                     '06/14/1988'
%                     '12/01/1988'];
%   
%        The internal rate of return is yld = xirr(cf,df) or yld = 0.1006 
%        which is 10.06%. 
%  
%        

function payadv
%MATLAB Tour Partial Function Help:  fin_con
%
% PAYADV Periodic payment given number of advance payments.
%        P = PAYADV(RATE,NPER,PV,FV,ADV) returns the periodic payment
%        given a number of advance payments.  RATE is the lending or 
%        borrowing rate per period, NPER is the number of periods in 
%        the life of the instrument, PV is the present value, FV is the 
%        future value or target value to be attained after NPER periods, 
%        and ADV is the number of advance payments.  If the payments are 
%        made at the beginning of the period, add 1 to ADV.
% 
%        For example, the present value of a loan is $1000.00 and it will
%        be paid in full in 12 months.  The annual interest rate is 10% 
%        and 3 payments are made at closing time.  Using this data,
%        p = payadv(.1/12,12,1000,0,3) returns p = 85.94.
% 
%        

function payodd
%MATLAB Tour Partial Function Help:  fin_con
%
% PAYODD Payment of annuity with odd first period.
%        P = PAYODD(RATE,NPER,PV,FV,DYS) returns the payment 
%        for an annuity with an odd first period. RATE is the 
%        periodic interest rate, NPER is the number of periods, 
%        PV is the present value, FV is the future value, and 
%        DYS is the actual number of days until the first payment 
%        is made.  
% 
%        For example, a 2 year loan for $4000 has an annual interest 
%        rate of 11%.  The first payment will be made in 36 days.  
%        To find the monthly payment, p = payodd(.11/12,24,4000,0,36)
%        returns p = 186.77. 
% 
%        

function payper
%MATLAB Tour Partial Function Help:  fin_con
%
% PAYPER Periodic payment of loan or annuity.
%        P = PAYPER(RATE,NPER,PV,FV,DUE) returns the periodic
%        payment of a loan or an annuity.  RATE is the periodic 
%        interest rate, NPER is number of payment periods, PV is 
%        the present value, FV is the future value or remaining
%        balance after NPER, and DUE specifies whether the payments 
%        are made at the beginning (DUE = 1) or end (DUE = 0) of the 
%        period.  By default, FV = 0 and DUE = 0.
% 
%        For example, the payment for a 3 year loan of $9000 with an 
%        annual interest rate of 11.75% is calculated with 
%        p = payper(.1175/12,36,9000,0,0) which returns p = 297.86.  
% 
%        

function payuni
%MATLAB Tour Partial Function Help:  fin_con
%
% PAYUNI Uniform payment equal to varying cash flow.
%        US = PAYUNI(CF,RATE) returns the uniform series value, US, of
%        a cash flow, CF, given the periodic interest rate, RATE.  Include the 
%        initial investment as the initial cash flow value.
% 
%        Suppose an initial investment of $10,000 is made.  The following 
%        cash flow represents the yearly income realized by the investment.
%        The annual discount rate is 8%.
% 
%                       Year 1       $2000
%                       Year 2       $1500
%                       Year 3       $3000
%                       Year 4       $3800
%                       Year 5       $5000
% 
%        To calculate the uniform series value, 
%        use us = payuni([-10000 2000 1500 3000 3800 5000],.08) 
%        which returns us = 429.63.  
% 
%        

function bnddurp
%MATLAB Tour Partial Function Help:  fin_con
%
% BNDDURP Duration of Bond Given Price
% 
% This function calculates the Macaulay and Modified duration of NUMBONDS fixed
%      income securities given the clean price for each bond. This function
%      will determine the duration for a bond regardless of whether the bond's
%      coupon structure contains short or long first or last coupon periods
%      (i.e. regardless of whether the coupon structure is synched to 
%      maturity). This function will also determine the Macaulay and Modified
%      duration for a zero coupon bond.
% 
%      [ModDuration, YearDuration, PerDuration] = bnddurp(Price, CouponRate,
%           Settle, Maturity, Period, Basis, EndMonthRule, IssueDate,
%           FirstCouponDate, LastCouponDate, StartDate, Face)
% 
%  Inputs: Price (required) - Clean price of a bond (i.e. excluding any
%               accrued interest
%          CouponRate (required) - Coupon rate in decimal form
%          Settle (required) - Settlement date
%          Maturity (required) - Maturity date
%          Period - Coupons payments per year; default is 2
%          Basis - Day-count basis; default is 0 (actual/actual) 
%          EndMonthRule - End-of-month rule; default is 1 (in effect)
%          IssueDate - Bond issue date
%          FirstCouponDate - Irregular or normal first coupon date
%          LastCouponDate - Irregular or normal last coupon date
%          StartDate - Forward starting date of payments (Input ignored in 2.0)
%          Face - Face value of the bond; default is 100
%          
%          Unless specified as being required, all listed input arguments
%          are optional. All required arguments must be NUMBONDSx1 or 
%          1xNUMBONDS conforming vectors or scalar arguments. All optional 
%          arguments must be either NUMBONDSx1 or 1xNUMBONDS conforming 
%          vectors, scalars, or empty matrices. Fill unspecified entries in 
%          input vectors with the value NaN. Dates can be serial date numbers 
%          or date strings.
% 
%          For a detailed description of each input and output argument, at
%          the command line type: 'help ftb' + the argument name (e.g. for
%          help on Settle, type: "help ftbSettle").
% 
% Outputs: ModifiedDuration - Modified duration
%          YearDuration - Macaulay duration in years
%          PerDuration - Periodic Macaulay duration
%          
%          Outputs are NUMBONDS by 1 vectors
% 
% 

function bnddury
%MATLAB Tour Partial Function Help:  fin_con
%
% BNDDURY Duration of Bond Given Yield
% 
% This function calculates the Macaulay and Modified duration of NUMBONDS fixed
%      fixed income securities given yield to maturity. This function
%      will determine the duration for a bond regardless of whether the bond's
%      coupon structure contains short or long first or last coupon periods
%      (i.e. regardless of whether the coupon structure is synched to 
%      maturity). This function will also determine the Macaulay and Modified
%      duration for a zero coupon bond.
% 
%      [ModDuration, YearDuration, PerDuration] = bnddury(Yield, CouponRate,
%           Settle, Maturity, Period, Basis, EndMonthRule, IssueDate,
%           FirstCouponDate, LastCouponDate, StartDate, Face)
% 
%  Inputs: Yield (required) - Yield to maturity on a semi-annual basis
%          CouponRate (required) - Coupon rate in decimal form
%          Settle (required) - Settlement date
%          Maturity (required) - Maturity date
%          Period - Coupons payments per year; default is 2
%          Basis - Day-count basis; default is 0 (actual/actual) 
%          EndMonthRule - End-of-month rule; default is 1 (in effect)
%          IssueDate - Bond issue date
%          FirstCouponDate - Irregular or normal first coupon date
%          LastCouponDate - Irregular or normal last coupon date
%          StartDate - Forward starting date of payments (Input ignored in 2.0)
%          Face - Face value of the bond; default is 100
%          
%          Unless specified as being required, all listed input arguments
%          are optional. All required arguments must be NUMBONDSx1 or 
%          1xNUMBONDS conforming vectors or scalar arguments. All optional 
%          arguments must be either NUMBONDSx1 or 1xNUMBONDS conforming 
%          vectors, scalars, or empty matrices. Fill unspecified entries in 
%          input vectors with the value NaN. Dates can be serial date numbers 
%          or date strings.
% 
%          For a detailed description of each input and output argument, at
%          the command line type: 'help ftb' + the argument name (e.g. for
%          help on Settle, type: "help ftbSettle").
% 
% Outputs: ModifiedDuration - Modified duration
%          YearDuration - Macaulay duration in years
%          PerDuration - Periodic Macaulay duration
%          
%          Outputs are NUMBONDS by 1 vectors
% 
% 

function bndconvp
%MATLAB Tour Partial Function Help:  fin_con
%
% BNDCONVY Convexity of Bond Given Price
% 
% This function calculates the convexity of NUMBONDS fixed income securities
%      given a clean price for each bond. This function will determine
%      the convexity for a bond regardless of whether the bond's
%      coupon structure contains short or long first or last coupon periods
%      (i.e. regardless of whether the coupon structure is synched to 
%      maturity). This function will also determine the convexity of a 
%      zero coupon bond.
% 
%      [YearConvexity, PerConvexity] = bndconvp(Price, CouponRate,
%           Settle, Maturity, Period, Basis, EndMonthRule, IssueDate,
%           FirstCouponDate, LastCouponDate, StartDate, Face)
% 
%  Inputs: Price (required) - Clean price
%          CouponRate (required) - Coupon rate in decimal form
%          Settle (required) - Settlement date
%          Maturity (required) - Maturity date
%          Period - Coupons payments per year; default is 2
%          Basis - Day-count basis; default is 0 (actual/actual) 
%          EndMonthRule - End-of-month rule; default is 1 (in effect)
%          IssueDate - Bond issue date
%          FirstCouponDate - Irregular or normal first coupon date
%          LastCouponDate - Irregular or normal last coupon date
%          StartDate - Forward starting date of payments (Input ignored in 2.0)
%          Face - Face value of the bond; default is 100
%          
%          Unless specified as being required, all listed input arguments
%          are optional. All required arguments must be NUMBONDSx1 or 
%          1xNUMBONDS conforming vectors or scalar arguments. All optional 
%          arguments must be either NUMBONDSx1 or 1xNUMBONDS conforming 
%          vectors, scalars, or empty matrices. Fill unspecified entries in 
%          input vectors with the value NaN. Dates can be serial date numbers 
%          or date strings.
% 
%          For a detailed description of each input and output argument, at
%          the command line type: 'help ftb' + the argument name (e.g. for
%          help on Settle, type: "help ftbSettle").
% 
% Outputs: YearConvexity - Yearly convexity
%          PerConvexity - Periodic convexity
%          
%          Outputs are NUMBONDS by 1 vectors
% 
% 

function bndconvy
%MATLAB Tour Partial Function Help:  fin_con
%
% BNDCONVY Convexity of Bond Given Yield
% 
% This function calculates the convexity of NUMBONDS fixed income securities
%      given yield to maturity for each bond. This function will determine
%      the convexity for a bond regardless of whether the bond's
%      coupon structure contains short or long first or last coupon periods
%      (i.e. regardless of whether the coupon structure is synched to 
%      maturity). This function will also determine the convexity of a 
%      zero coupon bond.
% 
%      [YearConvexity, PerConvexity] = bndconvy(Yield, CouponRate,
%           Settle, Maturity, Period, Basis, EndMonthRule, IssueDate,
%           FirstCouponDate, LastCouponDate, StartDate, Face)
% 
%  Inputs: Yield (required) - Yield to maturity on a semi-annual basis
%          CouponRate (required) - Coupon rate in decimal form
%          Settle (required) - Settlement date
%          Maturity (required) - Maturity date
%          Period - Coupons payments per year; default is 2
%          Basis - Day-count basis; default is 0 (actual/actual) 
%          EndMonthRule - End-of-month rule; default is 1 (in effect)
%          IssueDate - Bond issue date
%          FirstCouponDate - Irregular or normal first coupon date
%          LastCouponDate - Irregular or normal last coupon date
%          StartDate - Forward starting date of payments (Input ignored in 2.0)
%          Face - Face value of the bond; default is 100
%          
%          Unless specified as being required, all listed input arguments
%          are optional. All required arguments must be NUMBONDSx1 or 
%          1xNUMBONDS conforming vectors or scalar arguments. All optional 
%          arguments must be either NUMBONDSx1 or 1xNUMBONDS conforming 
%          vectors, scalars, or empty matrices. Fill unspecified entries in 
%          input vectors with the value NaN. Dates can be serial date numbers 
%          or date strings.
% 
%          For a detailed description of each input and output argument, at
%          the command line type: 'help ftb' + the argument name (e.g. for
%          help on Settle, type: "help ftbSettle").
% 
% Outputs: YearConvexity - Yearly convexity
%          PerConvexity - Periodic convexity
%          
%          Outputs are NUMBONDS by 1 vectors
% 
% 

function bondconv
%MATLAB Tour Partial Function Help:  fin_con
%
% BONDCONV Convexity. 
%        [PC,YC] = BONDCONV(SD,MD,RV,CPN,YLD,PER,BASIS) returns the
%        convexity for a security in periods pc and years yc.  SD is the
%        settlement date, MD is the maturity date, RV is the par value, CPN is
%        the coupon rate, YLD is the yield, PER is the number of periods per
%        year (default = 2), and BASIS is the day-count basis: 0 =
%        actual/actual (default), 1 = 30/360, 2 = actual/360, 3 = actual/365.
%        Enter dates as serial date numbers or date strings.
%        
%        For example, given this data:
%        
%               settlement date 01-Dec-1994
%               maturity date 01-Jan-2000
%               par value $100.00
%               coupon rate 5%
%               yield 4.34%
%               periods semi-annual
%               basis actual/actual
%        
%               [pc,yc] = bondconv('12/1/1994','1/1/2000',100,0.05,0.0434,2,0)
%        
%               returns pc = 92.13 periods and yc = 23.03 years.
%  
%        

function bonddur
%MATLAB Tour Partial Function Help:  fin_con
%
% BONDDUR Macaulay and modified durations. 
%        [D,M] =  BONDDUR(SD,MD,RV,CPN,YLD,PER,BASIS) finds the
%        Macaulay duration d and modified duration m in years for a security
%        with periodic interest payments.  SD is the settlement date, MD is the
%        maturity date, CPN is the coupon rate, YLD is the yield, PER is the
%        number of periods per year (default = 2), and BASIS is the day-count
%        basis: 0 = actual/actual (default), 1 = 30/360, 2 = actual/360, 3 =
%        actual/365.  Enter dates as serial date numbers or date strings.
%        
%        For example, given this data:
%        
%               settlement date 01-Dec-1994
%               maturity date 01-Jan-2000
%               par value $100.00
%               coupon rate 5%
%               yield 4.34%
%               periods semi-annual
%               basis actual/actual
%        
%               [d,m] = bonddur('12/1/1994','1/1/2000',100,0.05,0.0434,2,0)
%        
%               returns a Macaulay duration d = 4.4720 years and a modified
%               duration m = 4.3770 years. 
%  
%        

function cfconv
%MATLAB Tour Partial Function Help:  fin_con
%
% CFCONV Cash flow convexity. 
%        CX = CFCONV(CF,YLD) calculates the convexity C of a cash flow  
%        given the cash flow, CF, and the periodic yield, YLD. 
%  
%        For example, nine payments of $2.50 and a final payment 
%        $102.50 with a yield of 2.5% returns a convexity of  
%        90.45 periods. 
%  
%        

function cfdur
%MATLAB Tour Partial Function Help:  fin_con
%
% CFDUR  Cash flow duration and modified duration. 
%        [D,MD] = CFDUR(CF,YLD) calculates the duration D and modified  
%        duration (volatility) MD of a cash flow given the cash  
%        flow, CF, and the periodic yield, YLD.  
%  
%        For example, nine payments of $2.50 and a final payment 
%        $102.50 with a yield of 2.5% returns a duration of 8.97 
%        periods and a modified duration of 8.75 periods. 
%  
%        

function amortize
%MATLAB Tour Partial Function Help:  fin_con
%
% AMORTIZE Amortization.  
%        [PRINP,INTP,BAL,P] = AMORTIZE(RATE,NPER,PV,FV,DUE) returns   
%        the principal and interest portions of a loan paid by a periodic  
%        payment and computes the remaining balance of the original loan amount  
%        and the periodic payment.  RATE is the periodic interest rate charged,  
%        NPER is number of payment periods, PV is the present value of the  
%        loan, FV is the future value of the loan, and DUE specifies whether  
%        the payments are made at the beginning (due = 1) or end (due = 0) of  
%        the period.  By default, fv = 0 and due = 0.  prinp is a vector of the  
%        principal paid in each period, intp is a vector of the interest paid  
%        in each period, bal is the remaining balance of the loan in each  
%        payment period, and p is the periodic payment calculated by the  
%        payment function.  The outputs prinp, intp, and bal are 1-by-nper  
%        vectors and p is a scalar value.  
%  
%        For example, find the values for a $500 loan paid in six installments at an  
%        annual interest rate of 9%:  
%          
%               [prinp, intp, bal, p] = amortize(0.09/6, 6, 500)  
%          
%               returns  
%          
%               prinp = [81.47 82.69 83.93 85.19 86.47 87.76]  
%               intp = [6.30 5.07 3.83 2.57 1.30 0.00]  
%               bal = [419.74 338.27 255.58 171.65 86.47 0.00]  
%               p = 87.76  
%     
%        

function depfixdb
%MATLAB Tour Partial Function Help:  fin_con
%
% DEPFIXDB Fixed declining-balance depreciation. 
%        D = DEPFIXDB(COST,SALVAGE,LIFE,PERIOD,MONTH) calculates D, 
%        the fixed declining-balance depreciation for the period. 
%        COST is the initial value of the asset, SALVAGE is the  
%        salvage value of the asset, LIFE is the life of the asset  
%        in years, and PERIOD is the number of periods used to  
%        perform the calculation.  The default value for MONTH is 12  
%        which represents the number months in the first year of the  
%        life of the asset.  
%  
%        For example, a car is purchased for $11,000 with a  
%        salvage value $1500 and a lifetime of eight years. To calculate the depreciation for the
%        first five years:
%        
%               d = depfixdb(11000,1500,8,5)
%        
%               returns d = [2425.08 1890.44 1473.67 1148.78 895.52]
%  
%        

function depgendb
%MATLAB Tour Partial Function Help:  fin_con
%
% DEPGENDB Declining-balance depreciation. 
%        D = DEPGENDB(COST,SALVAGE,LIFE,FACTOR) calculates D, 
%        the declining-balance depreciation for each period. 
%        COST is the cost of the asset and SALVAGE is the estimated  
%        salvage value of the asset.  LIFE is the number of periods  
%        over which the asset is depreciated and FACTOR is the  
%        depreciation factor.  A FACTOR of 2 uses the double-declining-balance  
%        method.   
%  
%        For example, a car is purchased for $11,000 and is  
%        to be depreciated over 5 years.  The estimated salvage  
%        value is $1000.  Using the double-declining-balance method, 
%        the depreciation for each year is calculated and also  
%        returned is the remaining depreciable value at the end of  
%        the life of the car. 
%  
%        d = depgendb(11000,1000,5,2) returns  
%  
%        d = [4400.00,2640.00,1584.00,950.40,425.60]. 
%  
%        

function deprdv
%MATLAB Tour Partial Function Help:  fin_con
%
% DEPRDV Remaining depreciable value. 
%        R = DEPRDV(COST,SALVAGE,ACCUM) returns the remaining 
%        depreciable value for an asset given the COST,  
%        SALVAGE value, and the accumulated depreciation ACCUM 
%        of the asset for the prior periods.   
%  
%        For example, the cost of an asset is $13,000 with  
%        a life of 10 years.  The salvage value of the asset 
%        is $1000.  To find the remaining depreciable value  
%        after 6 years, use the following commands.  Find the  
%        accumulated depreciation with the straight-line  
%        depreciation function, DEPSTLN. 
%  
%        accum = depstln(13000,1000,10)*6 = 7200. 
%        r = deprdv(13000,1000,7200) = 4800. 
%  
%        

function depsoyd
%MATLAB Tour Partial Function Help:  fin_con
%
% DEPSOYD Sum of years' digits depreciation. 
%        SD = DEPSOYD(COST,SALVAGE,LIFE) calculates the depreciation for an 
%        asset using the sum of years' digits method given the COST, SALVAGE value, 
%        and depreciable LIFE of the asset.  SD is a vector of depreciation 
%        values with each element corresponding to a year of the asset's life.   
%  
%        For example, the cost of an asset is $13,000 with a life of 10 years. 
%        The salvage value of the asset is $1000.  
% 
%               SD=depsoyd(13000,1000,10)
%        
%               returns SD = [2181.82 1963.64 1745.45 1527.27 1309.09
%                            1090.91 872.73 654.55 436.36 218.18]
% 
%        The depreciation for the fifth calendar year is SD(5) or $1309.09. 
%  
%        

function depstln
%MATLAB Tour Partial Function Help:  fin_con
%
% DEPSTLN Straight line depreciation. 
%        SL = DEPSTLN(COST,SALVAGE,LIFE) calculates straight line depreciation 
%        for an asset given the COST, SALVAGE value, and depreciable LIFE 
%        of the asset. For example, the cost of an asset is $13,000 with a life 
%        of 10 years.  The salvage value of the asset is $1000.   
%  
%        SL = depstln(13000,1000,10) returns SL = $1200. 
%  
%        

function bdtbond
%MATLAB Tour Partial Function Help:  fin_con
%
% BDTBOND Black-Derman-Toy pricing of option-embedded bonds
%   Computes price and sensitivity measures of a bond with embedded
%   call or put options.  Valuation is based on the Black-Derman-Toy
%   model for pricing interest rate options given an input yield
%   curve (and possibly a credit spread) and volatility curve.
% 
%   [Price, Sensitivities, DiscTree, PriceTree] = bdtbond(OptBond, ...
%     ZeroCurve, VolatilityCurve, Accuracy, CreditCurve, ComputeSensitivity)
% 
%   The arguments other than Accuracy are structures.  The name of
%   the argument variable can be substituted, but the fieldnames
%   must be reproduced exactly.  The variables and the fields are
%   listed below in Variable.fieldname format.  An optional field or
%   variable may be set to the empty matrix [] to invoke defaults.
%   An optional field in a structure may also be left unspecified.
% 
%   Inputs:
%     OptBond : (required) specification of the underlying bond
%     with a possible call and put option.  Fields are scalars or
%     date strings. 
% 
%       Bond specification fields for the underlying bond.  See the
%       help header FTB for detailed information on bond parameters.
% 
%     - OptBond.Settle : (required) Settlement date.
%     - OptBond.Maturity : (required) Maturity date.
%     - OptBond.Period : (optional) Coupon frequency.  Default is 2.
%     - OptBond.Basis : (optional) Market Basis.  Default is 0 (actual/actual).
%     - OptBond.EndMonthRule : (optional) EOM rule.  Default is 1 (in effect).
%     - OptBond.FirstCouponDate : (optional) First coupon payment if
%       the first coupon period is irregular.
%     - OptBond.LastCouponDate : (optional) Last coupon payment before
%       maturity if the last coupon period is irregular.
%     - OptBond.IssueDate : (optional) Issue date of the bond if the
%       first coupon period is irregular.
%     - OptBond.StartDate : (optional) Forward start date of the
%       security if not before Settlement.
%     - OptBond.CouponRate : (optional) Coupon payment rate.  
%     - OptBond.Face : (optional) Maturity payment of the bond.
%       Default is 100.
% 
%       Option specification fields:  Fields for either a call or a
%       put may be specified.  Calls are assumed to be held by the
%       bond issuer, while puts are assumed to be held by the bond
%       holder.  A call therefore reduces the value of the bond to
%       the bond holder, while a put increases the value of the bond.
% 
%     - OptBond.CallStrike : (required) call option strike price.
%     - OptBond.CallType : (optional) flag 1 (American) or 0 (European).
%       The default is an American option (CallType = 1).
%     - OptBond.CallExpiryDate : (optional) last possible date of
%       exercise for an American option, or only date for a European
%       option.  The default is the Maturity of the bond.
%     - OptBond.CallStartDate : (optional) first possible date of
%       exercise for an American option.  The default is bond Settlement.
% 
%     - OptBond.PutStrike : (required) put option strike price.
%     - OptBond.PutType : (optional) flag 1 (American) or 0 (European).
%       The default is an American option (PutType = 1).
%     - OptBond.PutExpiryDate : (optional) last possible date of
%       exercise for an American option, or only date for a European
%       option.  The default is the Maturity of the bond.
%     - OptBond.PutStartDate : (optional) first possible date of
%       exercise for an American option.  The default is bond Settlement.
% 
%     
%     ZeroCurve : (required) The yield curve of NCURVE (date, decimal rate)
%     pairs is interpolated to cover the time span of the bond.  Times
%     before the first curve date use the first rate, and times after 
%     the last curve date use the last rate.  
%     - ZeroCurve.CurveDates : (required) [NCURVE by 1] vector of maturity
%       dates.  Dates are date strings or serial date numbers.
%     - ZeroCurve.ZeroRates  : (required) [NCURVE by 1] vector of rates.
% 
%     VolatilityCurve : (required) The curve of instantaneous 
%     volatilities of the short rates.  The curve consists of
%     NCURVE2 (date, decimal rate) pairs.  The curve will be
%     interpolated to cover the time span of the bond.  
%     - VolatilityCurve.CurveDates : (required) [NCURVE2 by 1]
%       vector of dates.
%     - VolatilityCurve.VolatilityRates : (required) [NCURVE2 by 1]
%       vector of yearly volatilities in decimal form.
% 
%     Accuracy : (required) This argument is NOT a structure.  The
%     scalar value Accuracy specifies the number of steps in the
%     tree per semi-annual coupon interval.  Larger numbers yield more 
%     accurate answers, but require more time and memory.
% 
%     CreditCurve : (optional) The curve of zero rate spreads arising
%     from default risk.  The curve has NCURVE3 (date, basis point)
%     pairs.  The curve will be interpolated to cover the time span
%     of the bond. 
%     - CreditCurve.CurveDates : (required) [NCURVE3 by 1] vector of
%       serial dates or date strings.
%     - CreditCurve.CreditRates : (required) [NCURVE3 by 1] vector
%       of credit spread values in basis points (not decimal rates).
%       The effective change to the zero rate is CreditRates/10000.
% 
%     ComputeSensitivity : (optional)  Specify if bond sensitivity
%     measures (with and without options) are to be computed.  A
%     value of 1 in the field indicates that the measure will be
%     computed, while a value of 0 specifies the measure will
%     not be computed.  Sensitivities are found by a finite
%     difference calculation.  The default is no sensitivities: only
%     prices are returned. 
%     - ComputeSensitivity.Duration: (required) scalar 1 or 0.
%     - ComputeSensitivity.Convexity: (required) scalar 1 or 0.
%     - ComputeSensitivity.Vega: (required) scalar 1 or 0.
% 
% 
%   Outputs:
%     Price : value of the bond with and without the options
%     - Price.OptionFreePrice : scalar price of the bond without any
%       options.
%     - Price.OptionEmbedPrice : scalar price (value to the holder
%       of the bond) of the bond with options.
%     - Price.OptionValue : scalar value to the holder of the bond
%       of the options.
%      
%     Sensitivities
%     - Sensitivities.Duration : Sensitivity of option-free bond price
%       to parallel shifts of the yield curve.
%     - Sensitivities.EffDuration : Sensitivity of the
%       option-embedded price to shifts of the yield curve.
%     - Sensitivities.Convexity : Sensitivity of Duration to shifts
%       in the yield curve.
%     - Sensitivities.EffConvexity : Sensitivity of EffDuration to
%       shifts in the yield curve.
%     - Sensitivities.Vega : Sensitivity of the option-embedded
%       price to parallel shifts of the volatility curve.
% 
%     DiscTree : recombining binomial tree of the interest rate
%     structure.  The tree covers NPERIODS times from Settlement to
%     Maturity, where there are Accuracy steps in each coupon
%     period.  The short rate at settlement and between settlement
%     and the first time is deterministic.  
%     - DiscTree.Values : [NSTATES by NPERIODS] matrix of short discount
%       factors.  The NPERIODS columns of Values correspond to successive
%       times.  The NSTATES rows correspond to states in the rate
%       process.  Unused states are masked by the value NaN.
%       Multiplication of a cash amount at time Dates(i) by the
%       discount Values(j,i) gives the price at Dates(i-1) after
%       traversing the (j,i) edge of the tree.  The short rate R(j,i)
%       prevailing at node (j,i) satisfies:
%       ( 1 + R(j,i)/Frequency)^(-(Times(j)-Times(j-1))) = Values(j,i)
%     - DiscTree.Times: [1 by NPERIODS] vector of tree node times in
%       units of coupon intervals.  (See ftbTFactors).
%       DiscTree.Dates: [1 by NPERIODS] vector of tree node times as
%       serial date numbers.
%     - DiscTree.Type : 'Short Discount'
%     - DiscTree.Frequency : The compounding frequency of the input bond.
%     - DiscTree.ErrorFlag : (0 or 1).  This is set to 1 if any
%       short rates become negative.
% 
%     PriceTree : recombining binomial tree of cash amounts at tree
%     nodes.  The Price Tree is computed from the bond cash flows
%     and the option payoffs.  The clean price of the bond is the
%     Price Tree Value minus the coupon payment and the accrued interest.
%     - PriceTree.Values [NSTATES by NPERIODS] matrix of price states.
%     - PriceTree.Times: [1 by NPERIODS] vector of tree node times in
%       units of coupon intervals.  (See ftbTFactors).
%     - PriceTree.Dates: [1 by NPERIODS] vector of tree node times as
%       serial date numbers.
%     - PriceTree.AccrInt: [1 by NPERIODS] vector of accrued
%       interest payable at each time.
%     - PriceTree.Coupons: [1 by NPERIODS] vector of coupon payments
%       at each time.
%     - DiscTree.Type : 'Price'
% 
%  

function bdttrans
%MATLAB Tour Partial Function Help:  fin_con
%
%  BDTTRANS Translate a tree returned by BDTBOND.
%  Unpack and convert a Short Discount tree structure to a Short Rate tree,
%  or a Price tree structure to a Clean Price tree.  The output is a matrix
%  of tree node values and a vector of node times.
% 
%  Usage:
%    [TreeMat, TreeTimes] = bdttrans(Tree)
%    bdttrans(Tree)
%  
%  Inputs:
%    Tree : Tree structure returned by BDTBOND.
% 
%  Outputs
%    TreeMat : [NSTATES by NTIMES] Converted matrix of Short Rate or
%    Clean Price values at points on the tree.  Time layers are
%    columns containing the different states.  Unused entries of the
%    matrix are screened with NaN's
% 
%    TreeTimes: [1 by NTIMES] Vector of times corresponding to
%    layers of TreeMat. 
%  
%  If BDTTRANS is called without output arguments, it plots the translated
%  tree against the time axis in coupon intervals.
% 
%  

function binprice
%MATLAB Tour Partial Function Help:  fin_con
%
% BINPRICE Binomial put and call pricing. 
%        [PR,OPT] = BINPRICE(SO,X,R,T,DT,SIG,FLAG,Q,DIV,EXDIV)  
%        prices an option using a binomial pricing model. SO is the underlying 
%        asset price, X is the option exercise price, R is the risk-free 
%        interest rate, T is the option's time until maturity in years and DT 
%        is the time increment within T. DT will be adjusted so that the 
%        length of each interval is consistent with  the maturity time of the 
%        option. SIG is the asset’s volatility, FLAG specifies whether the 
%        option is a call (flag = 1) or a put (flag = 0), Q is the dividend rate,
%        DIV is the dividend payment at an ex-dividend date, EXDIV. EXDIV is 
%        specified in number of periods.  All inputs to this function are
%        scalar values except DIV and EXDIV which are 1-by-n vectors.  For each
%        dividend payment, there must be a corresponding ex-dividend date.  
%        By default q,div, and EXDIV equal 0.  If a value is entered for the
%        dividend rate q, DIV and EXDIV should equal 0 or not be entered.
%        If values are entered for DIV and EXDIV, set Q = 0. 
%  
%        [P,O] = binprice(52,50,.1,5/12,1/12,.4,0,0,2.06,3.5) returns 
%        the asset price and option value at each node of the binary 
%        tree. 
%  
%        P = 
%  
%         52.0000   58.1367   65.0226   72.7494   79.3515   89.0642 
%               0   46.5642   52.0336   58.1706   62.9882   70.6980 
%               0         0   41.7231   46.5981   49.9992   56.1192 
%               0         0         0   37.4120   39.6887   44.5467 
%               0         0         0         0   31.5044   35.3606 
%               0         0         0         0         0   28.0688 
%  
%        O = 
%  
%          4.4404    2.1627    0.6361         0         0         0 
%               0    6.8611    3.7715    1.3018         0         0 
%               0         0   10.1591    6.3785    2.6645         0 
%               0         0         0   14.2245   10.3113    5.4533 
%               0         0         0         0   18.4956   14.6394 
%               0         0         0         0         0   21.9312 
%  
%        

function blkprice
%MATLAB Tour Partial Function Help:  fin_con
%
% BLKPRICE Black's option pricing.
% 
%      [c, p] = blkprice(f, x, r, t, sig)
% 
%      Summary: This function uses Black's Model to determine the call and put option values
%               on futures given a forward price, strike price, risk free interest rate,
%               time to maturity, and volatility
% 
%       Inputs: f - value for the forward price of the underlying asset at time zero
%               x - value for the strike price of the call and put options
%               r - value for the risk free interest rate (plus storage costs less
%                    less any convenience yield)
%               t - value for the time to maturity or expiry of the option
%               sig - value for the volatility of the price of the underlying asset
% 
%               Note: Black's Model can be extended to value interest rate derivatives in
%                     the form of call and put options embedded in bonds by deriving the
%                     forward price as follows:
% 
%                     f = (B - I) * exp(R*t)
% 
%                     where:
%                     
%                     B - the face value of the bond
%                     I - the present value of the coupons during the life of the option
%                          (i.e. from time zero until expiry of the option)
%                     r - the riskless rate (plus storage costs less any convenience yield)
%                     t - time from time zero until expiry of the option
% 
%      Outputs: c - Price of the call option
%               p - Price of the put option
% 
%      Example: [c, p] = blkprice(95, 98, 0.11, 3, 0.025)
% 
%               returns:
% 
%               c = 0.4162 (or $0.42)
%               p = 2.5729 (or $2.57)
% 
%    

function blsdelta
%MATLAB Tour Partial Function Help:  fin_con
%
% BLSDELTA Black-Scholes sensitivity to underlying price change.  
%        [CD,PD] = BLSDELTA(SO,X,R,T,SIG,Q) returns sensitivity in   
%        option value to change in the underlying security price.  Delta is 
%        also known as the hedge ratio.  SO is the current stock price, X is 
%        the exercise price, R is the risk-free interest rate, T is the time to 
%        maturity of the option in years, SIG is the standard deviation of the 
%        annualized continuously compounded rate of return of the stock (also 
%        known as the volatility), and Q is the dividend rate or the foreign 
%        interest rate where applicable.  The default Q is 0.  CD is the delta 
%        of a call option, and PD is the delta of a put option. 
%         
%               Note: This function uses normcdf, the normal cumulative 
%        distribution function in the Statistics Toolbox. 
%   
%        For example, [c,p] = blsdelta(50,50,.1,.25,.3,0) returns  
%        c = 0.5955 and p = -0.4045.  
%   
%        

function blsgamma
%MATLAB Tour Partial Function Help:  fin_con
%
% BLSGAMMA Black-Scholes sensitivity to underlying delta change. 
%        G = BLSGAMMA(SO,X,R,T,SIG) returns sensitivity of delta 
%        to change in the underlying security price.  SO is the current stock
%        price, X is the exercise price, R is the risk-free interest rate, T is
%        the time to maturity of the option in years, SIG is the standard
%        deviation of the annualized continuously compounded rate of return of
%        the stock (also known as the volatility), and Q is the dividend rate.
%        The default Q is 0.
%        
%               Note: This function uses normpdf, the normal probability
%        density function in the Statistics Toolbox.
%  
%        For example, g = blsgamma(50,50,.12,.25,.3,0) returns g = 0.0512. 
%  
%        

function blsimpv
%MATLAB Tour Partial Function Help:  fin_con
%
% BLSIMPV Black-Scholes implied volatility. 
%        V = BLSIMPV(SO,X,R,T,CALL,MAXITER) returns the implied
%        volatility of an underlying asset given the current asset price SO,
%        the exercise price X, the risk free interest rate R, the time to
%        maturity in years T, and the call option value call.  This function
%        solves for the implied volatility V, using Newton’s method.
%        MAXITER is the maximum number of iterations used in solving for V.  By
%        default, MAXITER = 50.
%        
%               Note: This function uses normcdf and normpdf, the normal
%        cumulative distribution and normal probability density functions in
%        the Statistics Toolbox. 
%  
%        For example, an asset has a current price of $100, an 
%        exercise price of $95, the risk free interest rate is 
%        7.5% and the time to maturity of the option is .25 years. 
%        The call option has a value of $10.00.  
%  
%        Using blsimpv(100,95,.075,.25,10) returns an implied volatility 
%        of .31 or 31%. 
%  
%        

function blsprice
%MATLAB Tour Partial Function Help:  fin_con
%
% BLSPRICE Black-Scholes put and call pricing. 
%        [CALL,PUT] = BLSPRICE(SO,X,R,T,SIG,Q) returns the value of
%        call and put options using the Black-Scholes pricing formula.  SO is
%        the current asset price, X is the exercise price, R is the risk-free
%        interest rate, T is the time to maturity of the option in years, SIG
%        is the standard deviation of the annualized continuously compounded
%        rate of return of the asset (also known as volatility), and Q is the
%        dividend rate of the asset.  The default Q is 0. 
%        
%               Note: This function uses normcdf, the normal cumulative
%        distribution function in the Statistics Toolbox.
%  
%        For example, the current price an asset is $100, the exercise price 
%        of the option is $95, the risk-free interest rate is 10%, the time 
%        to maturity of the option is .25 years, and the standard deviation of 
%        of the asset is 50%.  Using this data,  
%  
%        call = blsprice(100,95,.1,.25,.5,0) 
%  
%        returns a call option price of $13.70. 
%         
%        Reference: Bodie, Kane, and Marcus, Investments, page 681. 
%  
%        

function blsrho
%MATLAB Tour Partial Function Help:  fin_con
%
% BLSRHO Black-Scholes sensitivity to interest rate change. 
%        [CR,PR]= BLSRHO(SO,X,R,T,SIG,Q) returns the rate of change
%        in value of securities with respect to interest rates.  SO is the
%        current security price, X is the exercise or strike price, R is the
%        interest rate, T is the time until maturity expressed in years, SIG is
%        the volatility (standard deviation), and Q is the dividend rate.  The
%        default Q is 0.  CR is the call option rho and PR is the put option
%        rho.
%        
%               Note: This function uses normcdf, the normal cumulative
%        distribution function in the Statistics Toolbox. 
%  
%        For example, [c,p] = blsrho(50,50,.12,.25,.3,0) returns 
%        c = 6.6686 and p = -5.4619. 
%  
%        

function blstheta
%MATLAB Tour Partial Function Help:  fin_con
%
% BLSTHETA Black-Scholes sensitivity to time until maturity change. 
%        [CT,PT] = BLSTHETA(SO,X,R,T,SIG,Q) returns sensitivity in
%        option value with respect to time.  SO is the current stock price, X
%        is the exercise price, R is the risk-free interest rate, T is the time
%        to maturity of the option in years, SIG is the standard deviation of
%        the annualized continuously compounded rate of return of the stock
%        (also known as volatility), and Q is the dividend rate.  The default Q
%        is 0.  CT is the theta of a call option, and PT is the theta of a put
%        option. 
%        
%               Note: This function uses normpdf, the normal probability
%        density function and normcdf, the normal cumulative distribution
%        function in the Statistics Toolbox. 
%  
%        For example, [c,p] = blstheta(50,50,.12,.25,.3,0) returns  
%        c = -8.9630 and p = -3.1404. 
%  
%        

function blsvega
%MATLAB Tour Partial Function Help:  fin_con
%
% BLSVEGA Black-Scholes sensitivity to underlying price volatility. 
%        V = BLSVEGA(SO,X,R,T,SIG,Q) returns the rate of change of
%        the option value with respect to the volatility of the underlying
%        asset.  SO is the current stock price, X is the exercise price, R is
%        the risk-free interest rate, T is the time to maturity of the option
%        in years, SIG is the standard deviation of the annualized continuously
%        compounded rate of return of the stock (also known as volatility), and
%        q is the dividend rate.  The default Q is 0.
%        
%               Note: This function uses normpdf, the normal probability
%        density function in the Statistics Toolbox.
%  
%        For example, v = blsvega(50,50,.12,.15,.3,0) returns v = 7.5522. 
%  
%        

function opprofit
%MATLAB Tour Partial Function Help:  fin_con
%
% OPPROFIT Option profit.
%        P = OPPROFIT(SO,X,COST,FLAG,TYPE) returns the profit of an option given
%        the asset price, SO, strike price, X, and cost of the option, COST.
%        FLAG specifies if option is long (FLAG = 0) or short (FLAG = 1).  
%        TYPE determines whether the option is a call (TYPE = 0) or a put 
%        (TYPE = 1).
%  
%        For example, buying (long) a call option with a strike price
%        $90 on an underlying asset with a current price of $100 for 
%        a price of $4 returns a profit of $6 if the option is 
%        exercised under these conditions.
% 
%        

function ugarch
%MATLAB Tour Partial Function Help:  fin_con
%
% UGARCH Univariate GARCH(P,Q) parameter estimation with Gaussian innovations.
% 
%  [Kappa , Alpha , Beta] = ugarch(U , P , Q)
% 
%  Inputs:
%    U: Single column vector of random disturbances (i.e., the residuals, 
%       or innovations, of an econometric model) representing a mean-zero, 
%       discrete-time stochastic process. The innovations time series U is 
%       assumed to follow a GARCH(P,Q) process. 
% 
%    P: Non-negative, scalar integer representing a model order of the GARCH 
%       process: P is the number of lags of the conditional variance included 
%       in the GARCH process. Note that P can be zero; when P = 0, a GARCH(0,Q)
%       process is actually an ARCH(Q) process.
% 
%    Q: Positive, scalar integer representing a model order of the GARCH 
%       process: Q is the number of lags of the squared innovations included 
%       in the GARCH process. 
% 
%  Outputs:
%    Kappa: Estimated scalar constant term of the GARCH process. 
% 
%    Alpha: P by 1 column vector of estimated coefficients, where P is the
%       number of lags of the conditional variance included in the GARCH process.
% 
%    Beta: Q by 1 column vector of estimated coefficients, where Q is the 
%       number of lags of the squared innovations included in the GARCH process.
% 
%  Notes:
%    GARCH(P,Q) coefficients {Kappa, Alpha, Beta} are subject to constraints:
%      (1) Kappa > 0
%      (2) Alpha(i) >= 0 for i = 1,2,...P
%      (3) Beta(i)  >= 0 for i = 1,2,...Q
%      (4) sum(Alpha(i) + Beta(j)) < 1 for i = 1,2,...P and j = 1,2,...Q
% 
%    The time-conditional variance, H(t), of a GARCH(P,Q) process is modeled 
%    as follows:
% 
%      H(t) = Kappa + Alpha(1)*H(t-1) + Alpha(2)*H(t-2) +...+ Alpha(P)*H(t-P)
%                   + Beta(1)*U^2(t-1)+ Beta(2)*U^2(t-2)+...+ Beta(Q)*U^2(t-Q)
% 
%    Note that U is a vector of innovations, or regression residuals of an
%    econometric model, representing a mean-zero, discrete-time stochastic 
%    process. That is, it is assumed that a regression model has already been
%    run, and that U(t) = y(t) - F(X(t),B) is the time series of innovations 
%    derived from the model. 
% 
%    Although H is generated via the equation above, U and H are related:
% 
%      U(t) = sqrt(H(t))*v(t), where {v(t)} is an i.i.d. sequence ~ N(0,1).
% 
%  

function ugarchllf
%MATLAB Tour Partial Function Help:  fin_con
%
% UGARCHLLF Log-likelihood objective function of univariate GARCH(P,Q)
%           processes with Gaussian innovations.
% 
%  LogLikelihood = ugarchllf(Parameters , U , P , Q)
% 
%  Inputs:
%    Parameters: (1 + P + Q) by 1 column vector of GARCH(P,Q) process 
%       parameters. The first element is the scalar constant term of the 
%       GARCH process; the next P elements are coefficients associated with 
%       the P lags of the conditional variance terms; the next Q elements 
%       are coefficients associated with the Q lags of the squared innovations
%       terms.
% 
%    U: Single column vector of random disturbances (i.e., the residuals, 
%       or innovations, of an econometric model) representing a mean-zero, 
%       discrete-time stochastic process. The innovations time series U is 
%       assumed to follow a GARCH(P,Q) process.
% 
%    P: Non-negative, scalar integer representing a model order of the GARCH 
%       process: P is the number of lags of the conditional variance included 
%       in the GARCH process. Note that P can be zero; when P = 0, a GARCH(0,Q)
%       process is actually an ARCH(Q) process.
% 
%    Q: Positive, scalar integer representing a model order of the GARCH 
%       process: Q is the number of lags of the squared innovations included 
%       in the GARCH process. 
% 
%  Output:
%    LogLikelihood: Scalar value of the GARCH(P,Q) log-likelihood objective
%       function given the input arguments. This function is meant to be 
%       optimized via the FMINCON function of the MATLAB Optimization Toolbox. 
%       FMINCON is a minimization routine. To maximize the log-likelihood 
%       function, the likelihood output parameter is actually the negative 
%       of what is formally presented in most time series or econometrics 
%       references.
% 
%  Notes:
%    The time-conditional variance, H(t), of a GARCH(P,Q) process is modeled 
%    as follows:
% 
%      H(t) = Kappa + Alpha(1)*H(t-1) + Alpha(2)*H(t-2) +...+ Alpha(P)*H(t-P)
%                   + Beta(1)*U^2(t-1)+ Beta(2)*U^2(t-2)+...+ Beta(Q)*U^2(t-Q)
% 
%    Note that U is vector of innovations representing a mean-zero, discrete 
%    time stochastic process. Although H is generated via the equation above, 
%    U and H are related as follows:
%     
%      U(t) = sqrt(H(t))*v(t), where {v(t)} is an i.i.d. sequence ~ N(0,1).
% 
%    Also, since this function is really just a helper function, no argument 
%    checking is performed; thus, this function is NOT meant to be called 
%    directly from the command line.
% 
%  

function ugarchpred
%MATLAB Tour Partial Function Help:  fin_con
%
% UGARCHPRED Forecast conditional variance of univariate GARCH(P,Q) processes.
% 
%  [VarianceForecast , H] = ugarchpred(U , Kappa , Alpha , Beta  , NumPeriods)
% 
%  Inputs:
%    U: Single column vector of random disturbances (i.e., the residuals, 
%       or innovations, of an econometric model) representing a mean-zero, 
%       discrete-time stochastic process. The innovations time series U is 
%       assumed to follow a GARCH(P,Q) process. 
% 
%    Kappa: Scalar constant term of the GARCH process. 
% 
%    Alpha: P by 1 column vector of coefficients, where P is the number of
%       lags of the conditional variance included in the GARCH process. Alpha 
%       can be an empty matrix, in which case P is assumed zero; when P = 0,
%       a GARCH(0,Q) process is actually an ARCH(Q) process.
% 
%    Beta: Q by 1 column vector of coefficients, where Q is the number of
%       lags of the squared innovations included in the GARCH process.
% 
%    NumPeriods: Positive, scalar integer representing the forecast horizon of
%       interest, expressed in periods compatible with the sampling frequency 
%       of the input innovations column vector U. 
% 
%  Outputs:
%    VarianceForecast: NUMPERIODS by 1 column vector of the minimum mean 
%       square error forecast of the conditional variance of the innovations 
%       time series vector U. The first element contains the 1-period-ahead 
%       forecast, the second element contains the 2-period-ahead forecast, and
%       so on. Thus, if a forecast horizon greater than one is specified (i.e.,
%       NUMPERIODS > 1), the forecasts of all intermediate horizons are 
%       returned as well; in this case, the last element of will contain the 
%       variance forecast of the specified horizon, NUMPERIODS from the most 
%       recent observation in U.
% 
%    H: Single column vector of the same length as the input innovations 
%       vector U. To model the GARCH(P,Q) process, the conditional variance 
%       time series, H(t), must be constructed (see notes below). This 
%       represents the time series inferred from the innovations U, and is a 
%       re-construction of the 'past' conditional variances, whereas the above
%       output 'VarianceForecast' represents the projection of conditional 
%       variances into the 'future'. This sequence is based on setting 
%       pre-sample values of H(t) to the unconditional variance of the U(t)
%       process.
% 
%  Notes:
%    GARCH(P,Q) coefficients {Kappa, Alpha, Beta} are subject to constraints:
%      (1) Kappa > 0
%      (2) Alpha(i) >= 0 for i = 1,2,...P
%      (3) Beta(i)  >= 0 for i = 1,2,...Q
%      (4) sum(Alpha(i) + Beta(j)) < 1 for i = 1,2,...P and j = 1,2,...Q
% 
%    The time-conditional variance, H(t), of a GARCH(P,Q) process is modeled 
%    as follows:
% 
%      H(t) = Kappa + Alpha(1)*H(t-1) + Alpha(2)*H(t-2) +...+ Alpha(P)*H(t-P)
%                   + Beta(1)*U^2(t-1)+ Beta(2)*U^2(t-2)+...+ Beta(Q)*U^2(t-Q)
% 
%    Note that U is a vector of innovations, or regression residuals of an
%    econometric model, representing a mean-zero, discrete-time stochastic 
%    process. That is, it is assumed that a regression model has already been
%    run, and that U(t) = y(t) - F(X(t),B) is the time series of innovations 
%    derived from the model. 
% 
%    Although H is generated via the equation above, U and H are related:
%     
%      U(t) = sqrt(H(t))*v(t), where {v(t)} is an i.i.d. sequence.
% 
%  

function ugarchsim
%MATLAB Tour Partial Function Help:  fin_con
%
% UGARCHSIM Simulate a univariate GARCH(P,Q) process with Gaussian innovations.
% 
%  [U , H] = ugarchsim(Kappa , Alpha , Beta , NumSamples)
% 
%  Inputs:
%    Kappa: Scalar constant term of the GARCH process. 
% 
%    Alpha: P by 1 column vector of coefficients, where P is a model order that
%       determines the number of lags of the conditional variance included in 
%       the GARCH process. Alpha can be an empty matrix, in which case P is 
%       assumed zero; when P = 0, a GARCH(0,Q) process is actually an ARCH(Q) 
%       process.
% 
%    Beta: Q by 1 column vector of coefficients, where Q is a model order that
%       determines the number of lags of the squared innovations included in 
%       the GARCH process.
% 
%    NumSamples: Positive, scalar integer indicating the number of samples of
%       the innovations U and conditional variance H (see below) to simulate.
% 
%  Outputs:
%    U: NUMSAMPLES by 1 column vector of innovations, representing a mean-zero,
%       discrete-time stochastic process. The innovations time series U is 
%       designed to follow the GARCH(P,Q) process specified by the inputs Kappa,
%       Alpha, and Beta. 
% 
%    H: NUMSAMPLES by 1 column vector of the conditional variance corresponding 
%       to the innovations vector U. Note that U and H are the same length, and 
%       form a 'matching' pair of vectors. To model the GARCH(P,Q) process, the 
%       conditional variance time series, H(t), must be constructed (see notes 
%       below). Thus, H(t) represents the time series inferred from the 
%       innovations time series vector U. 
% 
%  Notes:
%    GARCH(P,Q) coefficients {Kappa, Alpha, Beta} are subject to constraints:
%      (1) Kappa > 0
%      (2) Alpha(i) >= 0 for i = 1,2,...P
%      (3) Beta(i)  >= 0 for i = 1,2,...Q
%      (4) sum(Alpha(i) + Beta(j)) < 1 for i = 1,2,...P and j = 1,2,...Q
% 
%    The time-conditional variance, H(t), of a GARCH(P,Q) process is modeled 
%    as follows:
% 
%      H(t) = Kappa + Alpha(1)*H(t-1) + Alpha(2)*H(t-2) +...+ Alpha(P)*H(t-P)
%                   + Beta(1)*U^2(t-1)+ Beta(2)*U^2(t-2)+...+ Beta(Q)*U^2(t-Q)
% 
%    Note that U is vector of innovations representing a mean-zero, discrete-time
%    stochastic process. Although H is generated via the equation above, U and H
%    are related as follows:
%     
%      U(t) = sqrt(H(t))*v(t), where {v(t)} is an i.i.d. sequence ~ N(0,1).
% 
%    The output vectors U and H are designed to be steady-state sequences, in that 
%    transients have arbitrarily small effect. The (arbitrary) metric used strips
%    the first N samples of U and H such that the sum of the GARCH coefficients, 
%    excluding Kappa, raised to the Nth power will not exceed 0.01:
% 
%      0.01 = (sum(Alpha) + sum(Beta))^N
% 
%    thus,
% 
%      N = log(0.01)/log((sum(Alpha) + sum(Beta)))
% 
%  

function cov2corr
%MATLAB Tour Partial Function Help:  fin_con
%
% COV2CORR Convert covariance to standard deviation and correlation coefficient
%  Computes the volatilities of N random processes and the degree of
%  correlation between the processes.  
% 
%  [ExpSigma, ExpCorrC] = cov2corr(ExpCovariance)
% 
%  Input:
%    ExpCovariance: N by N covariance matrix, e.g. from COV or EWSTATS
% 
%  Outputs:
%    ExpSigma     : 1 by N vector with the standard deviations of each process
% 
%    ExpCorrC     : N by N matrix of correlation coefficients.  The
%    entries of ExpCorrC range from 1 (completely correlated) to -1
%    (completely anti-correlated).  A value of 0 in the (i,j) entry
%    indicates that the i'th and j'th processes are uncorrelated.
%  
%  ExpSigma(i) = sqrt( ExpCovariance(i,i) );
%  ExpCorrC(i,j) = ExpCovariance(i,j)/( ExpSigma(i)*ExpSigma(j) );
%  
%  

function corr2cov
%MATLAB Tour Partial Function Help:  fin_con
%
% CORR2COV Convert standard deviation and correlation to covariance
%  Transforms the volatilities of N random processes and the degrees
%  of correlation between the processes into an N by N covariance matrix.
% 
%  ExpCovariance = corr2cov(ExpSigma, ExpCorrC)
% 
%  Inputs
%    ExpSigma : Vector of length N with the standard deviations of each process
% 
%    ExpCorrC : N by N correlation coefficient matrix.  If ExpCorrC is not 
%    specified, the processes are assumed to be uncorrelated and the 
%    identity matrix is used.
% 
%  Output
%    ExpCovariance  : N by N covariance matrix.  The (i,j) entry is
%    the expectation of the i'th fluctuation from the mean times the
%    j'th fluctuation from the mean.
%  
%  ExpCov(i,j) = ExpCorrC(i,j)*( ExpSigma(i)*ExpSigma(j) )
%  
%  

function ewstats
%MATLAB Tour Partial Function Help:  fin_con
%
%  EWSTATS Expected return and covariance from return time series.  Optional 
%  exponential weighting emphasizes more recent data.
%  
%   [ExpReturn, ExpCovariance, NumEffObs] = ewstats(RetSeries, ...
%                                           DecayFactor, WindowLength)
%   
%  Inputs:
%     RetSeries : NUMOBS by NASSETS matrix of equally spaced incremental 
%     return observations.  The first row is the oldest observation, and the
%     last row is the most recent.
% 
%     DecayFactor : Controls how much less each observation is weighted 
%     than its successor.  The k'th observation back in time has weight 
%     DecayFactor^k.
%     DecayFactor must lie in the range: 0 < DecayFactor <= 1. 
%     The default is DecayFactor = 1, which is the equally weighted linear
%     moving average Model (BIS).  
% 
%     WindowLength: The number of recent observations used in
%     the computation.  The default is all NUMOBS observations.
% 
%  Outputs:
%     ExpReturn : 1 by NASSETS estimated expected returns.
%  
%     ExpCovariance : NASSETS by NASSETS estimated covariance matrix.  
% 
%     NumEffObs: The number of effective observations is given by the formula:
%     NumEffObs = (1-DecayFactor^WindowLength)/(1-DecayFactor).  Smaller
%     DecayFactors or WindowLengths emphasize recent data more strongly, but
%     use less of the available data set.
% 
%  The standard deviations of the asset return processes are given by:
%  STDVec = sqrt(diag(ECov)).  The correlation matrix is :
%  CorrMat = VarMat./( STDVec*STDVec' )
% 
%  

function portsim
%MATLAB Tour Partial Function Help:  fin_con
%
% PORTSIM Random simulation of correlated asset returns.
%  Simulates returns of NASSETS assets over NUMOBS consecutive observation
%  intervals.  Returns are simulated as the increments of constant drift 
%  and volatility Brownian processes.
% 
%  RetSeries = portsim(ExpReturn, ExpCovariance, NumObs, RetIntervals, NumSim)
% 
%  Inputs:
%     ExpReturn : 1 by NASSETS vector of expected (mean) returns of each asset. 
% 
%     ExpCovariance : NASSETS by NASSETS matrix of asset-asset 
%     covariances.  The standard deviations of the returns are:
%     ExpSigma = sqrt(diag(ExpCovariance)).
% 
%     NumObs : Number of consecutive observations in the return time series.
%     If NumObs is entered as the empty matrix [], the length of RetIntervals
%     is used.
% 
%     RetIntervals : Scalar or NUMOBS by 1 vector of interval times between
%     observations.  If RetIntervals is not specified, all intervals are 
%     assumed to have length 1.
% 
%     NumSim : number of separate simulations of the NUMOBS observations to
%     perform.  The default is 1.
% 
%  Output
%     RetSeries : NUMOBS by NASSETS by NUMSIM array of incremental return
%     observations.  The return over an interval of length DT is given by
%     ExpReturn*DT + ExpSigma*sqrt(DT)*randn where randn is a standard normal
%     random draw.
% 
%  The returns realized from portfolios listed in PortWts are given by:
%  PortReturn = PortWts * RetSeries(:,:,1)', where PortWts is a matrix in
%  which each row contains the asset allocations of a portfolio.  Each row of
%  PortReturn corresponds to one of the portfolios identified in PortWts, and
%  each column corresponds to one of the observations in RetSeries.  See
%  PORTOPT and PORTSTATS for portfolio specification and optimization. 
%  
%  

function ret2tick
%MATLAB Tour Partial Function Help:  fin_con
%
% RET2TICK Price tick series from incremental returns and initial price.
%  Generates price values from the starting prices of NASSET investments
%  and NUMOBS incremental return observations.
%  
%  [TickSeries, TickTimes] = ret2tick(RetSeries, StartPrice, ... 
%                                     RetIntervals, StartTime)
%   
%  Inputs:
%     RetSeries : NUMOBS by NASSETS matrix of incremental return
%     observations.  The i'th return is quoted for the period 
%     TickTimes(i) to TickTimes(i+1) and is not scaled to a yearly return.
% 
%     StartPrice : optional 1 by NASSETS vector of initial asset prices.  The
%     prices start at 1 if StartPrice is not specified.
% 
%     RetIntervals : optional scalar or NUMOBS by 1 vector of interval times
%     between observations.  If RetIntervals is not specified, all 
%     intervals are assumed to have length 1.
% 
%     StartTime : optional starting time for the first observation. 
% 
%  Outputs:
%     TickSeries : NUMOBS+1 by NASSETS matrix of prices of equity assets.
%     The first row is the starting price of the assets, and the
%     last row is the last (most recent) observation.
% 
%     TickTimes : NUMOBS+1 by 1 vector of tick observation times.  The
%     initial time is zero unless specified in StartTime.
% 
%    

function tick2ret
%MATLAB Tour Partial Function Help:  fin_con
%
%  TICK2RET Incremental return series from a tick price series.
%  Computes the asset returns realized between NUMOBS observations of prices
%  of NASSETS assets.
%  
%  [RetSeries, RetIntervals] = tick2ret(TickSeries, TickTimes)
%   
%  Inputs:
%     TickSeries : NUMOBS by NASSETS matrix of prices of equity assets.
%     The first row is the oldest observation, and the last row is the most
%     recent. 
% 
%     TickTimes : optional NUMOBS by 1 increasing vector of observation
%     times.  Times are numeric and taken either as serial date numbers
%     (day units) or as decimal numbers in arbitrary units (e.g. yearly).
% 
%  Outputs:
%     RetSeries : NUMOBS-1 by NASSETS matrix of incremental return
%     observations.  The i'th return is quoted for the period 
%     TickTimes(i) to TickTimes(i+1) and is not scaled to a yearly 
%     return:  RetSeries(i) = TickSeries(i+1)/TickSeries(i) - 1;
% 
%     RetIntervals : NUMOBS-1 by 1 vector of interval times between
%     observations.  If TickTimes is not specified, all intervals are 
%     assumed to have length 1.
% 
%    

function frontcon
%MATLAB Tour Partial Function Help:  fin_con
%
%  FRONTCON  Mean-variance efficient frontier with portfolio constraints
%  Returns the mean-variance efficient frontier with user specified asset
%  constraints, covariance and returns. Given a collection of NASSETS risky 
%  assets, computes a portfolio of asset investment weights which minimize
%  the risk for given values of the expected return.  The portfolio risk is
%  minimized subject to constraints on the asset weights or on groups of
%  asset weights.
% 
%  [PortRisk, PortReturn, PortWts] = frontcon(ExpReturn, ExpCovariance, ...
%     NumPorts, PortReturn, AssetBounds, Groups, GroupBounds)
% 
%  Inputs: 
%     ExpReturn is a 1xNASSETS vector specifying the expected (mean) 
%     return of each asset.
%     
%     ExpCovariance is an NASSETSxNASSETS matrix specifying the covariance of
%     the asset returns.
%     
%     NumPorts is the number of efficient portfolios, NPORTS.  The default 
%     value is 10 if NumPorts is entered as the empty matrix [] or not
%     specified.  NumPorts should be entered as [] if PortReturn is to be
%     entered.
% 
%     PortReturn is a vector of length NPORTS containing the target return
%     values on the frontier.
%     You can specify the portfolio return values in two ways.  If PortReturn
%     is not entered or is empty, NumPorts equally spaced returns between the
%     minimum and maximum possible values will be used.  
% 
%     AssetBounds is a 2xNASSETS matrix containing the lower and upper
%     bounds on the weight to be allocated in each asset in the portfolio.
%     The default lower bound is all zeros (no short-selling), the default 
%     upper bound is all ones (any asset may comprise the entire portfolio). 
%     
%     Groups is an NGROUPSxNASSETS matrix specifying NGROUPS asset  
%     groups or classes.  Each row specifies a group:  Groups(i,j) = 1 if 
%     the j'th asset belongs to the i'th group.  Groups(i,j) = 0 if the j'th
%     asset is not in the i'th group.
%     
%     GroupBounds is a NGROUPSx2 matrix specifying, for each group, the 
%     lower and upper bounds of the total weights of all assets in that 
%     group. The default lower bound is all zeros, the default upper bound 
%     is all ones.   
% 
% 
%  Outputs: 
%     PortRisk is an NPORTSx1 vector of the standard deviation of return for
%     each portfolio. 
%     
%     PortReturn is an NPORTSx1 vector of the expected return of each portfolio.
%     
%     PortWts is an NPORTSxNASSETS matrix of weights allocated to each
%     asset. Each row represents a different portfolio. The total of all 
%     weights in a portfolio is 1.
%             
% 
%  Notes: 
%     A plot of the efficient frontier is returned if the function is
%     invoked without output arguments.
% 
%     The asset returns are assumed to be jointly normal, with expected mean
%     returns of ExpReturn and return covariance ExpCovariance.  The variance
%     of a portfolio with 1 by NASSET weights PortWts is given by
%     PortVar = PortWts*ExpCovariance*PortWts'.  The portfolio expected
%     return is PortReturn = dot(ExpReturn, PortWts).
% 
%     

function portalloc
%MATLAB Tour Partial Function Help:  fin_con
%
% PORTALLOC Capital allocation to efficient portfolio.
%   [RiskyRisk, RiskyReturn, RiskyWts, RiskyFraction, OverallRisk, OverallReturn] = ...
%   portalloc(PortRisk, PortReturn, PortWts, RisklessRate, BorrowRate, RiskAversion)
%   returns the optimal risky portfolio given user-specified standard 
%   deviations, expected returns and weights of the efficient portfolios. 
%   Given the risk free rate, the borrowing rate and the investor's  
%   degree of risk aversion, calculates the optimal overall portfolio, and the 
%   optimal allocation of funds between the risky portfolio and the risk-free 
%   asset. 
% 
%   Inputs:
%     PortRisk is an NPORTSx1 vector of the variance of each portfolio. 
%             
%     PortReturn is an NPORTSx1 vector of the expected return of each portfolio.
% 
%     PortWts is an NPORTSxNASSETS matrix of weights allocated to each
%     asset. Each row represents a different portfolio. The total of  
%     all weights in a portfolio is 1.
% 
%     RisklessRate is the risk free rate, as a decimal number. 
% 
%     BorrowRate is the borrowing rate, as a decimal number. If borrowing is  
%     not desired, or not an option, this value must be set to NaN,  
%     which is the default value.
% 
%     RiskAversion is the coefficient of investor's degree of risk aversion.  
%     The higher this number, the more averse an investor is to risk. Typical 
%     risk aversion coefficient range between 2.0 and 4.0. 
%     The default is 3.
% 
%   Outputs:
%     RiskyRisk is the variance of the optimal risky portfolio.
% 
%     RiskyReturn is the expected return of the optimal risky portfolio.
% 
%     RiskyWts is an 1xNASSETS vector of weights allocated to the optimal
%     risky portfolio. The total of all weights in the portfolio is 1.
%  
%     RiskyFraction is the fraction of the complete portfolio 
%     allocated in the risky portfolio.
% 
%     OverallRisk is the variance of the optimal overall portfolio.
% 
%     OverallReturn is the expected rate of return of the optimal overall 
%     portfolio.
% 
% 
%   Notes :
%     A graph displaying critical points is shown if the function 
%     is invoked without output arguments.
% 
% 
%   

function portopt
%MATLAB Tour Partial Function Help:  fin_con
%
% PORTOPT  Portfolios on constrained efficient frontier.
%   Returns portfolios on the mean-variance efficient frontier given asset
%   properties and a user specified set of portfolio constraints (ConSet).
%   Among a collection of NASSETS risky assets, computes a portfolio of asset
%   investment weights which minimize the risk for given values of the  
%   expected return.  The portfolio weights satisfy constraints specified in
%   linear inequality equations.  See PORTCONS for the generation of
%   portfolio constraints.
% 
%   [PortRisk, PortReturn, PortWts] = portopt(ExpReturn, ExpCovariance, ...
%                                         NumPorts, PortReturn, ConSet) 
% 
%   Inputs: 
%      ExpReturn is a 1xNASSETS vector specifying the expected (mean) 
%      return of each asset.
% 
%      ExpCovariance is an NASSETSxNASSETS matrix specifying the 
%      covariance of the asset returns.  ExpCovariance must be symmetric with
%      no negative eigenvalues (positive semi-definite).
% 
%      Either NumPorts or PortReturn specifies the set of efficient
%      portfolios computed.
% 
%      NumPorts is the number of portfolios generated along the efficient
%      frontier when specific portfolio return values are not requested.
%      The default is 10 portfolios equally spaced between the minimum risk
%      point and the maximum possible return.  Enter NumPorts as an empty
%      matrix [], when specifying PortReturn.
% 
%      PortReturn is a vector of length NPORTS containing the target return
%      values along the frontier.  If PortReturn is not entered or is empty,
%      NumPorts equally spaced returns between the minimum and maximum
%      possible values will be used.   
% 
%      ConSet is a matrix of constraints for a portfolio of asset
%      investments.  An eligible 1 by NASSETS vector of asset allocation
%      weights, PortWts, satisfies the inequalities A*PortWts' <= b, 
%      where A = ConSet(:,1:end-1) and b = ConSet(:,end).  ConSet should
%      include at least an equation bounding the total value of the
%      portfolio below.
%  
%      See PORTCONS for a list of portfolio constraint types and their
%      corresponding financial parameters.
% 
%      If the variable ConSet is not specified, a default constraint set 
%      will be used.  The default constraints scale the total value of the
%      portfolio to 1, and place the minimum weight of every asset at 0 to
%      prevent short-selling.
% 
%   Outputs: 
%      PortRisk is an NPORTSx1 vector of the standard deviation of return 
%      for each portfolio. 
%             
%      PortReturn is an NPORTSx1 vector of the expected return of each 
%      portfolio.
% 
%      PortWts is an NPORTSxNASSETS matrix of weights allocated to each
%      asset. Each row represents a different portfolio. 
%             
% 
%   Notes: 
%      A plot of the efficient frontier is returned if the function is
%      invoked without output arguments.
%              
% 
%   

function portcons
%MATLAB Tour Partial Function Help:  fin_con
%
%  PORTCONS Generates a matrix of constraints for a portfolio
%    of asset investments by using linear inequalities. The 
%    inequalities are of the type A*Wts' <= b, where Wts is the 
%    matrix of weights. The matrix ConSet is defined as 
%    ConSet = [A b].
% 
%    ConSet = portcons('ConstType', Data1, ..., DataN) creates a matrix 
%    ConSet, based on the constraint type ConstType, and the constraint 
%    parameters Data1, ..., DataN. See below for a list of constraint 
%    types and their corresponding constraint parameters.
%    
%    ConSet = portcons('ConstType1', Data11, ..., Data1N, 'ConstType2', Data21, ..., Data2N, ...) 
%    creates a matrix ConSet, based on the on the constraint types ConstTypeN, 
%    and the corresponding constraint parameters DataN1, ..., DataNN. See 
%    below for a list of constraint types and their corresponding constraint 
%    parameters.
% 
%    Constraint types and corresponding constraint data:
% 
%      Constraint type: 'Default'
%      All allocations are >= 0; no short selling is allowed. The combined
%      value of the portfolio allocations is normalized to 1.
% 
%      Constraint data: NumAssets (required)
%      NumAssets is a scalar representing the number of assets in the 
%      portfolio.
% 
% 
%      Constraint type: 'PortValue'
%      Require the total value of the portfolio to be fixed to PVal.
% 
%      Constraint data: PVal (required), NumAssets(required)
%      PVal is a scalar representing the total value of the portfolio.
%      NumAssets is a scalar representing the number of assets in the portfolio.
%      See the function PCPVAL for more information.
%      
% 
%      Constraint type: 'AssetLims'
%      Specify the minimum and maximum allocation per asset.
% 
%      Constraint data: AssetMin (required), AssetMax (required), NumAssets (optional)
%      AssetMin is a scalar or vector of length NASSETS, specifying the  
%      minimum allocation per asset.
%      AssetMax is a scalar or vector of length NASSETS, specifying the  
%      maximum allocation per asset.
%      NumAssets is a scalar representing the number of assets in the portfolio.
%      See the function PCALIMS for more information.     
%  
%      
%      Constraint type: 'GroupLims'
%      Specify minimum and maximum allocations to groups of assets.
% 
%      Constraint data: Groups (required), GroupMin (required), GroupMax (required)
%      Groups  is an NGROUPS by NASSETS matrix, specifying which assets 
%      belong to each group.
%      GroupMin is a scalar or a vector of length NGROUPS, specifying  
%      the minimum combined allocations in each group.
%      GroupMax is a scalar or a vector of length NGROUPS, specifying  
%      the maximum combined allocations in each group.
%      See the function PCGLIMS for more information.     
% 
% 
%      Constraint type: 'GroupComparison' 
%      Specify the asset group-to-group comparison constraints. 
% 
%      Constraint data: GroupA (required), AtoBmin (required), AtoBmax (required), GroupB (required)
%      GroupA and GroupB are NGROUPS by NASSETS matrices, specifying the 
%      groups to compare.
%      AtoBmin is a scalar or a vector of length NGROUPS, specifying the  
%      minimum ratios of allocations in group A to allocations in group B.
%      AtoBmax is a scalar or a vector of length NGROUPS, specifying the  
%      maximum ratios of allocations in group A to allocations in group B.
%      See the function PCGCOMP for more information.
% 
% 
%      Constraint type: 'Custom'
%      Custom linear inequality constraints A*Wts' <= b.  
% 
%      Constraint data: A (required), b (required)
%      A is an NCONSTRAINTS by NASSETS matrix, specifying the weights for 
%      each asset in each inequality equation.
%      b is a vector of length NCONSTRAINTS, specifying the right hand sides  
%      of the inequalities.
% 
% 
%    

function pcalims
%MATLAB Tour Partial Function Help:  fin_con
%
%  PCALIMS Linear inequalities for individual asset min and max allocation
%  Specifies the lower and upper bounds of portfolio allocations in each of
%  NASSETS available asset investments.
% 
%  [A,b] = pcalims(AssetMin, AssetMax, NumAssets)  
%  
%  Inputs:
%    AssetMin, AssetMax : scalar or NASSETS long vector of minimum and
%    maximum allocations in each asset.  The entry NaN indicates no
%    constraint for that asset in that direction.  Scalar bounds are applied
%    to all the assets. 
% 
%    NumAssets : (optional) number of assets NASSETS.  If not specified,
%    NumAssets is the length of AssetMin or AssetMax.
% 
%  Outputs:
%    Matrix A and vector b such that A*Pwts' <= b enforces the constraints,
%    where Pwts is a 1 by NASSETS vector of asset allocations.
% 
%    Alternate Usage:  If called with fewer than 2 output arguments, 
%    returns A and b concatenated together: Cons = [A, b];
%    Cons = pcalims(AssetMin, AssetMax, NumAssets)
%  
%  

function pcglims
%MATLAB Tour Partial Function Help:  fin_con
%
%  PCGLIMS Linear inequalities for asset group min and max allocation
%  Specifies minimum and maximum allocations to groups of assets.  Bounds can
%  be specified for an arbitrary number of groups, NGROUPS, made up as
%  subsets of the NASSETS investments. 
%  
%  [A,b] = pcglims(Groups, GroupMin, GroupMax) 
% 
%  Inputs:
%    Groups : NGROUPS by NASSETS specifications of which assets belong to
%    each group.  Every group is a row: Group(i,j) = 1 if group i contains
%    asset j, otherwise Group(i,j) = 0.
% 
%    GroupMin, GroupMax : scalar or NGROUPS long vector of minimum and
%    maximum combined allocations in each group.  The entry NaN indicates 
%    no constraint for that asset.  Scalar bounds are applied to all the
%    groups. 
% 
%  Outputs:
%    Matrix A and vector b such that A*Pwts' <= b enforces the constraints,
%    where Pwts is a 1 by NASSETS vector of asset allocations.
% 
%    Alternate Usage:  If called with fewer than 2 output arguments, 
%    returns A and b concatenated together: Cons = [A, b];
%    Cons = pcglims(Groups, GroupMin, GroupMax)
%  
%  

function pcgcomp
%MATLAB Tour Partial Function Help:  fin_con
%
%  PCGCOMP Linear inequalities for asset group-to-group comparison constraints
%  Specifies that the ratio of allocations in one group to allocations in
%  another group is at least AtoBmin to one, and at most AtoBmax to one.
%  Comparisons can be made between an arbitrary number, NGROUPS, of group
%  pairs made up as subsets of the NASSETS available investments.
%  
%  [A,b] = pcgcomp(GroupA, AtoBmin, AtoBmax, GroupB) 
%  
%  Inputs:
%    GroupA, GroupB : NGROUPS by NASSETS specifications of groups to
%    compare.  Each row specifies which assets are in one group:
%    Group(i,j) = 1 if group i contains asset j, otherwise Group(i,j) = 0;
% 
%    AtoBmin, AtoBmax : scalar or NGROUPS long vectors of minimum and 
%    maximum ratios of allocations in group A to allocations in group B.
%    The entry NaN indicates no constraint between the two groups in 
%    that direction.  Scalar bounds are applied to all the group pairs.
%    For each of the NGROUPS group pairs:
%    GroupA total >= GroubB total * AtoBmin
%    GroupA total <= GroubB total * AtoBmax
%  
%  Outputs:
%    Matrix A and vector b such that A*Pwts' <= b enforces the constraints,
%    where Pwts is a 1 by NASSETS vector of asset allocations.
% 
%    Alternate Usage:  If called with fewer than 2 output arguments, 
%    returns A and b concatenated together: Cons = [A, b];
%    Cons = pcgcomp(GroupA, AtoBmin, AtoBmax, GroupB)
%  
%  

function pcpval
%MATLAB Tour Partial Function Help:  fin_con
%
%  PCPVAL Linear inequalities for fixing total portfolio value
%  Scales the total value of a portfolio of NumAssets assets to PortValue.
%  All portfolio weights, bounds, return, and risk values except ExpReturn
%  and ExpCovariance (see PORTOPT) are in terms of PortValue.  
%   
%  [A,b] = pcpval(PortValue, NumAssets)
% 
%  Inputs:
%    PortValue : Total value of asset portfolio (scalar).  PortValue is the
%    sum of the allocations in all the assets.  Use PortValue = 1 to specify
%    weights as fractions of the portfolio and return and risk numbers as
%    rates instead of value.
% 
%    NumAssets : Number of available asset investments.
% 
%  Outputs:
%    Matrix A and vector b such that A*Pwts' <= b sets the value,
%    where Pwts is a 1 by NumAssets vector of asset allocations.
% 
%    Alternate Usage:  If called with fewer than 2 output arguments, 
%    returns A and b concatenated together: Cons = [A, b];
%    Cons = pcpval(PortValue, NumAssets)
%  
%  

function portrand
%MATLAB Tour Partial Function Help:  fin_con
%
% PORTRAND Randomized portfolio risks, returns, and weights. 
%        [RISK,ROR,WEIGHTS]=PORTRAND(ASSET,RET,PTS) returns the 
%        risk, rate of return, and weight vectors of random  
%        portfolio configurations.  ASSET is an MxN matrix where 
%        each column represents the time series data of a single  
%        security.  RET is a 1xN vector where each column represents 
%        the rate of return for a corresponding security in ASSET.   
%        PTS is a scalar value that specifies how many random points 
%        should be generated.  RISK is a PTSx1 vector of standard 
%        deviations, ROR is a PTSx1 vector of expected rates of return,  
%        and WEIGHTS is a PTSxN matrix of asset weights.  Each row of 
%        WEIGHTS is a different portfolio configuration.  By default, PTS 
%        equals 1000 and RET will be computed by taking the average 
%        value of each column of ASSET.     
%  
%        PORTRAND(ASSET,RET,PTS) plots the points representing each
%        portfolio configuration.
%        
%        This function is used in the MATLAB Financial Expo and
%        illustrates how multiple weighting combinations of the same portfolio
%        will generate the same expected rate of return.
% 
%        

function portstats
%MATLAB Tour Partial Function Help:  fin_con
%
% PORTSTATS  Portfolio expected return and risk.
%     [PortRisk, PortReturn] = portstats (ExpReturn, ExpCovariance, Wts) returns
%     the expected rate of return and risk for a portfolio of assets.
% 
%     Inputs: 
%            ExpReturn is a 1xNASSETS vector specifying the expected (mean) 
%            return of each asset.
% 
%            ExpCovariance is an NASSETSxNASSETS matrix specifying the  
%            covariance of the asset returns.
% 
%            Wts is an NPORTSxNASSETS matrix of weights allocated to each asset.
%            Each row represents a different weighting combination of the assets
%            in the portfolio. If Wts is not entered, weights of 1/NASSETS are
%            assigned to each security.
%  
%     Outputs:             
%            PortRisk is an NPORTSx1 vector of the standard deviation of return 
%            for each portfolio. 
% 
%            PortReturn is an NPORTSx1 vector of the expected return of each 
%            portfolio.
% 
% 
%     

function portvrisk
%MATLAB Tour Partial Function Help:  fin_con
%
% PORTVRISK Portfolio Value-At-Risk
%   ValueAtRisk = portvrisk(PortReturn, PortRisk, RiskThreshold, PortValue)
%   returns the potential loss in the value of a portfolio over one 
%   period of time, given the loss probability level RiskThreshold.
% 
%   Inputs:
%     PortReturn is an NPORTSx1 vector or scalar of the expected return 
%     of each portfolio over the period.
% 
%     PortRisk is an NPORTSx1 vector or scalar of the standard deviation  
%     of each portfolio over the period. 
%             
%     RiskThreshold is an NPORTSx1 vector or scalar specifying the loss 
%     probability. The default value is 0.05 (5%).
% 
%     PortValue is an NPORTSx1 vector or scalar specifying the total value 
%     of asset portfolio. The default value is 1.
%  
%   Outputs:
%     ValueAtRisk is an NPORTSx1 vector of the estimated maximum loss in the  
%     portfolio, predicted with a confidence probability of 1 - RiskThreshold.
% 
%     With probability 1-RiskThreshold the loss will be ValueAtRisk
%     or less, while with probability RiskThreshold the loss will be
%     ValueAtRisk or more.
% 
%   Notes: 
%     If PortValue is not given, ValueAtRisk is presented on a per-unit
%     basis. A value of zero indicates no losses.
%     
%     If PortReturn and PortRisk are in dollar units, then PortValue should 
%     be 1. If PortReturn and PortRisk are on a percentage basis, then
%     PortValue should be the total value of the portfolio.
% 
% 
%   

function today
%MATLAB Tour Partial Function Help:  fin_con
%
% TODAY       Current date. 
%        T = TODAY returns the current date.
% 
%        

function datefind
%MATLAB Tour Partial Function Help:  fin_con
%
% DATEFIND Indices of date numbers in matrix.
%          IND = DATEFIND(SUB,SUPER,TOL) returns a vector of indices to the  
%          date numbers in SUPER that are present in SUB, plus or minus the 
%          tolerance TOL. SUPER is the superset matrix of non-repeating date
%          numbers whose elements are sought. SUB is a subset matrix of date
%          numbers used to find matching date numbers in SUPER. TOL is a  
%          positive integer, representing the tolerance. The default is TOL = 0.
%          
%          Notes: If no date numbers match, IND = [].
%        
%                 The elements of SUB must be contained in SUPER, without 
%                 repetition. This function is designed to work with 
%                 non-repeating sequences of dates.
% 
% 
%          For example, given the following data:
%  
%             Super = datenum(1997, 7, 1:31);
%             Sub = [datenum(1997, 7, 10); datenum(1997, 7, 20)];
%         
%             ind = datefind(Sub,Super,1) returns 
% 
%             ind =  9
%                   10
%                   11
%                   19
%                   20
%                   21
% 
%          

function day
%MATLAB Tour Partial Function Help:  fin_con
%
% DAY    Day of month. 
%        DOM = DAY(D) returns the day of the month given a serial date number 
%        or date string, D. 
%  
%        For example, dom = day(728647) or dom = day('19-Dec-1994') 
%        returns dom = 19. 
%   
%        

function eomdate
%MATLAB Tour Partial Function Help:  fin_con
%
% EOMDATE Last date of month. 
%         D = EOMDATE(Y,M) returns the last date of the month, in serial
%         form, for the given year, Y, and month, M.  
%  
%         For example, d = eomdate(1997,2) returns d = 729449 which is the serial
%         date corresponding to February 28, 1997.
% 
%         

function hour
%MATLAB Tour Partial Function Help:  fin_con
%
% HOUR   Hour of date or time. 
%        H = HOUR(D) returns the hour of the day given a serial date number or 
%        a date string, D. 
%  
%        For example, h = hour(728647.5590548427) or  
%        h = hour('19-Dec-1994, 13:24:08.17') returns h = 13. 
%         
%        

function lweekdate
%MATLAB Tour Partial Function Help:  fin_con
%
% LWEEKDATE Date of last occurrence of weekday in month.
%         D = LWEEKDATE(WKD,Y,M,G) returns the date, in serial form,
%         of the last occurrence of a given weekday in a given 
%         month.  WKD is the weekday, (1 through 7 equal Sunday 
%         through Saturday), Y is the year, M is the month, and G 
%         specifies a weekday that must fall after WKD in the same
%         week.  
% 
%         For example, to find the last Monday in June 1997:
% 
%           d = lweekdate(2,1997,6) returns 729571 which is the serial 
%               date corresponding to Jun 30, 1997. 
%       
%         

function minute
%MATLAB Tour Partial Function Help:  fin_con
%
% MINUTE Minute of date or time. 
%        M = MINUTE(D) returns the minute given a serial date number or a 
%        date string, D. 
%  
%        For example, m = minute(728647.559054842) or  
%        m = minute('19-Dec-1994, 13:25:08.17') returns m = 25. 
%     
%        

function month
%MATLAB Tour Partial Function Help:  fin_con
%
% MONTH  Month of date. 
%        [N,M] = MONTH(D) returns the month in numeric and string form given
%        a serial date number or a date string, D.
%        
%        For example, [n,m] = month(728647) or [n,m] = month('19-Dec-1994')
%        returns n = 12 and m = Dec.
% 
%        

function months
%MATLAB Tour Partial Function Help:  fin_con
%
% MONTHS Number of whole months between dates.
%         MM = MONTHS(D1,D2,EOM) returns the number of whole months 
%         between two dates, D1 and D2. EOM determines if dates 
%         corresponding to the last day of the month are treated as  
%         an additional whole month (EOM = 1, default) or not (EOM = 0).
%          
%         For example, mm = months('31-march-1997','30-Jun-1997',1) returns mm = 3 and 
%         mm = months('31-march-1997','30-Jun-1997',0) returns mm = 2.
% 
%         

function m2xdate
%MATLAB Tour Partial Function Help:  fin_con
%
% M2XDATE MATLAB Serial Date Number Form to Excel Serial Date Number Form
% 
%      DateNumber = m2xdate(MATLABDateNumber, Convention)
% 
% Summary: This function converts serial date numbers from the MATLAB
%          serial date number format to the Excel serial date number format.
% 
%  Inputs: MATLABDateNumber - Nx1 or 1xN vector of serial date numbers in
%               MATLAB serial date number form
%          Convention - Nx1 or 1xN vector or scalar flag value indicating
%               which Excel serial date number convention should be used when
%               converting from MATLAB serial date numbers; possible values
%               are:
%               a) Convention = 0 - 1900 date system in which a serial date
%                    number of one corresponds to the date 31-Dec-1899
%                    (default)
%               b) Convention = 1 - 1904 date system in which a serial date
%                    number of zero corresponds to the date 1-Jan-1904
% 
% Outputs: Nx1 or 1xN vector of serial date numbers in Excel serial date
%               number form
%  
% Example: StartDate = 729706
%          Convention = 0;
% 
%          EndDate = m2xdate(StartDate, Convention);
% 
%          returns:
% 
%          EndDate = 35746
% 
% 

function nweekdate
%MATLAB Tour Partial Function Help:  fin_con
%
% NWEEKDATE  Date of specific occurrence of weekday in month.
%          D = NWEEKDATE(N,WKD,Y,M,G) returns the serial date for a
%          specific occurrence of a given weekday, in a given year
%          and month. N is the nth occurrence of the desired weekday,
%          (an integer from 1 to 5), WKD is the weekday, (1 through 7 
%          equal Sunday through Saturday), Y is the year, M is the month, 
%          and G is an optional specification of another weekday that must 
%          fall in the same week as WKD. The default value is G = 0.
%   
%          For example, to find the first Thursday in May 1997:
% 
%           d = nweekdate(1,5,1997,5) returns d = 729511 which is
%               the serial date corresponding to May 01, 1997. 
%    
%          

function second
%MATLAB Tour Partial Function Help:  fin_con
%
% SECOND Seconds of date or time. 
%        S = SECOND(D) returns the seconds given a serial date number or a 
%        date string, D. 
%         
%        For example, s = second(728647.558427893) or  
%        s = second('19-Dec-1994, 13:24:08.17') returns s = 8.17. 
%    
%        

function x2mdate
%MATLAB Tour Partial Function Help:  fin_con
%
% X2MDATE Excel Serial Date Number Form to MATLAB Serial Date Number Form
% 
%      DateNumber = x2mdate(ExcelDateNumber, Convention)
% 
% Summary: This function converts serial date numbers from the Excel serial
%          date number format to the MATLAB serial date number format.
% 
%  Inputs: ExcelDateNumber - Nx1 or 1xN vector of serial date numbers in
%               Excel serial date number form
%          Convention - Nx1 or 1xN vector or scalar flag value indicating
%               which date convention was used in Excel to convert the date
%               strings to serial date numbers; possible values are:
%               a) Convention = 0 - 1900 date system in which a serial date
%                    number of one corresponds to the date 31-Dec-1899
%                   (default)
%               b) Convention = 1 - 1904 date system in which a serial date
%                   number of zero corresponds to the date 1-Jan-1904
% 
% Outputs: Nx1 or 1xN vector of serial date numbers in MATLAB serial date
%               number form
% 
% Example: StartDate = 35746
%          Convention = 0;
% 
%          EndDate = x2mdate(StartDate, Convention);
% 
%          returns:
% 
%          EndDate = 729706
% 
% 

function year
%MATLAB Tour Partial Function Help:  fin_con
%
% YEAR   Year of date. 
%        Y = YEAR(D) returns the year of a serial date number or a date string, D. 
%  
%        For example, y = year(728647) or y = year('19-Dec-1994') 
%        returns y = 1994. 
%   
%        

function yeardays
%MATLAB Tour Partial Function Help:  fin_con
%
% YEARDAYS Number of days in year.
%         ND = YEARDAYS(Y) returns the number of days in 
%         a given year, Y.
% 
%         For example, nd = yeardays(2000) returns 366.
% 
%         

function busdate
%MATLAB Tour Partial Function Help:  fin_con
%
% BUSDATE Next or previous business day.
%         BD = BUSDATE(D,DIREC,HOL) returns the next or previous business
%         date, in serial form, based on a reference date, D. DIREC specifies 
%         whether the next (DIREC = 1, default) or previous (DIREC = -1)  
%         business day should be returned. HOL is a vector of non-trading    
%         day dates. If HOL is not specified, the non-trading day data is  
%         determined by the routine, HOLIDAYS.
% 
%         For example, bd = busdate('3-jul-1997',1) returns bd = 729578 which 
%         is the serial date corresponding to July 7, 1997.  
% 
%         

function datemnth
%MATLAB Tour Partial Function Help:  fin_con
%
% DATEMNTH Future or Past Date Given a Number of Months Movement Forward
%      or Backward in Time
% 
%          TargetDate = datemnth(StartDate, NumberMonths, DayFlag,...
%               Basis, EndMonthRule)
% 
% Summary: This function determines the serial date number for a date in a
%          future or past month based on movement either forward or backward
%          in time by a given number of months.
% 
%  Inputs: StartDate - Nx1 or 1xN vector containing values for the start date
%               in either serial date number or date string form
%          NumberMonths - Nx1 or 1xN vector containing values for the number
%               months movement forward or backward in time; values must be
%               in integer form
%          DayFlag - Nx1 or 1xN vector containing values which specify how the
%               actual day number for the target date in future or past month
%               is determined; possible values are:
%               a) DayFlag = 0 (default) - day number should be the day in the
%                    future or past month corresponding to the actual day
%                    number of the start date
%               b) DayFlag = 1 - day number should be the first day of the
%                    future or or past month
%               c) DayFlag = 2 - day number should be the last day of the
%                    future or past month
%          Basis - Nx1 or 1xN vector or scalar value specifying the basis to
%               be used when when determining the past or future date;
%               possible values are:
%               1) Basis = 0 - actual/actual(default)
%               2) Basis = 1 - 30/360
%               3) Basis = 2 - actual/360
%               4) Basis = 3 - actual/365
%          EndMonthRule - Nx1 or 1xN vector or scalar value specifying
%               whether or not the "end of month rule" is in effect:
%               1) EndMonthRule = 1 - rule is in effect (meaning that if you
%                     are beginning on the last day of a month, and the month
%                     has 30 or fewer days, you will land on the last actual
%                     day of the future or past month regardless of whether
%                     that month has 28, 29, 30 or 31 days)
%               2) EndMonthRule = 0 (default) - rule is NOT in effect
% 
% Outputs: TargetDate - Nx1 or 1xN vector containing the serial date number
%               of the target date in the future or past month
% 
% Example: StartDate = '03-Jun-1997';
%          NumberMonths = 6;
%          DayFlag = 0;
%          Basis = 0;
%          EndMonthRule = 1;
% 
%          TargetDate = datemnth(StartDate, NumberMonths, DayFlag,...
%               Basis, EndMonthRule)
% 
%          returns:
% 
%          TargetDate = 729727 (03-Dec-1997)
% 
%    

function datewrkdy
%MATLAB Tour Partial Function Help:  fin_con
%
% DATEWRKDY Date of Future or Past Workday 
% 
%      EndDate = datewrkdy(StartDate, NumberWorkDays, NumberHolidays)  
% 
% Summary: This function determines the date of a future or past date given
%               a number of days movement in terms of work days and holidays.
% 
%  Inputs: StartDate - Nx1 or 1xN vector containing the date string or serial
%               date number for the start date
%          NumberWorkDays - Nx1 or 1xN vector containing values for the number
%               of work or business days movement into the future (if positive)
%               or past (if negative)
%          NumberHolidays - Nx1 or 1xN vector containing values for the number
%               of days movement in terms of holidays into the future
%               (if positive) or past (if negative)
% Outputs: EndDate - Nx1 or 1xN vector containing the serial date number of the
%                   resulting future or past date
% 
%      Example: StartDate = '20-Dec-1994';
%               NumberWorkDays = 16;
%               NumberHolidays = 2;
% 
%               datewrkdy(StartDate, NumberWorkDays, NumberHolidays)
% 
%               returns:  
% 
%               EndDate = 728671 (12-Jan-1995) 
%  
% 

function days360
%MATLAB Tour Partial Function Help:  fin_con
%
% DAYS360 Days Between Dates Based on a 360 Day Year
% 
%      NumberDays = days360(StartDate, EndDate, EndMonthRule)
% 
% Summary: This function returns the number of days between two dates given a
%          basis of 30/360
% 
%  Inputs: StartDate - Nx1 or 1xN vector or scalar value, in either serial date
%               number or date string form, representing the start date
%          EndDate - Nx1 or 1xN vector or scalar value, in either serial date
%               number or date string form, representing the end date
% 
% Outputs: NumberDays - Nx1 or 1xN vector or scalar value for the number of
%               days between two dates
% 
% Example: StartDate = '28-Feb-1994';
%          EndDate = '1-Mar-1994';
% 
%          NumberDays = days360(StartDate, EndDate);
% 
%          returns:
% 
%          NumberDays = 3
% 
% Note:  While DAYS360 continues to treat the end of month rule as a valid
%        input argument, it no longer uses the argument to calculate the
%        number of days between the start date and end date. Future releases
%        will disallow use of the end of month rule in calling this function.
%        See the Financial Toolbox User's Guide for further information.
%  
%        

function days365
%MATLAB Tour Partial Function Help:  fin_con
%
% DAYS365 Days between dates based on 365 day year. 
%        D = DAYS365(D1,D2) returns the number of days between D1 and D2 based 
%        on a 365 day year. .  Enter dates as serial date numbers or date
%        strings.  If D2 is less than D1, the value returned will be negative.  
%  
%        For example, d = days365('1-Dec-1993', '12-Jan-1994') 
%        or d = days365(728264,728306) returns d = 42. 
%  
%        

function daysdif
%MATLAB Tour Partial Function Help:  fin_con
%
% DAYSDIF Days between dates for any day count basis.
%        D = DAYSDIF(D1,D2,BASIS) returns the number of
%        days between D1 and D2 using the given day count
%        basis. Enter dates as serial date numbers or date strings.  
%        BASIS is the day-count basis: 0 = actual/actual (default), 
%        1 = 30/360, 2 = actual/360, 3 = actual/365.
% 
%        This function is a helper function for the bond pricing and
%        yield functions designed to make the code more readable and to
%        eliminate redundant calls within if statements.

function daysact
%MATLAB Tour Partial Function Help:  fin_con
%
% DAYSACT Actual number of days between serial date numbers. 
%        D = DAYSACT(T) converts the date representations to a DAYS  
%        scalar value, which is the elapsed time, in units of days, from an  
%        origin roughly 2000 years ago, on the day before January first of  
%        year 0.  
% 
%        D = DAYSACT(T1,T2), with two arguments in any of the two  
%        representations, is the same as DAYSACT(T2) - DAYSACT(T1), which is  
%        the number of days from T1 to T2.  This is negative if T2 represents  
%        an earlier time than T1. 
%  
%        Examples: d=daysact('7-sep-1995', '25-dec-1995') returns d = 109.
%                         d=daysact('9/7/1995') returns d = 728909.
%  
%        

function fbusdate
%MATLAB Tour Partial Function Help:  fin_con
%
% FBUSDATE First business date of month.
%         D = FBUSDATE(Y,M,HOL) returns the first business date  
%         of the month, in serial form, for the given year, Y, and  
%         month, M. HOL is a vector of non-trading day dates. If  
%         HOL is not specified the non-trading day data is determined  
%         by the routine, HOLIDAYS.
%  
%         For example, d = fbusdate(1997,11) returns d = 729697 
%         which is the serial date corresponding to November 03, 1997.
% 
%         

function holidays
%MATLAB Tour Partial Function Help:  fin_con
%
% HOLIDAYS Holidays and non-trading days.
%         H = HOLIDAYS(D1,D2) returns a vector of serial date numbers
%         corresponding to the holidays and non-trading days between 
%         the dates D1 and D2, inclusive. H = HOLIDAYS returns known 
%         non-trading day data.
% 
%         This function contains all holiday and special non-trading day
%         data for the New York Stock Exchange between 1950 and 2030.
%  
%         For example, h = holidays('01-jan-1997','23-jun-1997') returns
%         h =  729391, 729438, 729477, and  729536  which are the serial  
%         dates corresponding to January 1, 1997; February 17, 1997;  
%         March 28, 1997; and May 26, 1997. 
% 
%         

function isbusday
%MATLAB Tour Partial Function Help:  fin_con
%
% ISBUSDAY True for dates that are business days.
%         T = ISBUSDAY(D,HOL) returns 1 if D is a business day and 0
%         otherwise.  HOL is a matrix of dates representing holiday dates.
%         If HOL is not specified, a default set of holiday dates is used.
% 
%         For example, t = isbusday('15-Jun-1997') returns t = 0. 
% 
%         

function lbusdate
%MATLAB Tour Partial Function Help:  fin_con
%
% LBUSDATE Last business date of month.
%         D = LBUSDATE(Y,M,HOL) returns the last business date of the 
%         month, in serial form, for the given year, Y, and month, M.   
%         HOL is a vector of non-trading day dates. If HOL is not specified  
%         the non-trading day data is determined by the routine, HOLIDAYS. 
% 
%         For example, d = lbusdate(1997,5) returns d = 729540 which is the
%         serial date corresponding to May 30, 1997.
%  
%         

function wrkdydif
%MATLAB Tour Partial Function Help:  fin_con
%
% WRKDYDIF Number of Working Days between Dates 
%      NumberDays= WRKDYDIF(Date1, Date2, NumberHolidays)  
% 
% Summary: This function determines the number of working days between two
%          dates given a number of holidays.
% 
%  Inputs: Date1 - Nx1 or 1xN vector containing the date string or serial date
%               number for the start date
%          Date2 - Nx1 or 1xN vector containing the date string or serial date
%               number for the end date
%          NumberHolidays - Nx1 or 1xN vector containing values for the number
%               of days movement in terms of holidays into the future (if
%               positive) or past (if negative)
% 
% Outputs: NumberDays - Nx1 or 1xN vector containing the number of days between
%               Date 1 and Date 2
% 
% Example: Date1 = '9/1/1995';
%          Date2 = '9/11/1995';
%          NumberHolidays = 1;
% 
%          NumberDays = wrkdydif(Date1, Date2, NumberHolidays)
% 
%          returns:
% 
%          NumberDays = 6
%  
% 

function yearfrac
%MATLAB Tour Partial Function Help:  fin_con
%
% YEARFRAC Fraction of Year Between Dates
% 
%      [YearFraction] = yearfrac(Date1, Date2, Basis)
% 
% Summary: This function determines the fraction of a year occurring between
%          two dates based on the number days between those dates using a
%          specified day count Basis.  
% 
%  Inputs: Date 1 - Nx1 or 1xN vector containing values for Date 1 in either
%               date string or serial date form
%          Date 2 - Nx1 or 1xN vector containing values for Date 2 in either
%               date string or serial date form
%          Basis - Nx1 or 1xN vector containing value specifying the Basis for
%               each set of dates; possible values include:
%               a) Basis 0 - actual/actual(default)
%               b) Basis 1 - 30/360
%               c) Basis 2 - actual/360
%               d) Basis 3 - actual/365
% 
% Outputs: YearFraction - Nx1 or 1xN vector of real numbers identifying the
%               interval, in years, between Date 1 and Date 2
% 
% 

function accrfrac
%MATLAB Tour Partial Function Help:  fin_con
%
% ACCRFRAC Fraction of Coupon Period Before Settlement
% 
% This function calculates the fractional portion of the coupon period that has
%      has accrued as of settlement for NUMBONDS fixed income securities. 
%      Multiplying this fraction by the nominal periodic coupon cash flow 
%      amount for a bonds, yields the accrued interest payable on that bond. 
%      This function will determine the accured interest fraction for a bond
%      regardless of whether the bond has an first coupon period which is
%      abnormal in length.
% 
%      Fraction = accrfrac(Settle, Maturity, Period, Basis, EndMonthRule,
%          IssueDate, FirstCouponDate, LastCouponDate, StartDate)
% 
%  Inputs: Settle (required) - Settlement date
%          Maturity (required) - Maturity date
%          Period - Coupons payments per year; default is 2
%          Basis - Day-count basis; default is 0 (actual/actual) 
%          EndMonthRule - End-of-month rule; default is 1 (in effect)
%          IssueDate - Bond issue date
%          FirstCouponDate - Irregular or normal first coupon date
%          LastCouponDate - Irregular or normal last coupon date
%          StartDate - Forward starting date of payments (Input ignored in 2.0)
% 
%          Unless specified as being required, all listed input arguments
%          are optional. All required arguments must be NUMBONDSx1 or 
%          1xNUMBONDS conforming vectors or scalar arguments. All optional 
%          arguments must be either NUMBONDSx1 or 1xNUMBONDS conforming 
%          vectors, scalars, or empty matrices. Fill unspecified entries in 
%          input vectors with the value NaN. Dates can be serial date numbers 
%          or date strings.
% 
%          For a detailed description of each input and output argument, at
%          the command line type: 'help ftb' + the argument name (e.g. for
%          help on Settle, type: "help ftbSettle").
% 
% Outputs: Fraction - Accrued interest fraction 
% 
% 

function cfamounts
%MATLAB Tour Partial Function Help:  fin_con
%
% CFAMOUNTS Cash Flow and Time Mapping for a Portfolio of Bonds
% 
% This function returns a matrix of cash flow amounts, cash flow date, time
%      factors, and cash flow flags for a portfolio of NUMBONDS fixed income 
%      securities. The elements contained in the cash flow matrix, time factor
%      matrix, and cash flow flag matrix correspond to the cash flow dates for
%      each security. The first element of each row in the cash flow matrix is 
%      the accrued interest payable on each bond. This is zero in the case of 
%      all zero coupon bonds. This function will determine all cash flow and 
%      time mapping for a bond regardless of whether the coupon structure 
%      contains odd first or last coupon periods. 
% 
%      [CFlowAmounts, CFlowDates, TFactors, CFlowFlags] = cfamounts(CouponRate, 
%           Settle, Maturity, Period, Basis, EndMonthRule, IssueDate,
%           FirstCouponDate, LastCouponDate, StartDate, Face)
% 
%  Inputs: CouponRate (Required) - Decimal coupon rate; zero for zero coupon
%               bonds
%          Settle (Required) - Settlement date
%          Maturity (Required) - Maturity date
%          Period - Coupon frequency; default is "2" for semi-annual
%          Basis - Bond basis; default is "0" for Actual/Actual
%          EndMonthRule - End of month rule; default is "1" meaning "in effect"
%          IssueDate - Date of issue
%          FirstCouponDate - First actual coupon date
%          LastCouponDate - Last actual coupon date
%          StartDate - Forward starting date for security (Input ignored in 2.0)
%          Face - Face value; default is 100
% 
%          Unless specified as being required, all listed input arguments
%          are optional. All required arguments must be NUMBONDSx1 or 
%          1xNUMBONDS conforming vectors or scalar arguments. All optional 
%          arguments must be either NUMBONDSx1 or 1xNUMBONDS conforming 
%          vectors, scalars, or empty matrices. Fill unspecified entries in 
%          input vectors with the value NaN. Dates can be serial date numbers 
%          or date strings.
% 
%          For a detailed description of each input and output argument, at
%          the command line type: 'help ftb' + the argument name (e.g. for
%          help on Settle, type: "help ftbSettle").
% 
% Outputs: CFlowAmounts - Cash flow amounts; first entry in each row vector
%               is the accrued interest due (zero for zero-coupon bonds)
%          CFlowDates - Cash flow dates in serial date number form
%          TFactors - Time factor (i.e. time to cash flow) in fractional semi-
%               annual coupon periods
%          CFlowFlags - Cash flow flags (type "help ftbcflowflags" for a
%               detailed description of these flags)
% 
% 

function cfdates
%MATLAB Tour Partial Function Help:  fin_con
%
% CFDATES Cash Flow Dates for a Fixed Income Security
% 
% This function generates a matrix of cash flow dates for NUMBOND fixed income
%      securities. This function will determine all cash flow dates for a bond
%      regardless of whether the first and last coupon periods are normal,
%      long or short. This function also returns a matrix of flags which 
%      identify the type of cash flow receivable on each date, such as whether
%      the cash flow is normal cash flow or a "stub" cash flow.
% 
%      [CFlowDates, CFlowFlags] = cfdates(Settle, Maturity, Period, Basis, 
%           EndMonthRule, IssueDate, FirstCouponDate, LastCouponDate, StartDate)
% 
%  Inputs: Settle (Required) - Settlement date
%          Maturity (Required) - Maturity date
%          Period - Coupon frequency; default is "2" for semi-annual
%          Basis - Bond basis; default is "0" for Actual/Actual
%          EndMonthRule - End of month rule; default is "1" meaning "in effect"
%          IssueDate - Date of issue
%          FirstCouponDate - First actual coupon date
%          LastCouponDate - Last actual coupon date
%          StartDate - Forward starting date for security
% 
%          Unless specified as being required, all listed input arguments
%          are optional. All required arguments must be NUMBONDSx1 or 
%          1xNUMBONDS conforming vectors or scalar arguments. All optional 
%          arguments must be either NUMBONDSx1 or 1xNUMBONDS conforming 
%          vectors, scalars, or empty matrices. Fill unspecified entries in 
%          input vectors with the value NaN. Dates can be serial date numbers 
%          or date strings.
% 
%          For a detailed description of each input and output argument, at
%          the command line type: 'help ftb' + the argument name (e.g. for
%          help on Settle, type: "help ftbSettle").
% 
% Outputs: CFlowDates - Cash flow dates
%          CFlowFlags - Cash flow flags (type "help ftbcflowflags" for a
%               detailed description of these flags)
% 
% 

function cftimes
%MATLAB Tour Partial Function Help:  fin_con
%
% CFTIMES Time to Cash Flow in Fractional Coupon Periods  
% 
% This function determines the time factors for NUMBONDS fixed income
%      securities. The term "time factors" refers to the time to cash flow in 
%      fractional semi-annual coupon periods.
% 
%      TFactors = cftimes(Settle, Maturity, Period, Basis, EndMonthRule,
%           IssueDate, FirstCouponDate, LastCouponDate, StartDate)
% 
%  Inputs: Settle (required) - Settlement date
%          Maturity (required) - Maturity date
%          Period - Coupons payments per year; default is 2
%          Basis - Day-count basis; default is 0 (actual/actual) 
%          EndMonthRule - End-of-month rule; default is 1 (in effect)
%          IssueDate - Bond issue date
%          FirstCouponDate - Irregular or normal first coupon date
%          LastCouponDate - Irregular or normal last coupon date
%          StartDate - Forward starting date of payments (Input ignored in 2.0)
%          
%          Unless specified as being required, all listed input arguments
%          are optional. All required arguments must be NUMBONDSx1 or 
%          1xNUMBONDS conforming vectors or scalar arguments. All optional 
%          arguments must be either NUMBONDSx1 or 1xNUMBONDS conforming 
%          vectors, scalars, or empty matrices. Fill unspecified entries in 
%          input vectors with the value NaN. Dates can be serial date numbers 
%          or date strings.
% 
%          For a detailed description of each input and output argument, at
%          the command line type: 'help ftb' + the argument name (e.g. for
%          help on Settle, type: "help ftbSettle").
% 
% Outputs: TFactors - Time to cash flow
% 
%          Outputs are NUMBONDS vectors
% 
% 

function cpncount
%MATLAB Tour Partial Function Help:  fin_con
%
% CPNCOUNT Number of Coupon Payments Remaining Until Maturity 
% 
% This function determines the the number of coupon payments remaining from 
%      settlement until maturity for NUMBONDS fixed income securities.
% 
%      NumCouponsRemaining = cpncount(Settle, Maturity, Period, Basis, 
%           EndMonthRule, IssueDate, FirstCouponDate, LastCouponDate, 
%           StartDate)
% 
%  Inputs: Settle (required) - Settlement date
%          Maturity (required) - Maturity date
%          Period - Coupons payments per year; default is 2
%          Basis - Day-count basis; default is 0 (actual/actual) 
%          EndMonthRule - End-of-month rule; default is 1 (in effect)
%          IssueDate - Bond issue date
%          FirstCouponDate - Irregular or normal first coupon date
%          LastCouponDate - Irregular or normal last coupon date
%          StartDate - Forward starting date of payments
%          
%          Unless specified as being required, all listed input arguments
%          are optional. All required arguments must be NUMBONDSx1 or 
%          1xNUMBONDS conforming vectors or scalar arguments. All optional 
%          arguments must be either NUMBONDSx1 or 1xNUMBONDS conforming 
%          vectors, scalars, or empty matrices. Fill unspecified entries in 
%          input vectors with the value NaN. Dates can be serial date numbers 
%          or date strings.
% 
%          For a detailed description of each input and output argument, at
%          the command line type: 'help ftb' + the argument name (e.g. for
%          help on Settle, type: "help ftbSettle").
% 
% Outputs: NumCouponsRemaining - Number of coupon payment remaining until
%               maturity
% 
% 

function cpndaten
%MATLAB Tour Partial Function Help:  fin_con
%
% CPNDATEN Next Actual Coupon Date for a Fixed Income Security 
% 
% This function determines the next actual coupon date for a set of NUMBOND
%      fixed income securities. This function finds the next actual coupon
%      date for a bond with a coupon structure in which the first or last 
%      period is either normal, short, or long. In the case of zero coupon
%      bonds this function returns the maturity date.
% 
%      NextCouponDate = cpndaten(Settle, Maturity, Period, Basis, 
%           EndMonthRule, IssueDate, FirstCouponDate, LastCouponDate,
%           StartDate)
% 
%  Inputs: Settle (required) - Settlement date
%          Maturity (required) - Maturity date
%          Period - Coupons payments per year; default is 2
%          Basis - Day-count basis; default is 0 (actual/actual) 
%          EndMonthRule - End-of-month rule; default is 1 (in effect)
%          IssueDate - Bond issue date
%          FirstCouponDate - Irregular or normal first coupon date
%          LastCouponDate - Irregular or normal last coupon date
%          StartDate - Forward starting date of payments
% 
%          Unless specified as being required, all listed input arguments
%          are optional. All required arguments must be NUMBONDSx1 or 
%          1xNUMBONDS conforming vectors or scalar arguments. All optional 
%          arguments must be either NUMBONDSx1 or 1xNUMBONDS conforming 
%          vectors, scalars, or empty matrices. Fill unspecified entries in 
%          input vectors with the value NaN. Dates can be serial date numbers 
%          or date strings.
% 
%          For a detailed description of each input and output argument, at
%          the command line type: 'help ftb' + the argument name (e.g. for
%          help on Settle, type: "help ftbSettle").
% 
% Outputs: NextCouponDate - Next actual coupon date for a bond
% 
%          Outputs are NUMBONDS by 1 vectors
% 
%          If settlement is a coupon date, this function never returns
%          the settlement date. It returns the actual coupon date strictly 
%          after settlement.
% 
%          This function will always return the lesser of the actual maturity
%          date and the next coupon date.
% 
% 

function cpndatenq
%MATLAB Tour Partial Function Help:  fin_con
%
% CPNDATENQ Next Quasi Coupon Date for a Fixed Income Security 
% 
% This function determines the next quasi coupon date for a set of NUMBOND
%          fixed income securities. The term "next quasi coupon date" refers 
%          to the next coupon date for a bond computed as if the first coupon
%          date is unspecified. This function finds the next quasi coupon date
%          for a bond with a coupon structure in which the first or last 
%          period is either normal, short, or long. In the case of zero coupon
%          bonds this function returns the maturity date.
% 
%      NextQuasiCouponDate = cpndatenq(Settle, Maturity, Period, Basis, 
%           EndMonthRule, IssueDate, FirstCouponDate, LastCouponDate,
%           StartDate)
% 
%  Inputs: Settle (required) - Settlement date
%          Maturity (required) - Maturity date
%          Period - Coupons payments per year; default is 2
%          Basis - Day-count basis; default is 0 (actual/actual) 
%          EndMonthRule - End-of-month rule; default is 1 (in effect)
%          IssueDate - Bond issue date
%          FirstCouponDate - Irregular or normal first coupon date
%          LastCouponDate - Irregular or normal last coupon date
%          StartDate - Forward starting date of payments
% 
%          Unless specified as being required, all listed input arguments
%          are optional. All required arguments must be NUMBONDSx1 or 
%          1xNUMBONDS conforming vectors or scalar arguments. All optional 
%          arguments must be either NUMBONDSx1 or 1xNUMBONDS conforming 
%          vectors, scalars, or empty matrices. Fill unspecified entries in 
%          input vectors with the value NaN. Dates can be serial date numbers 
%          or date strings.
% 
%          For a detailed description of each input and output argument, at
%          the command line type: 'help ftb' + the argument name (e.g. for
%          help on Settle, type: "help ftbSettle").
% 
% Outputs: NextQuasiCouponDate - Next coupon date for a bond computed as if
%               no first coupon date has been explicitly specified
% 
%          Outputs are NUMBONDS by 1 vectors
% 
%          If settlement is a coupon date, this function never returns
%          the settlement date. It returns the coupon date strictly after
%          settlement.
% 
% 

function cpndatep
%MATLAB Tour Partial Function Help:  fin_con
%
% CPNDATEP Previous Coupon Date for a Fixed Income Security
% 
% This function determines the previous coupon date for a set of NUMBOND 
%      fixed income securities. This function finds the previous coupon date 
%      for a bond with a coupon structure in which the first or last period is
%      either normal, short, or long (i.e. regardless of whether the coupon 
%      structure is synched to maturity or not). In the case of zero coupon 
%      bonds this function returns the theoretical previous quasi coupon date
%      (i.e. the previous coupon date that would prevail if the bond were a 
%      coupon bond).
% 
%      PreviousCouponDate = cpndatep(Settle, Maturity, Period, Basis,...
%           EndMonthRule, IssueDate, FirstCouponDate, LastCouponDate,
%           StartDate)
% 
%  Inputs: Settle (required) - Settlement date
%          Maturity (required) - Maturity date
%          Period - Coupons payments per year; default is 2
%          Basis - Day-count basis; default is 0 (actual/actual) 
%          EndMonthRule - End-of-month rule; default is 1 (in effect)
%          IssueDate - Bond issue date
%          FirstCouponDate - Irregular or normal first coupon date
%          LastCouponDate - Irregular or normal last coupon date
%          StartDate - Forward starting date of payments
%          
%          Unless specified as being required, all listed input arguments
%          are optional. All required arguments must be NUMBONDSx1 or 
%          1xNUMBONDS conforming vectors or scalar arguments. All optional 
%          arguments must be either NUMBONDSx1 or 1xNUMBONDS conforming 
%          vectors, scalars, or empty matrices. Fill unspecified entries in 
%          input vectors with the value NaN. Dates can be serial date numbers 
%          or date strings.
% 
%          For a detailed description of each input and output argument, at
%          the command line type: 'help ftb' + the argument name (e.g. for
%          help on Settle, type: "help ftbSettle").
% 
% Outputs: PreviousCouponDate - Previous actual coupon date
%          
%          Outputs are NUMBONDS by 1 vectors
% 
%          If the settlement date is a coupon date, this function always 
%          returns the settlement date.
% 
% 

function cpndatepq
%MATLAB Tour Partial Function Help:  fin_con
%
% CPNDATEPQ Previous Quasi Coupon Date for a Fixed Income Security
% 
% This function determines the previous quasi coupon date for a set of NUMBOND 
%      fixed income securities. This function finds the previous quasi coupon 
%      date for a bond with a coupon structure in which the first or last 
%      period is either normal, short, or long (i.e. regardless of whether the
%      coupon structure is synched to maturity or not). In the case of zero 
%      coupon bonds this function returns the theoretical previous coupon date
%      that would prevail if the bond were a coupon bond).
% 
%      The term "previous quasi coupon date" refers to the previous coupon date
%      for a bond calculated as if no issue date were specified. Although the
%      issue date is not actually a coupon date, when issue date is specified,
%      the previous actual coupon date for a bond is normally calculated 
%      as being either the previous date or the issue date, whichever is 
%      greater. Also, the actual previous coupon date and the previous quasi 
%      coupon date can also differ when the maturity date is not synched with
%      the coupon structure and the settlement date is the maturity date.
%      This function will always return the previous quasi coupon date whether
%      the issue date is greater. This function will only return a maturity
%      date as a previous coupon date if it is synch with coupon structure
%      of the bond.
% 
%      PreviousQuasiCouponDate = cpndatepq(Settle, Maturity, Period, Basis,...
%           EndMonthRule, IssueDate, FirstCouponDate, LastCouponDate,
%           StartDate)
% 
%  Inputs: Settle (required) - Settlement date
%          Maturity (required) - Maturity date
%          Period - Coupons payments per year; default is 2
%          Basis - Day-count basis; default is 0 (actual/actual) 
%          EndMonthRule - End-of-month rule; default is 1 (in effect)
%          IssueDate - Bond issue date
%          FirstCouponDate - Irregular or normal first coupon date
%          LastCouponDate - Irregular or normal last coupon date
%          StartDate - Forward starting date of payments
%          
%          Unless specified as being required, all listed input arguments
%          are optional. All required arguments must be NUMBONDSx1 or 
%          1xNUMBONDS conforming vectors or scalar arguments. All optional 
%          arguments must be either NUMBONDSx1 or 1xNUMBONDS conforming 
%          vectors, scalars, or empty matrices. Fill unspecified entries in 
%          input vectors with the value NaN. Dates can be serial date numbers 
%          or date strings.
% 
%          For a detailed description of each input and output argument, at
%          the command line type: 'help ftb' + the argument name (e.g. for
%          help on Settle, type: "help ftbSettle").
% 
% Outputs: PreviousQuasiCouponDate - Previous quasi coupon date
%          
%          Outputs are NUMBONDS by 1 vectors
% 
%          If the settlement date is a coupon date, this function always 
%          returns the settlement date. This function will only return
%          maturity date as a coupon date if it is in synch with the coupon
%          structure.
% 
% 

function cpndaysn
%MATLAB Tour Partial Function Help:  fin_con
%
% CPNDAYSN Number of Days to Next Coupon Date  
% 
% This function determines the number of days from settlement to the next quasi
%      coupon date for a set of NUMBOND fixed income securities. This
%      function will determine the number of days regardless of whether the
%      bond has an abnormal first or last coupon period. In the case of zero
%      coupon bonds this function returns the number of days from settlement to
%      the theoretical next quasi coupon date (i.e. the next coupon date 
%      that would prevail if the bond were a coupon bond).
% 
%      NumDaysNext = cpndaysn(Settle, Maturity, Period, Basis, 
%           EndMonthRule, IssueDate, FirstCouponDate, LastCouponDate, 
%           StartDate)
% 
%  Inputs: Settle (required) - Settlement date
%          Maturity (required) - Maturity date
%          Period - Coupons payments per year; default is 2
%          Basis - Day-count basis; default is 0 (actual/actual) 
%          EndMonthRule - End-of-month rule; default is 1 (in effect)
%          IssueDate - Bond issue date
%          FirstCouponDate - Irregular or normal first coupon date
%          LastCouponDate - Irregular or normal last coupon date
%          StartDate - Forward starting date of payments
%          
%          Unless specified as being required, all listed input arguments
%          are optional. All required arguments must be NUMBONDSx1 or 
%          1xNUMBONDS conforming vectors or scalar arguments. All optional 
%          arguments must be either NUMBONDSx1 or 1xNUMBONDS conforming 
%          vectors, scalars, or empty matrices. Fill unspecified entries in 
%          input vectors with the value NaN. Dates can be serial date numbers 
%          or date strings.
% 
%          For a detailed description of each input and output argument, at
%          the command line type: 'help ftb' + the argument name (e.g. for
%          help on Settle, type: "help ftbSettle").
% 
% Outputs: NumDaysPrevious- Number of days from previous quasi coupon date
%               to settlement
%          
% 

function cpndaysp
%MATLAB Tour Partial Function Help:  fin_con
%
% CPNDAYSP Number of Days Since Previous Coupon Date  
% 
% This function determines the number of days from the previous quasi coupon 
%      date to settlement for a set of NUMBOND fixed income securities. This
%      function will determine the number of days regardless of whether the
%      bond has an abnormal first or last coupon period. In the case of zero
%      coupon bonds this function returns the number of days from the 
%      theoretical previous quasi coupon date (i.e. the previous coupon date 
%      that would prevail if the bond were a coupon bond) to settlement.
% 
%      NumDaysPrevious = cpndaysp(Settle, Maturity, Period, Basis, 
%           EndMonthRule, IssueDate, FirstCouponDate, LastCouponDate, 
%           StartDate)
% 
%  Inputs: Settle (required) - Settlement date
%          Maturity (required) - Maturity date
%          Period - Coupons payments per year; default is 2
%          Basis - Day-count basis; default is 0 (actual/actual) 
%          EndMonthRule - End-of-month rule; default is 1 (in effect)
%          IssueDate - Bond issue date
%          FirstCouponDate - Irregular or normal first coupon date
%          LastCouponDate - Irregular or normal last coupon date
%          StartDate - Forward starting date of payments
%          
%          Unless specified as being required, all listed input arguments
%          are optional. All required arguments must be NUMBONDSx1 or 
%          1xNUMBONDS conforming vectors or scalar arguments. All optional 
%          arguments must be either NUMBONDSx1 or 1xNUMBONDS conforming 
%          vectors, scalars, or empty matrices. Fill unspecified entries in 
%          input vectors with the value NaN. Dates can be serial date numbers 
%          or date strings.
% 
%          For a detailed description of each input and output argument, at
%          the command line type: 'help ftb' + the argument name (e.g. for
%          help on Settle, type: "help ftbSettle").
% 
% Outputs: NumDaysPrevious- Number of days from previous quasi coupon date
%               to settlement
%          
%          If the settlement date is a coupon date, this function always 
%          returns the settlement date.
% 
% 

function cpnpersz
%MATLAB Tour Partial Function Help:  fin_con
%
% CPNPERSZ Number of Days in Coupon Period  
% 
% This function determines the number of days in the coupon period containing
%      settlement date for NUMBONDS fixed income securities.
% 
%      NumDaysPeriod = cpnpersz(Settle, Maturity, Period, Basis, EndMonthRule,
%           IssueDate, FirstCouponDate, LastCouponDate, StartDate)
% 
%  Inputs: Settle (required) - Settlement date
%          Maturity (required) - Maturity date
%          Period - Coupons payments per year; default is 2
%          Basis - Day-count basis; default is 0 (actual/actual) 
%          EndMonthRule - End-of-month rule; default is 1 (in effect)
%          IssueDate - Bond issue date
%          FirstCouponDate - Irregular or normal first coupon date
%          LastCouponDate - Irregular or normal last coupon date
%          StartDate - Forward starting date of payments
%          
%          Unless specified as being required, all listed input arguments
%          are optional. All required arguments must be NUMBONDSx1 or 
%          1xNUMBONDS conforming vectors or scalar arguments. All optional 
%          arguments must be either NUMBONDSx1 or 1xNUMBONDS conforming 
%          vectors, scalars, or empty matrices. Fill unspecified entries in 
%          input vectors with the value NaN. Dates can be serial date numbers 
%          or date strings.
% 
%          For a detailed description of each input and output argument, at
%          the command line type: 'help ftb' + the argument name (e.g. for
%          help on Settle, type: "help ftbSettle").
% 
% Outputs: NumDaysPeriod - Number of days in coupon period containing settle
% 
% 

function finchart
%MATLAB Tour Partial Function Help:  fin_con
%
% FINCHART  Financial Expo financial charts.

function charhelp
%MATLAB Tour Partial Function Help:  fin_con
%
%  This file contains help text strings for Financial Expo on line help

function timeser
%MATLAB Tour Partial Function Help:  fin_con
%
% TIMESER Convert XData of time series plot to correct date values.
%        T = TIMESER(START,PERIODS,HLDAYS) converts the XData of time
%        series plots to the appropriate date values.  The axis
%        tick labels can then be converted to date string labels
%        of the desired format using the DATEAXIS command.  START
%        is the initial or starting date of the time series.  PERIODS  
%        specifies the frequency of the data.
% 
%               Data frequency         Periods setting
% 
%                  daily                      1 (default)
%                  weekly                     2
%                  monthly                    3
%                  quarterly                  4
%                  semi-annual                5
%                  annual                     6
% 
%        Saturdays and Sundays are removed from the XData vector
%        as are any specified HLDAYS.  HLDAYS represents any
%        non-trading days excepts Saturdays or Sundays that should
%        be eliminated from the dates associated with the time series
%        data.  HLDAYS can be set by editing this function and
%        adding appropriate dates, by defining the dates in a global
%        variable named HLDAYS, or by inputting it as the third 
%        argument.
% 
%        TIMESER converts the XData to a date vector using today's
%        date as the START date.   By default, HLDAYS is defined
%        within the function TIMESER or else globally by the user.
% 
%        TIMESER(START) converts the XData to a date vector using
%        START as the starting date.  By default, the data is treated
%        daily data (PERIODS = 1) and HLDAYS is defined within the 
%        function TIMESER or else globally by the user.
% 
%        TIMESER(START,PERIODS) converts the XData to a date vector
%        using START as the starting date and PERIODS as the frequency
%        of the data.   By default, HLDAYS is defined within the 
%        function TIMESER or else globally by the user.
% 
%        TIMESER(START,PERIODS,HLDAYS) converts the XData to a date vector
%        using START as the starting date, PERIODS as the frequency of the
%        data and HLDAYS as the non-trading days information.
% 
%        TRADDAYS = TIMESER(...) returns the date vector information
%        to the MATLAB workspace without altering the XData of the
%        time series plot.
% 
%        

function cfplot
%MATLAB Tour Partial Function Help:  fin_con
%
%  CFPLOT Visualize the cash flow dates of a series of financial instruments.
%  cfplot(CFlowDates, CFlowAmounts) plots a cash flow diagram where each
%  instrument is a horizontal line decorated with vertical arrows at the 
%  cash flow times.  The size and orientation of each arrow correspond 
%  to the cash flow amount.
%  
%  Inputs:
%    CFlowDates : Matrix of serial date numbers for cash flows.  Each row
%    represents an instrument so that CFlowDates(k,:) is the vector of cash
%    flow dates for the k'th instrument.  Rows are padded with trailing NaN's
%    if the number of cash flows is not the same for all instruments.
% 
%    CFlowAmounts : (optional) Matrix the same size as CFlowDates specifying
%    the amount of each cash flow.  Uniform cash flows of 1 are used if
%    CFlowAmounts is not entered.
%  
%  CFPLOT optionally takes additional string arguments
%    'Dates'   : label x axis with dates
%    'NoLine'  : suppress horizontal lines
%    'NoArrow' : suppress arrowheads
% 
%  Outputs:
%    If CFPLOT is called with an output argument, it returns a matrix of
%    handles to line objects.  Each row of handles corresponds to an
%    instrument. 
% 
%  

function dtaxis
%MATLAB Tour Partial Function Help:  fin_con
%
%  DTAXIS Date axis labels synced to the data
%  Usage: dtaxis(XYZ, DateForm, StartDate, TickDateSpace)
% 
%  Inputs
%    XYZ           : string either 'x', 'y', or 'z' Default: 'x'
%    DateForm      : Date Form flag for datestr     Default: 6  -> 'mm/dd'
%    StartDate     : Axis minimum date              Default: data-min
%    TickDateSpace : minimum number of days allowed between ticks 
%     
%  Example 
%    dates = cfdates(today, today+3*365, 2);
%    plot( dates, rand(size(dates)) )
%    dtaxis('x',2,[],180)

function datedisp
%MATLAB Tour Partial Function Help:  fin_con
%
%  DATEDISP print a matrix with some date entries in a datestr format
%  Usage:  datedisp(nmat, dateform)
%          datedisp(nmat)
%  
%  Inputs:
%    nmat     : matrix with data to display
%    dateform : optional date format (see DATESTR) 
%  
%  Outputs : charmat = datedisp(nmat, dateform)
%    charmat  : character array of the matrix.  If no output is assigned, the
%    function prints the array to the display.
% 
%  

function blsdemos
%MATLAB Tour Partial Function Help:  fin_con
%
%  BLSDEMOS Equity option pricing, hedging, and implied volatility demos
%   
%  

function oneopt
%MATLAB Tour Partial Function Help:  fin_con
%
%  ONEOPT Binomial Tree and Black-Scholes demonstration for equity options
%   Constructs and views Cox-Ross-Rubinstein binomial trees, and views the
%   price and hedge parameters of a single American or European option.
% 
%   oneopt(0) : invoke binomial tree construction
%   oneopt(1) : invoke price and hedge parameter viewing
% 
%  

function payoff
%MATLAB Tour Partial Function Help:  fin_con
%
%  PAYOFF Equity option portfolio hedging demonstration.
%  Compute the Profit/Loss diagram, Hedging diagram, and Profit probability
%  functions for a portfolio of options and underlying stock.
% 
%  Use the plot menu to change the mode of the demonstration.
% 
%  

function smile
%MATLAB Tour Partial Function Help:  fin_con
%
%  SMILE Demonstration of the implied volatility smile
% 
%  

function advgreek
%MATLAB Tour Partial Function Help:  fin_con
%
% ADVGREEK Financial Expo option portfolio sensitivities.

function greekdem
%MATLAB Tour Partial Function Help:  fin_con
%
% GREEKDEM Financial Expo single option sensitivities.

function seoption
%MATLAB Tour Partial Function Help:  fin_con
%
%  SEOPTION Calculates sensitivity measures of portfolio of options.
%        O = SEOPTION(PRANGE,STRIKE,RATE,MATS,SIG,CONTRACT,MEASURE) calculates
%        the sensitivity measure of a portfolio of options.  PRANGE is the
%        price range of the underlying asset, STRIKE is a vector of exercies 
%        prices, RATE is the risk free interest rate, MATS is a vector of 
%        periods until maturity, SIG is overall volatility of the portfolio, and
%        CONTRACT is the number of options (options/contract*contracts) of each
%        instrument.

function capaldemo
%MATLAB Tour Partial Function Help:  fin_con
%
%  CAPALDEMO Capital Allocation demo.
%  This is a demo for the function PORTALLOC.M

function optport
%MATLAB Tour Partial Function Help:  fin_con
%
% OPTPORT Portfolio optimization demonstration.
%        OPTPORT demonstrates portfolio optimization using given funds.
% 
%        

function frontier
%MATLAB Tour Partial Function Help:  fin_con
%
% FRONTIER Efficient frontier. 
%        [RISK,ROR,WTS] = FRONTIER(ASSET,RET,PTS,TARGET) returns
%        the standard deviations,RISK,and rates of return,ROR,that comprise the
%        efficient frontier of a given portfolio, plus the weights of each
%        asset,WTS,for each point on the frontier.  ASSET is an M-by-N matrix
%        of time series data where each column represents a
%        single asset.  RET is a 1-by-N vector of the rates of return for
%        asset.  PTS specifies the number of efficient frontier points to be
%        calculated.  By default, PTS = 10.  TARGET specifies the desired rate
%        of return based on the ASSET and RET data.  When entering a target
%        rate of return, enter PTS as an empty matrix.  RISK and ROR are
%        PTS-by-1 vectors, and WTS is a PTS-by-(number of assets) matrix. 
%  
%        FRONTIER(ASSET,RET) plots the efficient frontier without returning 
%        any data to the MATLAB workspace. 
%         
%        [RISK,ROR,WTS] = FRONTIER(ASSET,RET,PTS) returns the standard  
%        deviations, rates of return, and weights of each point on the  
%        efficient frontier. 
%  
%        [RISK,ROR,WTS] = FRONTIER(ASSET,RET,[],TARGET) returns the 
%        efficient frontier data associated with a specific rate of return 
%        on the frontier. 
%  
%        

function portror
%MATLAB Tour Partial Function Help:  fin_con
%
% PORTROR Portfolio expected rate of return. 
%        R = PORTROR(RS,WS) calculates the expected rate of return  
%        for a portfolio of assets given the expected rate of return  
%        and weight of each asset.  RS is an 1xN matrix of rates of 
%        return and WS is an MxN matrix of weights.  Each column of 
%        RS represents the rate of return for a single security.  
%        Each row of WS represents a different weighting combination 
%        of the assets in the portfolio.  R, the expected rate of  
%        return, is a 1xM vector. 
%  
%        For example, a portfolio is made up of two assets ABC   
%        and XYZ having expected rates of return of 10% and 14%,  
%        respectively.  40% percent of the portfolio's funds are  
%        allocated to asset ABC and the remaining funds are allocated  
%        to asset XYZ.  The portfolio's expected rate of return is  
%        r = portror([.1 .14],[.4 .6]) or r = 0.124. 
%  
%        

function portvar
%MATLAB Tour Partial Function Help:  fin_con
%
% PORTVAR Portfolio variance. 
%        V = PORTVAR(ASSET,WS) returns the variance for a portfolio 
%        of assets where ASSET is a matrix of asset data and WS are 
%        the corresponding weights of each asset.  ASSET is an MxN  
%        matrix of N securities and WS is a 1xN vector where each  
%        column of ASSET is a time series of historical data for a  
%        single security and each column of WS is a corresponding  
%        weight for each security in ASSET.   If WS is a matrix of  
%        size RxN, the portfolio variance, V, is returned as an  
%        Rx1 vector with each row representing a variance calculation  
%        for each row of WS.  
%  
%        V = PORTVAR(ASSET) assigns each security an equal weight when 
%        calculating the portfolio variance. 
%  
%        

function bdtdemo
%MATLAB Tour Partial Function Help:  fin_con
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
%     This is private file of the BDT Demo and is not meant to be called
%     directly by the user.
% 
% Author: C. Bassignani, 05-20-98 
%    Copyright (c) 1995-98 by The MathWorks, Inc.
%  $Revision: 1.14 $   $Date: 1998/10/16 23:19:17 $

function plotbintree
%MATLAB Tour Partial Function Help:  fin_con
%
%  PLOTBINTREE Plots the nodes of a binary recombining tree.  The
%  tree is stored in the upper triangle of a matrix and with time
%  running along the rows and states running along the colunms.  The
%  tree values can contain NaN entries to mask unused nodes.
% 
%    plotbintree(TreeMat, TreeTimes)
% 
%  Inputs:
%    TreeMat : [NSTATES by NTIMES] matrix with the upper triangle
%    storing the Y values on the tree at every time and state.
%   
%    TreeTimes : [1 by NTIMES] vector containing the X values of the
%    nodes.  If TreeTimes is empty, [], or not entered, the times
%    are numbered 1 to NTimes.
% 
%  Example:
%    [PriceTree] = binprice(52,50,.1,5/12,1/12,.4,0,0,2.06,3.5)
% 
%    PriceTree = 
%  
%      52.0000   58.1367   65.0226   72.7494   79.3515   89.0642 
%            0   46.5642   52.0336   58.1706   62.9882   70.6980 
%            0         0   41.7231   46.5981   49.9992   56.1192 
%            0         0         0   37.4120   39.6887   44.5467 
%            0         0         0         0   31.5044   35.3606 
%            0         0         0         0         0   28.0688 
% 
%    plotbintree(PriceTree, (0:5)/12)
% 

function garchgui
%MATLAB Tour Partial Function Help:  fin_con
%
% GARCHGUI Garch Estimation Demo.

function ugarchplot
%MATLAB Tour Partial Function Help:  fin_con
%
% UGARCHPLOT Plot univariate GARCH(P,Q) time series processes
% 
%  ugarchplot(U , H)
% 
%  Inputs:
%    U: Single column vector of innovations, representing a mean-zero,
%       discrete-time stochastic process. The innovations time series U is 
%       assumed to follow a GARCH(P,Q) process (see Notes below). 
% 
%    H: Single column vector of the conditional variance corresponding 
%       to the innovations vector U. Note that U and H are the same length, and 
%       form a 'matching' pair of vectors. To model the GARCH(P,Q) process, the 
%       conditional variance time series, H(t), must be constructed (see Notes 
%       below). Thus, H(t) represents the time series inferred from the 
%       innovations time series vector U(t). 
% 
%  Output:
%     UGARCHPLOT plots the innovations time series column vector U, and the
%     square root of the corresponding conditional variance column vector H.
%     Since the purpose of this function is to allow visual comparison of the
%     innovations time series U and the corresponding conditional standard 
%     deviation, U and H must be column vectors of the same length.
% 
%     The plot is 2-tiered: the top plot is the innovations time series U; the
%     bottom plot is the corresponding conditional standard deviation, which is
%     just the square root of H. Note that although the conditional variance H 
%     is the input, the square root of H is what appears in the bottom plot. 
%     Accepting the conditional variance H as an input, rather than the standard 
%     deviation of H, is just to maintain consistency with the output arguments 
%     of the univariate simulation function UGARCHSIM.
% 
%  Notes:
%    The time-conditional variance, H(t), of a GARCH(P,Q) process is modeled 
%    as follows:
% 
%      H(t) = Kappa + Alpha(1)*H(t-1) + Alpha(2)*H(t-2) +...+ Alpha(P)*H(t-P)
%                   + Beta(1)*U^2(t-1)+ Beta(2)*U^2(t-2)+...+ Beta(Q)*U^2(t-Q)
% 
%    Note that U is vector of innovations representing a mean-zero, discrete-time
%    stochastic process. Although H is generated via the equation above, U and H
%    are related as follows:
%     
%      U(t) = sqrt(H(t))*v(t), where {v(t)} is an i.i.d. sequence.
% 
%  

function degatool
%MATLAB Tour Partial Function Help:  fin_con
%
%  This is the machine-generated representation of a Handle Graphics object
%  and its children.  Note that handle values may change when these objects
%  are re-created. This may cause problems with any callbacks written to
%  depend on the value of the handle at the time the object was saved.
% 
%  To reopen this object, just type the name of the M-file at the MATLAB
%  prompt. The M-file and its associated MAT-file must be on your path.

function alltsdemo
%MATLAB Tour Partial Function Help:  fin_con
%
% ALLTSDEMO starts the Financial Time Series Demo.
% 

function fintsdemo
%MATLAB Tour Partial Function Help:  fin_con
%
% FINTSDEMO is a collection of the Financial Time Series Demo.  It is
%     called by ALLTSDEMO.  So, please run ALLTSDEMO instead of this 
%     function.
% 

function demtseries
%MATLAB Tour Partial Function Help:  fin_con
%
% @DEMTSERIES/DEMTSERIES constructs a financial time series object that
%     contains 4 (four) fields that represent name, frequency, dates and
%     value. These fields can only be accessed from inside its methods.
%     There can only be 1 (one) value series per time series object.
% 
%     TS = demtseries; initiates TS as a time series object with name = [],
%     frequency = 6 (mixed data), dates = [] and value = [].
% 
%     TS = demtseries(OTHERTS);, where OTHERTS is another time series object,
%     creates a replica of OTHERTS and stores it in TS.
%     
%     TS = demtseries(DATEANDVALUE, TSNAME, TSFREQ);, initiates TS as a time 
%     series object with name = TSNAME, frequency = TSFREQ, 
%     dates = DATEANDVALUE(:, 1) and value = DATEANDVALUE(:, 2).  
% 
%     Input arguments:
% 
%         DATEANDVALUE is a 2-column matrix with serial (numeric) dates
%         in the first column and the values for those dates in the
%         second.  This input is optional.  If it is not supplied, the
%         default is [].
% 
%         TSNAME is a string containing the name associated with the time
%         series object.  This input is optional.  If it is not supplied,
%         the default is [].
% 
%         TSFREQ is an integer or a string representing the frequency of
%         the data in the time series object.  This input is optional. 
%         If it is not supplied, the default is 6 for mixed frequency data.
%         TSFREQ can be one of the followings:
% 
%             Integer   String   Representing
%                0         d      Daily
%                1         w      Weekly
%                2         m      Monthly
%                3         q      Quarterly
%                4        hy      Half-yearly
%                5         y      Yearly
%                6                Mixed
% 
%     Example:
% 
%         dates = (today:today+10)';
%         values = rand(11, 1)*1000;
%         ts = demtseries([dates values], 'Random Time Series', 0)
% 
%     The above example creates an 11-day daily time series starting from
%     today with random values assigned to each day, 'Random Time Series'
%     as the name, and 0 (daily) as the frequency.
% 

function constant
%MATLAB Tour Partial Function Help:  fin_con
%
% @DEMTSERIES/CONSTANT creates a time series constant for the Economic 
%     Charting System.
% 
%     TSC = constant( ConstValue, DateStart, DateStop, Freq ); returns
%     a time series object TSC which values are constant.  DateStart and
%     DateStop are the starting date and final date, respectively.  If 
%     they are not supplied, a mixed frequency time series object with 
%     serial dates 0 and 1e11 will be generated for the constant value, 
%     ConstValue. Freq is an optional input argument that represents the 
%     frequency of the constant time series.  If it is not supplied, the 
%     default is daily time series.
% 
%     Valid calling syntax are:
% 
%         TSC = constant(ConstValue);
%         TSC = constant(ConstValue, DateStart, DateStop);
%         TSC = constant(ConstValue, DateStart, DateStop, Freq);
% 

function celldec
%MATLAB Tour Partial Function Help:  fin_con
%
% CELLDEC performs reverse operation to CELLENC; decodes date read from
%         database.
% 
%     Inputs:  1. Cell array of same size as input but with all elements
%                 in string format. Numeric elements are identified by
%                 a leading ± (ascii 177).
% 
%     Outputs: 1. Cell array where elements are either strings or vectors
%                 of double precision
% 
%     Note: This function is not called by anybode else of the @DEMTSERIES
%           object and TimeSeriesDemo stuff.
% 

function cellenc
%MATLAB Tour Partial Function Help:  fin_con
%
% CELLENC encodes cell array of chart data ready for save to database.
% 
%      Inputs:  1. Cell array where elements are either strings or vectors
%                  of double precision
% 
%      Outputs: 1. Cell array of same size as input but with all elements
%                  in string format. Numeric elements are identified by
%                  a leading ± (ascii 177).
% 
%     Note: This function is not called by anybode else of the @DEMTSERIES
%           object and TimeSeriesDemo stuff.
% 

function sprmtrx
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/sprmtrx.m ---
%
% SPRMTRX Spreadsheet matrix creates a matrix with a column of dates
%     and ten columns for time series
%  
%     [OutDate, OutMtx] = sprmtrx(TS1, TS2, ... , TS10) returns a vector of
%     dates OutDate that is the union of all 10 input time series, and OutMtx
%     which is the matrix of values of all time series put into a matrix.
%     This matrix is of the size length(OutDate)-by-10.  For dates that have
%     no values, it contant will be NaN.
% 

function tod
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/tod.m ---
%
% @DEMTSERIES/TOD converts any other frequency time series object to a daily
%     time series object.  It convert the time series object to working days.
% 
%     TSD = tod(TS);
% 
%     It will basically copy the periodic value for how ever many days there
%     are in the period of the input time series.  For example, if the input
%     time series is a weekly time series, the value for week 1 will be copied
%     4 times for each of the next business days until the next week's value
%     is encountered and the same process is repeated for that next week's 
%     value.
% 
%     Obviously, if the input time series is a daily time series, it will
%     just copy the time series into the new one.  However, if your daily 
%     time series is a continuous daily time series that is a time series
%     that includes weekend data, it will be pruned to only the data for 
%     the business days.
% 

function todc
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/todc.m ---
%
% @DEMTSERIES/TODC converts any other frequency time series object to a
%     continuous daily time series object.  It convert the time series object
%     to consecutive days including weekends.
% 
%     TSDC = todc(TS);
% 
%     It will basically copy the periodic value for how ever many days there
%     are in the period of the input time series.  For example, if the input
%     time series is a weekly time series, the value for week 1 will be copied
%     6 times for each of the days until the next week's value is encountered
%     and the same process is repeated for that next week's value.
% 
%     Obviously, if the input time series is a daily time series, it will
%     just copy the time series into the new one.  However, if your daily 
%     time series is NOT a continuous daily time series that is a time 
%     series that does not includes weekend data, the weekend data will be
%     LINEARLY INTERPOLATED from the Friday before and the Monday after
%     data.  It interpolates using MATLAB's INTERP1Q function.
% 

function tohy
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/tohy.m ---
%
% @DEMTSERIES/TOHY converts any other frequency time series object to a 
%     half-yearly time series object. 
% 
%     TSHY = tohy(TS, MeanMode) returns a time series object TSHY which
%     contains a half-yearly time series object calculated from the
%     time series object TS.  MeanMode is a required parameter that
%     specify the type of averaging the input time series, if is is of
%     a higher frequency time series such as daily, weekly, or monthly
%     time series.
% 
%     Note:  This function is not fully supported.
% 

function tom
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/tom.m ---
%
% @DEMTSERIES/TOM converts any other frequency time series object to a monthly
%     time series object.
% 
%     TSM = tom(TS);
% 
%     It will basically copy the periodic value for how ever many months there
%     are in the period of the input time series.  For example, if the input
%     time series is a daily time series, the value for each month in the
%     monthly time series is the average of the daily values in the month; 
%     similarly with weekly time series as the input.  If the input time 
%     series is a quarterly or yearly time series, the monthly values are the
%     input values replicated how ever many times as needed to fill the new
%     monthly time series.  If the input time series is a half-yearly time
%     series, the monthly data is linearly interpolated using INTERP1Q.  The 
%     dates are set to 15th of each month.  
% 
%     Obviously, if the input time series is a monthly time series, it will
%     just copy the time series into the new one.  And the dates are set to 
%     the 15th of the month.
% 

function toq
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/toq.m ---
%
% @DEMTSERIES/TOM converts any other frequency time series object to a 
%     quarterly time series object.
% 
%     TSQ = toq(TS);
% 
%     It will basically copy the periodic value for how ever many quarters
%     there are in the period of the input time series.  For example, if the
%     input time series is a daily time series, the value for each quarter in
%     the quarterly time series is the average of the daily values of the 3 
%     months in the quarter; similarly with weekly time series as the input.
%     If the input time series is a half-yearly or yearly time series, the 
%     quarterly values are the input values replicated how ever many times as 
%     needed to fill the new quarterly time series.  The dates are set to 15th
%     of each of the quarterly month ie. Feb, May, Aug, Nov.  
% 
%     Obviously, if the input time series is a monthly time series, it will
%     just copy the time series into the new one.  And the dates are set to 
%     the 15th of the quarterly months.
% 

function tow
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/tow.m ---
%
% @DEMTSERIES/TOW converts any other frequency time series object to a 
%     weekly time series object.  It convert the time series object to 
%     weekly data which is set on Fridays.
% 
%     TSW = tow(TS);
% 
%     It will basically copy the periodic value for how ever many days there
%     are in the period of the input time series.  For example, if the input
%     time series is a daily time series, the output will be a time series 
%     containing Fridays data only.  Now, if the input is a monthly time 
%     series, the output will be the data for each month replicated how ever
%     many Fridays there are in the months of the input monthly time series.
% 
%     Obviously, if the input time series is a weekly time series, it will
%     just copy the time series into the new one with the exception that
%     the date is set to Fridays, if not on Fridays already.
% 

function tox
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/tox.m ---
%
% @DEMTSERIES/TOX converts an input time series object TS to an output time
%     series object of specified frequency X
% 
%     TSX = tox( TS, X ) converts the input time series object TS to another
%     time series TSX of specified frequency X where X can be one of the 
%     following values:
% 
%         0 =='daily'
%         1 =='weekly'
%         2 =='monthly'
%         3 =='quarterly'
%         4 =='half yearly' Warning:Half Yearly is not fully supported.
%         5 =='yearly'
%         6 =='mixed'
% 
%     TS can be of any frequency time series object.  This function calls
%     the appropriate functions TOD, TOW, TOM, TOQ, TOHY, or TOY.
% 

function toy
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/toy.m ---
%
% @DEMTSERIES/TOY converts any other frequency time series object to a 
%     yearly time series object.
% 
%     TSY = toy(TS);
% 
%     It converts the input time series into a quarterly time series
%     date using TOQ (see HELP TOQ for details).  Then, it averages the
%     quarterly values in each year for the values of the year in the
%     yearly time series object.
% 

function fstvalue
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/fstvalue.m ---
%
% DEMTSERIES/FSTVALUE gets the very first value in a time series.
% 
%     FirstValue = fstvalue(TS) returns a 1-by-2 array, FirstValue, of a 
%     serial date and a value which is the first one in the input time series 
%     TS.
% 

function dateft
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/dateft.m ---
%
% @DEMTSERIES/DATEFT returns the first and last dates in a time series
%     object.
%  
%     [StartDate, StopDate] = dateft( TS ) returns the first date in the
%     time series object TS, StartDate, and the last date in the time series
%     object, StopDate.  Those dates are in serial date format.
% 

function getend
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/getend.m ---
%
% @DEMTSERIES/GETEND gets the last date in a time series object.
% 
%     StopDate = getend(TS) returns a string date, StopDate, in UK format,
%     DD/MM/YYYY, that is the last date in the time series TS.
% 

function getfreq
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/getfreq.m ---
%
% @DEMTSERIES/GETFREQ gets the frequency class of a time series object.
% 
%     Freq = getfreq(TS) returns a class corresponding to the frequency 
%     value of a time series object TS.  Possible values for Freq are:
% 
%         0 => 'daily'
%         1 => 'weekly'
%         2 => 'monthly'
%         3 => 'quarterly'
%         4 => 'half yearly' Warning:Half Yearly is not fully supported.
%         5 => 'yearly'
%         6 => 'mixed'
% 

function getstart
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/getstart.m ---
%
% @DEMTSERIES/GETSTART gets the first date in a time series object.
% 
%     StartDate = getend(TS) returns a string date, StartDate, in UK 
%     format, DD/MM/YYYY, that is the first date in the time series TS.
% 

function getstop
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/getstop.m ---
%
% @DEMTSERIES/GETSTOP is a wrapper function around @DEMTSERIES/GETEND; it
%     gets the last date in a time series object.  See @DEMTSERIES/GETEND
%     for further details.
% 

function getname
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/getname.m ---
%
% @DEMTSERIES/GETNAME gets the name associated with a time series object.
% 
%     TSName = getname(TS) returns a string TSName which is the content of
%     TS.n, the name assigned to the name field of the time series 
%     object.
% 

function val
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/val.m ---
%
% @DEMTSERIES/VAL gets the values in a time series object and puts then in a 
%     column vector.  It can also get a subset of the time series object.
% 
%     [TSval, TSdate] = val(TS, Indeces) returns a column matrix TSval which
%     contains the values of the time series TS and another column matrix
%     TSdate which has the dates associated with the values.  TSdate is an
%     optional output argument.  Indices is an optional input argument.  If 
%     it is not suplied, all values in the time series are returned.
% 
%     Also, [TSval, TSdate] = val(TS, StartDate) returns
%     a column matrix TSval which contains the values of the time series TS
%     and another column matrix TSdate which has the dates associated with 
%     the values extracted from StartDate to the end of the time series.  
%     TSdate is an optional output argument.  
%     StartDate is a date string in UK format, DD/MM/YY or DD/MM/YYYY.  
% 
%     Alternatively, [TSval, TSdate] = val(TS, StartDate, StopDate) returns
%     a column matrix TSval which contains the values of the time series TS
%     and another column matrix TSdate which has the dates associated with 
%     the values extracted between StartDate and StopDate.  TSdate is an 
%     optional output argument.  StartDate and StopDate are date strings in 
%     UK format, DD/MM/YY or DD/MM/YYYY.  StartDate can be '' which means 
%     the beginning of the time series object.
% 
%     Valid calling syntax are:
% 
%         TSval = val(TS, StartDate, StopDate);
%         TSval = val(TS, '', StopDate);
%         TSval = val(TS, StartDate);
%         TSval = val(TS, NumIndices);
%         TSval = val(TS);
%         [TSval, TSdate] = val(TS, StartDate, StopDate);
%         [TSval, TSdate] = val(TS, '', StopDate);
%         [TSval, TSdate] = val(TS, StartDate);
%         [TSval, TSdate] = val(TS, NumIndices);
%         [TSval, TSdate] = val(TS);
% 

function append
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/append.m ---
%
% @DEMTSERIES/APPEND appends one time series object to another.  There will
%     be no name assigned to the new time series object. If the frequencies
%     of the 2 input time series objects are the same, the frequency of the
%     new one will be the same as those two.  Otherwise, the frequency of 
%     the new time series object is 6 for mixed data.
% 

function clcutts
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/clcutts.m ---
%
% @DEMTSERIES/CLCUTTS ia the command line version of CUTTS; cuts time series
%     according to date settings.
% 
%     TSO = clcutts(TS, Command) returns a time series object TSO which is a
%     subsection of the input time serie object TS.  The section is determined
%     by setting global variables SDATE and/or FDATE.  SDATE for starting date
%     and FDATE for final date.  The Command input argument determines which
%     of the dates is to be regarded or both of them should be regarded.  The 
%     followings are the possible value for Command:
% 
%         0 => from beginning of time series TS to FDATE
%         1 => from SDATE to the end of time series TS
%         2 => from SDATE to FDATE of time series TS
% 
%     Another global variable, confcell, needs to be declared and defined.

function cutts
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/cutts.m ---
%
% @DEMTSERIES/CLCUTTS cuts time series according to date settings.
% 
%     TSO = cutts(TS, Command) returns a time series object TSO which is a
%     subsection of the input time serie object TS.  The section is determined
%     by setting global variables SDATE and/or FDATE.  SDATE for starting date
%     and FDATE for final date.  The Command input argument determines which
%     of the dates is to be regarded or both of them should be regarded.  The 
%     followings are the possible value for Command:
% 
%         0 => from beginning of time series TS to FDATE
%         1 => from SDATE to the end of time series TS
%         2 => from SDATE to FDATE of time series TS
% 

function windowts
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/windowts.m ---
%
% @DEMTSERIES/WINDOWSTS generates a subset of the time series base on the 
%                       Start Date, Finanl Date, or both.  These dates are
%                       set as the global variables SDATE and FDATE.
% 
%     TSW = WINDOWSTS(TS) returns a time series object TSW which may contain
%     a subset of the time series object TS.  The boundaries of the subset
%     are determined by the glbal variables SDATE and/or FDATE.
% 

function lag
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/lag.m ---
%
% @DEMTSERIES/LAG lags a time series object by n periods.  Lagging a time
%     series object means using the current period's value for the next
%     period's; that is, shift the data to later dates.
% 
%     TSL = lag( TS, NumPeriod ) returns a time series object TSL which
%     contains the values of the time series object TS lagged by NumPeriods.
%     NumPeriods is an integer specifying the number of periods to lag the
%     time series object TS by; it depends on the frequency of the input
%     time series.  For example, if you have a weekly time series, setting
%     NumPeriods to 5 will result in a weekly time series lagged by 5 days.
% 

function lastvalue
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/lastvalue.m ---
%
% DEMTSERIES/LASTVALUE gets the very last value in a time series.
% 
%     LastValue = lastvalue(TS) returns a 1-by-2 array, LastValue, of a 
%     serial date and a value which is the last one in the input time series 
%     TS.
% 

function lead
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/lead.m ---
%
% @DEMTSERIES/LEAD leads a time series object by n periods.  Leading a time
%     series object means using the next period's value for the current
%     period's; that is, shift the data to earlier dates.
% 
%     TSL = lead( TS, NumPeriods ) returns a time series object TSL which
%     contains the values of the time series object TS led by NumPeriods.
%     NumPeriods is an integer specifying the number of periods to lead the
%     time series object TS by; it depends on the frequency of the input
%     time series.  For example, if you have a daily time series, setting
%     NumPeriods to 5 will result in a daily time series led by 5 days.
% 

function sunion
%MATLAB Tour Partial Function Help:  fin_con
%
% SUNION returns the union of two sorted vectors
% 
%     Dout = sunion(DinA, DinB); returns a vector Dout that represents the
%     union of the two input column vectors DinA and DinB.
%     

function sunique
%MATLAB Tour Partial Function Help:  fin_con
%
% SUNIQUE return the unique set of a sorted vector
% 
%     Dout = sunique(Din); returns a vector Dout which contains the unique
%     occurences of the elements in the array Din.
% 

function dtunion
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/dtunion.m ---
%
% @DEMTSERIES/DTUNION returns union of dates for 4 time series from the main 
%     window.
% 
%     DateUnion = dtunion(TS1, TS2, TS3, TS4, TS5);
% 
%     The fifth time series is optional.  The first four are required.
% 

function fridays
%MATLAB Tour Partial Function Help:  fin_con
%
% @DEMTSERIES/FRIDAYS generates a vector of fridays from start to stop dates.
%     The dates must be in serial date format NOT string dates.
% 
%     Example:
% 
%         >> fris = fridays(datenum('05/01/98'), datenum('05/15/98'));
% 

function datenumuk
%MATLAB Tour Partial Function Help:  fin_con
%
% @DEMTSERIES/DATENUMUK converts UK date format, DD/MM/YYYY, to a serial
%     date number, such as the output of DATENUM.
% 
%     Valid calling syntax are:
% 
%         >> dtnum = datenumuk( '1/4/1998' );    %First of April 1998
%         >> dtnum = datenumuk( '7/1997' );      %September 1997
%         >> dtnum = datenumuk( 'q3/98' );       %Third quarter of 1998
% 

function uk2usa
%MATLAB Tour Partial Function Help:  fin_con
%
% @DEMTSERIES/UK2USA Convert date string format #2 UK, DD/MM/YYYY, to USA 
%     date format.
% 
%     If you only input the month and year, the first day of the month in
%     that year will be returned.  If you input a quarter indicator (q1/1998)
%     and the year, the fifteenth day of the middle month of the quarter will
%     be returned.
% 
%     The 3 valid calling syntax are:
% 
%         >> us_date = uk2usa('1/4/1998');    %That's first of April 1998
%         >> us_date = uk2usa('7/1997');      %That's September 1997
%         >> us_date = uk2usa('q3/98');       %That's third quarter of 1998
% 
%     Note:  You may use 2-digit year; hoever, keep in mind the year 2000 and
%            beyond.  '00', '01', '02', etc. are regarded as 1900, 1901, 1902,
%            respectively.
% 

function usa2uk
%MATLAB Tour Partial Function Help:  fin_con
%
% @DEMTSERIES/USA2UK converts date string format #2 USA, MM/DD/YYYY, to UK 
%     format, DD/MM/YYYY.
% 
%     This function will only convert the following formats:
% 
%         MM/DD/YY     to     DD/MM/YY
%         MM/DD/YYYY   to     DD/MM/YYYY
%         MM/DD        to     DD/MM
% 

function weekdays
%MATLAB Tour Partial Function Help:  fin_con
%
% WEEKDAYS Creates a vector of working days from start to stop dates.
% 
%     WeekDayVec = weekdays(StartDate, StopDate) returns a vector of 
%     weekdays, WeekDayVec, between the starting date, StartDate, and end
%     date, StopDate.  The WeekdayVec is a vector of serial dates.
% 

function display
%MATLAB Tour Partial Function Help:  fin_con
%
% DISPLAY Display array.
%    DISPLAY(X) is called for the object X when the semicolon is not used
%    to terminate a statement. 
% 
%    For example,
%      X = inline('sin(x)')
%    calls DISPLAY(X) while
%      X = inline('sin(x)');
%    does not.
% 
%    A typical implementation of DISPLAY calls DISP to do most of the work
%    and looks like this
% 
%       function display(X)
%       if isequal(get(0,'FormatSpacing'),'compact')
%          disp([inputname(1) ' =']);
%          disp(X)
%       else
%          disp(' ')
%          disp([inputname(1) ' =']);
%          disp(' ');
%          disp(X)
%       end
%    
%    

function barstck
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/barstck.m ---
%
% @DEMTSERIES/BARSTCK plots a stacked bar chart of 4 time series data at a
%     time.
% 
%     barstck(TS1, TS2, TS3, TS4) plots the data from 4 equivalent time 
%     series objects as a stacked bar chart.
% 

function barts
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/barts.m ---
%
% @DEMTSERIES/BARTS plots a bar chart a time series data.
% 
%     The followings are the possible calling syntax for this function:
% 
%         barts(TS)
%         barts(CMap, TS)
%         barts(CMap, TS, Width)
%         barts(CMap, TS, Width, GroupOrStack)
%         barts(CMap, TS, Width, GroupOrStack, LineSpec)
% 
%     where TS is the required input arguments that represent the input
%     time series object.  CMap, Width, GroupOrStack, and LineSpec are 
%     optional input arguments that represents colormap, line width, 
%     'Grouped' or 'Stacked' mode, and line color specification, 
%     respectively.  Please see HELP BAR for further details.
% 

function plotts
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/plotts.m ---
%
% @DEMTSERIES/PLOTTS plots time series data.
% 
%     Similar to plot() but can only plot one time series object at a time.
% 
%     plotts(TS, ... )
% 

function semilogy
%MATLAB Tour Partial Function Help:  fin_con
%
% SEMILOGY Semi-log scale plot.
%    SEMILOGY(...) is the same as PLOT(...), except a
%    logarithmic (base 10) scale is used for the Y-axis.
% 
%    

function ssplot
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/ssplot.m ---
%
% @DEMTSERIES/SSPLOT plots time series data.
% 
%     Similar to plotts() but can only plot one time series object at a time
%     and it adds title in the figure window.  If you use this function
%     multiple times while a Time Series plot figure window is still up,
%     it will replace the old plot with the new one in the same window.
% 
%     ssplot(TS, ... )
% 

function stairs
%MATLAB Tour Partial Function Help:  fin_con
%
% STAIRS Stairstep plot.
%    STAIRS(Y) draws a stairstep graph of the elements of vector Y.
%    STAIRS(X,Y) draws a stairstep graph of the elements in vector Y at
%    the locations specified in X.  The X-values must be in
%    ascending order and evenly spaced.
%    STAIRS(...,STYLE) uses the plot linestyle specified by the
%    string STYLE.
% 
%    H = STAIRS(X,Y) returns a vector of line handles.
%    [XX,YY] = STAIRS(X,Y) does not draw a graph, but returns vectors
%    X and Y such that PLOT(XX,YY) is the stairstep graph.
% 
%    Stairstep plots are useful for drawing time history plots of
%    zero-order-hold digital sampled-data systems.
% 
%    

function annav
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/annav.m ---
%
% @DEMTSERIES/ANNAV calculates the mean of a time series yearly starting from
%     the beginning of the time series or from specified offset in the time
%     series object.
% 
%     TSA = annav(TS, OffsetPeriods) returns a yearly time series object that
%     contains the yearly average of the time series object TS starting from 
%     OffsetPeriods.  OffsetPeriods is an optional input argument.  If it is 
%     not supplied, the default is 1; thus, if you call the function without 
%     the second input argument, you will get a yearly average from the 
%     beginning of the times series TS.
% 

function apch
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/apch.m ---
%
% @DEMTSERIES/APCH calculates the annualised percentage change from period
%     to period.  It calculates the percentage difference between a value
%     in the time series and the next one, annualised.
% 
%     TSA = apch(TS, OffsetPeriods) returns a time series object TSA which
%     contains no names, the frequency of the input time series TS, and the
%     annualised percentage change of the time series values from period to
%     period.  OffsetPeriods is an optional parameters that you can used to
%     specify at which period you would like to start calculating the
%     annualised percentage change.  If it not supplied, the default is 1.
% 
%     The annualised percentage change is calculated using the formula:
% 
%         APC = (newvalue/oldvalue)^numperiods*100 - 100
% 
%     it is analogous to the annualised interest rate formula:
% 
%         AIR = (1+r)^t - 1
% 

function arith
%MATLAB Tour Partial Function Help:  fin_con
%
% Arithmetic operators.
%  +   Plus.
%      X + Y adds matrices X and Y.  X and Y must have the same
%      dimensions unless one is a scalar (a 1-by-1 matrix).
%      A scalar can be added to anything.  
% 
%  -   Minus.
%      X - Y subtracts matrix X from Y.  X and Y must have the same
%      dimensions unless one is a scalar.  A scalar can be subtracted
%      from anything.  
% 
%  *   Matrix multiplication.
%      X*Y is the matrix product of X and Y.  Any scalar (a 1-by-1 matrix)
%      may multiply anything.  Otherwise, the number of columns of X must
%      equal the number of rows of Y.
% 
%  .*  Array multiplication
%      X.*Y denotes element-by-element multiplication.  X and Y
%      must have the same dimensions unless one is a scalar.
%      A scalar can be multiplied into anything.
% 
%  ^   Matrix power.
%      Z = X^y is X to the y power if y is a scalar and X is square. If y is an
%      integer greater than one, the power is computed by repeated
%      multiplication. For other values of y the calculation
%      involves eigenvalues and eigenvectors.
%      Z = x^Y is x to the Y power, if Y is a square matrix and x is a scalar,
%      computed using eigenvalues and eigenvectors.
%      Z = X^Y, where both X and Y are matrices, is an error.
% 
%  .^  Array power.
%      Z = X.^Y denotes element-by-element powers.  X and Y
%      must have the same dimensions unless one is a scalar. 
%      A scalar can operate into anything.
%
% Overloaded methods
%    help demtseries/arith.m

function arithtrend
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/arithtrend.m ---
%
% @DEMTSERIES/ARITHTREND calculates the linear trend for a time series
%     object using the backslash (\) operator.  It is essentially
%     doing a linear regression to fit the data to the linear equation:
% 
%         y(x) = b + m * x
% 
%     It calculates what b and m are, then generates the data points
%     that lie on the line at every x, y(x).  These values of y(x) are the
%     ones contained in the resulting time series object.
% 

function del
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/del.m ---
%
% @DEMTSERIES/DEL calculates absolute change over n periods for a time series
%     object.
% 
%     TSDel = del( TS, NPeriod ) returns a time series object that is the 
%     absolute difference of values between periods NPeriod and 
%     length(TS)-NPeriod.  If NPeriod is not supplied, the default is 1.
%     

function devtrend
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/devtrend.m ---
%
% @DEMTSERIES/DEVTREND calculates deviation of a time series object from 
%     linear or log trend.
% 
%     TSDT = devtrend(TS) finds the deviation from either an arithmetic or 
%     a log trend by deflating the original series TS by the result of
%     a trend of that series.  The return is another time series object TSDT.

function dfl
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/dfl.m ---
%
% @DEMTSERIES/DFL deflates ts1 by ts2, ts2 can be an integer.
% 
%  ts_dfl = dfl( ts1, ts2 );
% 

function dfmt
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/dfmt.m ---
%
% @DEMTSERIES/DFMT finds the deviation from the moving trend by deflating 
%     the original series by the result of a Moving Trend (MT) of that 
%     series.
% 
%     TSD = dfmt( TS );
% 

function dfmtrend
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/dfmtrend.m ---
%
% @DEMTSERIES/DFMTREND Calculates a DFMT on the data, the results of which
%     are centred on 100. This DFMT is used as the function output
%     up to the point where it crosses 100 for the last time.
%     However, if this point is in the last three years of the time 
%     series then the previous crossing point is used.
%     The remainder of the output is calculated by deflating the 
%     input by a trend, which can either be specified as a function 
%     argument, or else it will be calculated using TREND 
%     on the whole input series;
% 
%     eg.
% 
%        TSD = dfmtrend( ftse200, 2.5 );
% 
%     will calculate the last part of the output as a deviation
%     from a trend rate of 2.5%
% 

function exp
%MATLAB Tour Partial Function Help:  fin_con
%
% EXP    Exponential.
%    EXP(X) is the exponential of the elements of X, e to the X.
%    For complex Z=X+i*Y, EXP(Z) = EXP(X)*(COS(Y)+i*SIN(Y)).
% 
%    

function evenlma
%MATLAB Tour Partial Function Help:  fin_con
%
% EVENLMA calculates the Even Linma Weights.
% 
%     WeightsMatrix = evenlma( Order ) returns the weight matrix WeightMatrix
%     that contains the Even Linear Moving Average Weights based on the order
%     Order specified.  Order must be an even number and greater than 3.
% 

function hender
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/hender.m ---
%
% @DEMTSERIES/HENDER creates a Henderson weighted moving average of a time
%     series object.
% 
%     TSH = hender( TS, WindowLength ) returns a time series object TSH
%     which contains the Henderson weighted moving average of the time
%     series object TS.  WindowLength is an integer that specify the length
%     of the averaging window.  Valid WindowLength are 5, 9, 13, and 23 in
%     HENDER.
% 
%     

function index
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/index.m ---
%
% @DEMTSERIES/INDEX calculates a time series indices based on the value in
%     the time series on a certain date.
% 
%     TS_idx = index(TS, BaseDate) returns a time series object, TS_idx, 
%     whose values are the ratios of the values in TS by the value of TS
%     on date BaseDate.  The BaseDate must be in UK format, DD/MM/YY.
% 
%     Note:  This function, index, is NOT an array/matrix indexing 
%            function.  This function calculates an index in the finance
%            sense ie. a ratio of a value or values based on a given 
%            reference (base) value.
% 

function interpt
%MATLAB Tour Partial Function Help:  fin_con
%
% INTERPT Fast vector interpolation for use in time series methods.
% 
%     Yi=interpt(XVec, YVec, Xi);
% 
%     For more details, see HELP INTERP1Q.
% 

function linma
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/linma.m ---
%
% @DEMTSERIES/LINMA creates a linearly weighted moving average of a time
%     series object.
% 
%     TSLMA = linma( TS, WindowLength ) returns a time series object TSLMA
%     which contains the linearly weighted moving average of the time
%     series object TS.  WindowLength is an integer that specify the length
%     of the averaging window.  Valid WindowLength are 3, 4, 5, 6, 7, 9, 11,
%     and 21 in LINMA.
% 
%     

function filter
%MATLAB Tour Partial Function Help:  fin_con
%
% FILTER One-dimensional digital filter.
%    Y = FILTER(B,A,X) filters the data in vector X with the
%    filter described by vectors A and B to create the filtered
%    data Y.  The filter is a "Direct Form II Transposed"
%    implementation of the standard difference equation:
% 
%    a(1)*y(n) = b(1)*x(n) + b(2)*x(n-1) + ... + b(nb+1)*x(n-nb)
%                          - a(2)*y(n-1) - ... - a(na+1)*y(n-na)
% 
%    If a(1) is not equal to 1, FILTER normalizes the filter
%    coefficients by a(1). 
% 
%    When X is a matrix, FILTER operates on the columns of X.  When X
%    is an N-D array, FILTER operates along the first non-singleton
%    dimension.
% 
%    [Y,Zf] = FILTER(B,A,X,Zi) gives access to initial and final
%    conditions, Zi and Zf, of the delays.  Zi is a vector of length
%    MAX(LENGTH(A),LENGTH(B))-1 or an array of such vectors, one for
%    each column of X.
% 
%    FILTER(B,A,X,[],DIM) or FILTER(B,A,X,Zi,DIM) operates along the
%    dimension DIM.
% 
%    

function flatma
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/flatma.m ---
%
% @DEMTSERIES/FLATMA calculates the moving average of a time series object
%     using flat weights on a sliding window of 7 data wide.  Thus, the
%     weights are [1/7 1/7 1/7 1/7 1/7 1/7 1/7].
% 
%     TSFlat = flatma(TS, NPeriod) returns a time series object that contains
%     the flat weightes moving average of the input time series TS.  NPeriod
%     is always 7, regardles what the input is set to.
% 

function log
%MATLAB Tour Partial Function Help:  fin_con
%
% LOG    Natural logarithm.
%    LOG(X) is the natural logarithm of the elements of X.
%    Complex results are produced if X is not positive.
% 
%    

function log10
%MATLAB Tour Partial Function Help:  fin_con
%
% LOG10  Common (base 10) logarithm.
%    LOG10(X) is the base 10 logarithm of the elements of X.   
%    Complex results are produced if X is not positive.
% 
%    

function log2
%MATLAB Tour Partial Function Help:  fin_con
%
% LOG2   Base 2 logarithm and dissect floating point number.
%    Y = LOG2(X) is the base 2 logarithm of the elements of X.
% 
%    [F,E] = LOG2(X) for each element of the real array X, returns an
%    array F of real numbers, usually in the range 0.5 <= abs(F) < 1,
%    and an array E of integers, so that X = F .* 2.^E.  Any zeros in X
%    produce F = 0 and E = 0.  This corresponds to the ANSI C function
%    frexp() and the IEEE floating point standard function logb().
% 
%    

function ma
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/ma.m ---
%
% @DEMTSERIES/MA creates a matrix for the calculation of a weighted moving 
%     average.
% 
%     TSmx = ma( TS, WindowLength ) returns a matrix of M-by-WindowsLength
%     where M is the length of the time series TS.  TSmx is a matrix that
%     represents the values of the time series led and lagged by the same
%     number of periods.  For example, if the WindowsLength is set as 5 and
%     you have a time series that is 365-day long, you will get a matrix of 
%     the size 365-by-5 where the first and second columns are the values
%     in the original time series LED by 2 and 1 day, repectively, and the
%     fourth and fifth columns are the values LAGGED by 1 and 2 day, 
%     respectively.  The third column is a replica of the original time
%     series.  This function is useful for calculating the moving average
%     of a time series object.
% 
%     This function is called by LINMA, QUADMA and HENDER
% 

function max
%MATLAB Tour Partial Function Help:  fin_con
%
% MAX    Largest component.
%    For vectors, MAX(X) is the largest element in X. For matrices,
%    MAX(X) is a row vector containing the maximum element from each
%    column. For N-D arrays, MAX(X) operates along the first
%    non-singleton dimension.
% 
%    [Y,I] = MAX(X) returns the indices of the maximum values in vector I.
%    If the values along the first non-singleton dimension contain more
%    than one maximal element, the index of the first one is returned.
% 
%    MAX(X,Y) returns an array the same size as X and Y with the
%    largest elements taken from X or Y.  Either one can be a scalar.
% 
%    [Y,I] = MAX(X,[],DIM) operates along the dimension DIM. 
% 
%    When complex, the magnitude MAX(ABS(X)) is used.  NaN's are
%    ignored when computing the maximum.
% 
%    Example: If X = [2 8 4   then max(X,[],1) is [7 8 9],
%                     7 3 9]
% 
%        max(X,[],2) is [8    and max(X,5) is [5 8 5
%                        9],                   7 5 9].
% 
%    

function mav
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/mav.m ---
%
% @DEMTSERIES/MAV calculates the moving average of a time series object.
% 
%     TSmav = mav( TS, WindowLength ) returns a time series object that
%     contains the moving average of the time series object TS using
%     averaging window of length WindowLength.
% 

function meants
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/meants.m ---
%
% @DEMTSERIES/MEANTS calculates the mean of a time series between two dates.
% 
%     X = meants( TS, StartDate, StopDate ) returns the arithmetic average of
%     the values of a time series object between StartDate and StopDate.
%     StartDate and StopDate must be in date string UK format, DD/MM/YYYY.
%     If those dates are not supplied the arithmetic average of the whole
%     time series is returned.
% 

function min
%MATLAB Tour Partial Function Help:  fin_con
%
% MIN    Smallest component.
%    For vectors, MIN(X) is the smallest element in X. For matrices,
%    MIN(X) is a row vector containing the minimum element from each
%    column. For N-D arrays, MIN(X) operates along the first
%    non-singleton dimension.
% 
%    [Y,I] = MIN(X) returns the indices of the minimum values in vector I.
%    If the values along the first non-singleton dimension contain more
%    than one minimal element, the index of the first one is returned.
% 
%    MIN(X,Y) returns an array the same size as X and Y with the
%    smallest elements taken from X or Y. Either one can be a scalar.
% 
%    [Y,I] = MIN(X,[],DIM) operates along the dimension DIM.
% 
%    When complex, the magnitude MIN(ABS(X)) is used. NaN's are ignored
%    when computing the minimum.
% 
%    Example: If X = [2 8 4   then min(X,[],1) is [2 3 4],
%                     7 3 9]
% 
%        min(X,[],2) is [2    and min(X,5) is [2 5 4
%                        3],                   5 3 5].
% 
%    

function mt
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/mt.m ---
%
% @DEMTSERIES/MT calculates a Moving Trend which fits an 11 period linma to
%     the data and then a 21 period LINMA to the result of that.
% 
%     TSmt = mt( TSQ ); returns a time series object TSmt which contains the
%     moving trend of the input quarterly time series TSQ.
% 

function percnt
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/percnt.m ---
%
% @DEMTSERIES/PERCNT calculates the period percentage change.  
% 
%     TSp = percnt( TS, PeriodLength ) calculates the percentage change over a 
%     specified length of period, PeriodLength.  It returns the results in a
%     time series object TSp which contains the dates of the end of each
%     periods and the average values of the period.  If PeriodLength is not
%     supplied, the average of the whole time series is returned.
% 

function qoq3m
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/qoq3m.m ---
%
% @DEMTSERIES/QOQ3M calculates 3 month on 3 month change, for a monthly time
%     series.
% 
%     TS3m = qoq3m( TS ); returns a time series object TS3m tha contains the
%     3-month-on-3-month change of the time series object TS.  TS must be at
%     least 6 months long.
% 

function quadma
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/quadma.m ---
%
% @DEMTSERIES/QUADMA creates a quadratic weighted moving average of a time
%     series object.
% 
%     TSQMA = linma( TS, WindowLength ) returns a time series object TSLMA
%     which contains the quadraticly weighted moving average of the time
%     series object TS.  WindowLength is an integer that specify the length
%     of the averaging window.  Valid WindowLength are 5, 7, 9, 11, 13
%     and 21 in QUADMA.
% 
%     

function sd
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/sd.m ---
%
% @DEMTSERIES/SD calculates the standard deviation of a time series object.
% 
%     STDEV = sd(TS) returns a value that represents the standard deviation
%     of the time series object, TS.
% 

function seas
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/seas.m ---
%
% @DEMTSERIES/SEAS Seasonal Adjustment of a monthly or quarterly time
%     series only.
% 
%     Tseas = seas( TS );
% 

function seas2
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/seas2.m ---
%
% @DEMTSERIES/SEAS2 Seasonal Adjustment using the Additive method on a
%     monthly or quarterly time series only.
% 
%     Tseas = seas2( TS );
% 

function trend
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/trend.m ---
%
% @DEMTSERIES/TREND calculates the logarithmic trend for a time series
%     object using the backslash (\) operator.  It is essentially
%     doing a linear regression to fit the data to the linear equation:
% 
%         y(x) = a * x ^ b  =>  log( y(x) ) = log( a ) + b * log( x )
%                           =>     Y(X)     =     A    + b *    X
% 
%     It calculates what b and A are, then generates the data points
%     that lie on the line at every X, Y(X).  These values of Y(X), which 
%     are logarithmic in scale, are the ones contained in the resulting 
%     time series object.
% 

function yoy
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/yoy.m ---
%
% @DEMTSERIES/YOY implements year on year percentage change.
% 
%     TSyy = yoy( TS )
% 
%     Implemented as: (ts1.v(date)./ts1.v(date+year)).*100-100 for time
%     series.
%  

function zohts
%MATLAB Tour Partial Function Help:  fin_con
%
% --- help for demtseries/zohts.m ---
%
% @DEMTSERIES/ZOHTS holds a particular value for a certain amount of time.
%     It replicates a value or values for multiple days.  In other words,
%     it converts low frequency time series to a higer frequency time
%     series.   [Zero-order hold for Time Series objects.]
% 
%     HiFTSVal = zohts(TS, HiFTSDate) returns a vector of values which are 
%     the values from the input time series object TS replicated until the
%     next value is encountered.
% 
%     This function is used by DEMTSERIES object methods TOD, TOW, TOM,
%     TOQ, TOHY, TOY, and TOX.
% 

function minus
%MATLAB Tour Partial Function Help:  fin_con
%
% -   Minus.
%    X - Y subtracts matrix Y from X.  X and Y must have the same
%    dimensions unless one is a scalar.  A scalar can be subtracted
%    from anything.  
% 
%    C = MINUS(A,B) is called for the syntax 'A - B' when A or B is an
%    object.
%
% Overloaded methods
%    help demtseries/minus.m
%    help printjob/minus.m

function mpower
%MATLAB Tour Partial Function Help:  fin_con
%
% ^   Matrix power.
%    Z = X^y is X to the y power if y is a scalar and X is square. If y is an
%    integer greater than one, the power is computed by repeated
%    multiplication. For other values of y the calculation
%    involves eigenvalues and eigenvectors.
%    Z = x^Y is x to the Y power, if Y is a square matrix and x is a scalar,
%    computed using eigenvalues and eigenvectors.
%    Z = X^Y, where both X and Y are matrices, is an error.
% 
%    C = MPOWER(A,B) is called for the syntax 'A ^ B' when A or B is an
%    object.
% 
%    

function mrdivide
%MATLAB Tour Partial Function Help:  fin_con
%
% /   Slash or right matrix divide.
%    A/B is the matrix division of B into A, which is roughly the
%    same as A*INV(B) , except it is computed in a different way.
%    More precisely, A/B = (B'\A')'. See MLDIVIDE for details.
% 
%    C = MRDIVIDE(A,B) is called for the syntax 'A / B' when A or B is an
%    object.
% 
%    

function mtimes
%MATLAB Tour Partial Function Help:  fin_con
%
% *   Matrix multiply.
%    X*Y is the matrix product of X and Y.  Any scalar (a 1-by-1 matrix)
%    may multiply anything.  Otherwise, the number of columns of X must
%    equal the number of rows of Y.
% 
%    C = MTIMES(A,B) is called for the syntax 'A * B' when A or B is an
%    object.
% 
%    

function plus
%MATLAB Tour Partial Function Help:  fin_con
%
% +   Plus.
%    X + Y adds matrices X and Y.  X and Y must have the same
%    dimensions unless one is a scalar (a 1-by-1 matrix).
%    A scalar can be added to anything.  
% 
%    C = PLUS(A,B) is called for the syntax 'A + B' when A or B is an
%    object.
%
% Overloaded methods
%    help demtseries/plus.m

function power
%MATLAB Tour Partial Function Help:  fin_con
%
% .^  Array power.
%    Z = X.^Y denotes element-by-element powers.  X and Y
%    must have the same dimensions unless one is a scalar. 
%    A scalar can operate into anything.
% 
%    C = POWER(A,B) is called for the syntax 'A .^ B' when A or B is an
%    object.
% 
%    

function rdivide
%MATLAB Tour Partial Function Help:  fin_con
%
% ./  Right array divide.
%    A./B denotes element-by-element division.  A and B
%    must have the same dimensions unless one is a scalar.
%    A scalar can be divided with anything.
% 
%    C = RDIVIDE(A,B) is called for the syntax 'A ./ B' when A or B is an
%    object.
% 
%    

function times
%MATLAB Tour Partial Function Help:  fin_con
%
% .*  Array multiply.
%    X.*Y denotes element-by-element multiplication.  X and Y
%    must have the same dimensions unless one is a scalar.
%    A scalar can be multiplied into anything.
% 
%    C = TIMES(A,B) is called for the syntax 'A .* B' when A or B is an
%    object.
% 
%    

function uminus
%MATLAB Tour Partial Function Help:  fin_con
%
% -  Unary minus.
%    -A negates the elements of A.
% 
%    B = UMINUS(A) is called for the syntax '-A' when A is an object.
%
% Overloaded methods
%    help demtseries/uminus.m

function uplus
%MATLAB Tour Partial Function Help:  fin_con
%
% +  Unary plus.
%    +A for numeric arrays is A. 
% 
%    B = UPLUS(A) is called for the syntax '+A' when A is an object.
%
% Overloaded methods
%    help demtseries/uplus.m

function ftgex1
%MATLAB Tour Partial Function Help:  fin_con
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Filename FTGEX1.M
%  Financial Toolbox Graphics Example 1:
%  Plotting an Efficient Frontier
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function ftgex2
%MATLAB Tour Partial Function Help:  fin_con
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Filename FTGEX2.M
%  Financial Toolbox Graphics Example 2:
%  Plotting Sensitivities of an Option
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function ftgex3
%MATLAB Tour Partial Function Help:  fin_con
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Filename FTGEX3.M
%  Financial Toolbox Graphics Example 3:
%  Plotting Sensitivities of a Portfolio of Options
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function ftspex1
%MATLAB Tour Partial Function Help:  fin_con
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Filename FTSPEX1.M
%  Financial Toolbox Solving Problems Example 1:
%  Sensitivity of Bond Prices to Changes in Interest Rates
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function ftspex2
%MATLAB Tour Partial Function Help:  fin_con
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Filename FTSPEX2.M
%  Financial Toolbox Solving Problems Example 2:
%  Constructing a Bond Portfolio to Hedge Against Duration and Convexity
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function ftspex3
%MATLAB Tour Partial Function Help:  fin_con
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Filename FTSPEX3.M
%  Financial Toolbox Solving Problems Example 3:
%  Visualizing the Sensitivity of a Bond Portfolio's Prices
%   to Parallel Shifts in the Yield Curve
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function ftspex4
%MATLAB Tour Partial Function Help:  fin_con
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Filename FTSPEX4.M
%  Financial Toolbox Solving Problems Example 4:
%  Constructing Greek-Neutral Portfolios of European Stock Options
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Part I:  Create a delta-neutral portfolio of two options with a $1000 total value.
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

