Functions

For an in-depth overview of any of the functions, please view the PSec GEARS Help file that accompanies the installation.

Data
  • PD.ReadFile:
    • Retrieve data from a file based on the specified File Configuration.
Data Analytics
  • PQ.AreCointegrated:
    • Performs a test for cointegration between two time (or more) series. Please see the documentation for more information on this function.
  • PQ.AutoCorrel:
    • Gets the auto-correlation of the elements of an array.
  • PQ.Correl:
    • Calculates the Pearson correlation coefficient. Returns a single value for two arrays and a square matrix for more.
  • PQ.CorrelDebiased:
    • Calculates a symmetrical Correlation matrix by employing a cleaning scheme aimed at reducing the sampling error arising from the non-representativeness of the sample taken.
  • PQ.Covar:
    • Calculates a symmetrical Covariance matrix. Returns a single value for two arrays and a square symmetrical matrix if the first paramater is a matrix.
  • PQ.CovarDebiased:
    • Calculates a symmetrical Covariance matrix by employing a cleaning scheme aimed at reducing the sampling error arising from the non-representativeness of the sample taken.
  • PQ.CovarianceLedoitWolf:
    • Generates Ledoit Wolf shrinkage covariance matrix.
  • PQ.Entropy:
    • Calculates an estimation of differential entropy on empirical data using k-d partitioning described by Stowell and Plumbley (2009).
  • PQ.HierarchicalCluster:
    • Performs hierarchical cluster analysis on a given dataset.
  • PQ.IsStationary:
    • Performs a unit root test for stationarity on a series of residual values. It tests the null hypothesis of a unit root present in the time-series, so in simple terms, it checks whether a time series is mean reverting or not.
  • PQ.JarqueBeraTest:
    • The Jarque-Bera test of normality.
  • PQ.Kurtosis:
    • Calculates the kurtosis of a distribution.
  • PQ.LoessFilter:
    • Computes the Loess smoothed series.
  • PQ.LowessFilter:
    • Computes the Lowess smoothed series (LOcally WEighted Scatterplot Smoothing).
  • PQ.MeansBayesStein:
    • Generates row vector of Bayes Stein Means.
  • PQ.MeansJamesStein:
    • Generates row vector of James Stein Means.
  • PQ.MultiVarRegression:
    • Multivariate regression analysis.
  • PQ.MultiVarRegressionDebiased:
    • Multivariate regression analysis using a debiased Covariance matrix.
  • PQ.PCA:
    • Principal component analysis.
  • PQ.RegressionVPE:
    • Calculates variance proportion explained of a regression.
  • PQ.Skewness:
    • Calculates the skewness of a distribution.
  • PQ.SmoothingIndex:
    • Provides a normalised measure of liquidity risk.
  • PQ.SavitskyGolaySmoother:
    • Computes Savitsky-Golay smoothed time series.
Derivatives
  • PE.BS:
    • Values an European option with a continuous dividend yield using the standard Black Scholes formula.
  • PE.BS_ImpVol:
    • Find the implied volatility for a given premium of an European option with a continuous dividend yield, assuming the standard Black Scholes formula.
  • PE.BSfutures:
    • Values an option on a future using the Black Scholes formula. Risk Free Rate and Dividend Yield set to zero. Used to value SAFEX and Yield-X options on futures.
  • PE.BSfutures_ImpVol:
    • Find the implied volatility for a given premium of an option on a future.
  • PE.BSmultiDiv:
    • Values an European option with multiple discrete dividends using either the Escrowed Dividend model or the Bos-Vandermark model.
  • PE.DoubleBarrier_IK:
    • Prices a double barrier option using the Ikeda-Kuntomo approach.
  • PE.DoubleStepBarrier:
    • Calculates the price of a Double Step Barrier option by means of a Monte-Carlo simulation.
  • PE.DoubleStepBarrier_LV:
    • Calculates the price of a Double Step Barrier option by means of a Monte-Carlo simulation and using a local volatility approach.
  • PE.FirstThenBarrier:
    • Calculates the price of First-Then-Barrier Option using the design of Haug (1998).
  • PE.ForwardPrice:
    • Calculates the forward price of a discrete dividend paying stock for a given constant risk free rate to expiry.
  • PE.ForwardPrice_Curve:
    • Calculates the forward price of a discrete dividend paying stock for a given risk free yield curve.
  • PE.LookbackAsian:
    • Asian Lookback Put Spread.
  • PE.Parisian:
    • Pricing of Parisian options using Monte Carlo simulation.
  • PE.Reservoir:
    • Pricing of Reservoir options using Monte Carlo simulation.
  • PE.SingleBarrier:
    • Pricing standard single European barrier options.
  • PE.SingleStepBarrier:
    • Calculates the price of a Single Step Barrier option by means of a Monte-Carlo simulation.
  • PE.SingleStepBarrier_LV:
    • Calculates the price of a Single Step Barrier option by means of a Monte-Carlo simulation and using a local volatility approach.
Financial Analysis
  • PFA.DDM:
    • Dividend Discount Model: Calculates the shareholder value per share given forecasted dividends.
  • PFA.FCF:
    • Calculates the Free Cash Flow to Equity of a company.
  • PFA.FCFF:
    • Calculates the annual Free Cash Flow to Firm.
  • PFA.TRD:
    • Calculation of Total Return Decomposition. Can input discrete dividends or dividend yield. Can input discrete earnings or PE Ratio.
  • PFA.WACC:
    • Calculates the Weighted Average Cost of Capital. WACC is the average rate of return a company is expected to pay its security holders to finance the company's assets.
Fixed Income
  • PF.AllinCurve:
    • Calculates the allin price of a listed bond by valuing the bond's cash flows using a specified yield curve.
  • PF.AltmanZScore:
    • Calculates the probability of default of a firm.
  • PF.AssetSwap:
    • Calculates Asset Swap Outputs.
  • PF.BondCPI:
    • Performs various calculations on inflation linked bonds.
  • PF.BondData:
    • Looks up a specified property from the bond data file for a specified bond.
  • PF.BondFRN:
    • Finds the value of a floating rate note, listed or unlisted.
  • PF.BondFuture:
    • Calculates a future yield on a given listed fixed coupon bond to achieve a future price if the coupons are reinvested at the specified risk free rate until expiry.
  • PF.BondOption:
    • Values a bond option using the standard Black Scholes formula.
  • PF.BondV:
    • Performs various calculations on vanilla bonds.
  • PF.BreakEvenInflation:
    • Calculates the amount of average inflation required for the total return of an inflation linked bond to equal the total return of a vanilla bond between two given dates.
  • PF.ConvertibleBond:
    • Calculates the value of a convertible bond using the approach of Chambers and Lu (2007).
  • PF.CouponFlow:
    • Decomposes a bond into its future coupons that will be received from the specified settlement date to the bond's maturity (according to the JSE's Bond Pricing Specification).
  • PF.CPI:
    • Looks up the Consumer Price Index for a specified date.
  • PF.CPI3MonthLag:
    • Looks up the Consumer Price Index with a 3 month lag from a specified date.
  • PF.FindYield_Allin:
    • Returns the required yield to achieve a given rounded all-in price for a vanilla bond.
  • PF.FindYield_TR:
    • Returns the required end yield to achieve a given total return on a vanilla bond.
  • PF.MertonModel:
    • Calculates the value of a firm's equity at time t.
  • PF.MixedRate_BondCodes:
    • Returns all the Mixed Rate Notes bond codes listed on the JSE.
  • PF.MixedRate_Legs:
    • Returns the number of legs for a Mixed Rate Note listed on the JSE.
  • PF.MixedRateNote:
    • Returns reference data for a Mixed Rate Notes listed on the JSE.
  • PF.MTM:
    • Returns the MTM valuations and other instrument related information for all the JSE listed debt instruments.
  • PF.MTM_BondCodes:
    • Returns all the bond codes for instruments the JSE publishes MTM valuations.
  • PF.MTM_Outputs:
    • Returns all the Output fields that are available for retrieval through the PF.MTM and PF.MTM_Range function.
  • PF.MTM_Range:
    • Returns the MTM valuations and other instrument related information for all the JSE listed debt instruments.
  • PF.OhlsonOScore:
    • Calculates Ohlson O-Score for financial distress.'
  • PF.PrefShare:
    • Provides Pref-Share data for a specified date and instrument.'
  • PF.PVdownCurve:
    • Calculates the present value of a given set of cash flows by discounting it using a specified yield curve.
  • PF.Rates:
    • Looks up a specified interest rate (e.g. 3 month Jibar, 6 month Jibar, etc.) for a given date.
  • PF.Swap:
    • Performs various SWAP calculations and measures.
  • PF.TotalReturn_ActualAndAvgInf:
    • Calculates the total return for an inflation linked bond using a combination of historical inflation figures going backwards and an average inflation figure going forwards to gross up the coupons.
  • PF.TotalReturn_ActualInf:
    • Calculates the total return for an inflation linked bond using actual inflation figures to gross up the coupons.
  • PF.TotalReturn_AvgInf:
    • Calculates the total return for an inflation linked bond using an average inflation figure to gross up the coupons.
  • PF.TotalReturn_V:
    • Calculates the total return for a vanilla bond between a specified start and end date.
  • PF.YieldCurve:
    • Calculates a zero curve (NACC) for a given set of deposits and listed vanilla bonds.
  • PF.YieldCurveConstituents:
    • Returns the set of inputs used by the JSE to construct zero-coupon yield curves.
  • PF.YieldCurveJSE:
    • Returns the zero-coupon yield curves as constructed and published by the JSE.
  • PF.YieldCurveLookup:
    • Returns an interest rate corresponding to a particular point in time on the JSE yield curve.
  • PF.ZeroCurve2Par:
    • Calculates a par curve (in NACC) for a given zero curve (in NACC) and returns a par yield vector associated with the given zero curve's term vector.
Portfolio Analytics
  • PQ.AlphaJensen:
    • Calculates alpha, the excess return adjusted for systematic risk.
  • PQ.AlphaNet:
    • Net alpha is the remaining alpha after deducting the amount of return required to justify not being fully diversified.
  • PQ.AppraisalRatio:
    • Appraisal ratio is the Jensen's alpha adjusted for specific risk. The numerator is divided by specific risk instead of total risk.
  • PQ.BernardoLedoitRatio:
    • Is a special case of the Omega ratio where the hurdle rate is zero.
  • PQ.Beta:
    • Returns the beta of a portfolio to a benchmark.
  • PQ.ContributionToRisk:
    • Calculates risk contributions per asset.
  • PQ.CorrelationToBasket:
    • Calculates correlation to basket per asset.
  • PQ.CSV:
    • Calculates uniform or weighted Cross-Sectional Volatility (CSV) as well as attribution of the same on a given set of cross asset returns and, optionally, corresponding weights.
  • PQ.CumulativeReturns:
    • Generates a per asset cumulative returns matrix from a price or returns matrix.
  • PQ.CVaR:
    • Returns the Conditional Value-at-Risk for a given set of returns and hurdle rate (i.e. n-th percentile).
  • PQ.DivDelta:
    • Calculates the diversification delta of a portfolio given its underlying constituents and weightings.
  • PQ.DownsideFrequency:
    • Calculates the downside frequency.
  • PQ.DownsideStats:
    • Calculates the specified downside statistic of a portfolio below a minimum acceptable return.
  • PQ.ENB:
    • Calculates the Effective Number of Bets (ENB) of a portfolio given its underlying constituents and weightings.
  • PQ.EPM:
    • Returns the Economic Performance Measure (EPM) for a given set of returns and risk free rate.
  • PQ.FamaBeta:
    • Beta used to calculate the loss of diversification.
  • PQ.HI:
    • Calculates the Herfindahl Index (HI) of a portfolio given the weights of its underlying constituents.
  • PQ.IPC:
    • Calculates the Intra-portfolio Correlation (IPC) of a portfolio given its underlying constituents and weightings.
  • PQ.IR:
    • Returns the annualised information ratio of a portfolio to a benchmark.
  • PQ.Kappa:
    • Generalised downside risk-adjusted performance measure.
  • PQ.KellyRatio:
    • Calculates Kelly ratio (leverage or bet size) for a strategy.
  • PQ.MarketTiming:
    • Estimates parameters of Treynor-Mazuy or Merton-Henriksson market timing model.
  • PQ.MaxDrawDown:
    • Calculate maximum drawdown for a price series.
  • PQ.MaxGain:
    • Calculate maximum gain for a price series.
  • PQ.MeanAbsoluteDeviation:
    • Mean absolute deviation of the return distribution.
  • PQ.MSquared:
    • Calculates the Modigliani-Modigliani or the Sortino Modigliani-Modigliani squared measure of the return distribution.
  • PQ.MSquaredExcess:
    • Calculates the risk-adjusted return in excess of the benchmark return.
  • PQ.MultivarReturns:
    • Generate correlated multivariate returns with specified moments.
  • PQ.Omega:
    • Returns the Omega ratio for a given set of returns.
  • PQ.OmegaSharpeRatio:
    • Converts Omega ratio into a ranking statistic in the Sharpe form.
  • PQ.PDI:
    • Calculates the Portfolio Diversification Index (PDI) for a portfolio of asset returns.
  • PQ.PortfolioReturns:
    • Portfolio Return Calculator. Calculates portfolio returns over a period given user-supplied weights, transaction costs, and dividend yield.
  • PQ.PortfolioRisk:
    • Calculates the risk of a portfolio using asset returns and weight.
  • PQ.PortOpt:
    • NOTE: This function is in BETA testing! Use this function to construct an Efficient Frontier. It minimizes volatility under possible constraints by targeting a specified return.
  • PQ.ProspectRatio:
    • Performance measure used to penalise loss.
  • PQ.RandomPortfolio:
    • Generates random portfolios.
  • PQ.ReturnAnnualised:
    • Calculates average annualised return.
  • PQ.ReturnAnnualisedExcess:
    • Calculates an average annualised excess return.
  • PQ.ReturnsGeltner:
    • Removes estimation or liquidity bias in return series that exhibit autocorrelation or illiquidity effects.
  • PQ.ReturnsRelative:
    • Calculates the ratio of the cumulative performance for two assets through time.
  • PQ.RiskDecomposition:
    • Calculates three components of risk: specific, systematic, and total.
  • PQ.SharpeRatio:
    • Returns the Sharpe ratio for a given set of returns and risk-free rate.
  • PQ.SharpeRatioAdjusted:
    • Adjusted Sharpe ratio adjusts for skewness and kurtosis by incorporating a penalty factor for negative skewness and excess kurtosis.
  • PQ.SharpeRatioRealised:
    • Calculates the realised annualised Sharpe ratio.
  • PQ.SkewnessKurtosisRatio:
    • Skewness-Kurtosis ratio is the division of Skewness by Kurtosis.
  • PQ.Sortino:
    • Calculates the Sortino ratio.
  • PQ.StandardDeviationAnnualised:
    • Calculate a annualised Standard Deviation.
  • PQ.TE:
    • Returns the tracking error of a portfolio to a benchmark.
  • PQ.TreynorRatio:
    • Calculates the Treynor or Modified Treynor ratio.
  • PQ.UpDownRatios:
    • Measures performance in up and down markets.
  • PQ.UpsideFrequency:
    • Calculates the upside frequency of returns.
  • PQ.UpsidePotentialRatio:
    • Returns the upside potential ratio of a portfolio given a minimum acceptable return.
  • PQ.UpsideStats:
    • Returns the specified upside statistic of a portfolio above a minimum acceptable return.
  • PQ.VaR:
    • Returns the Value-at-Risk for a given set of returns at the n-th percentile.
  • PQ.VariabilitySkewness:
    • The ratio of the upside risk compared to the downside risk.
  • PQ.VolatilitySkewness:
    • The ratio of the upside variance compared to the downside variance.
  • PQ.WE:
    • Calculates the Weight Entropy (WE) of a portfolio given the weights of its underlying constituents.
Tools
  • PT.AddMonths:
    • Returns a Date that adds the specified number of months to the specified Date parameter.
  • PT.AddWorkDays:
    • Add x amount of work days to a specified date.
  • PT.BusinessDay:
    • Calculates a date using a variety of business day conventions.
  • PT.Concat:
    • Concatenates the elements of a vector, separated by delimiter, into a single string value.
  • PT.Contains:
    • Evaluates whether a range or matrix contains a specified value.
  • PT.ConvertRates:
    • Converts a given interest rate from one compounding convention to another.
  • PT.DayOfWeek:
    • Returns the day of the week for the specified date in either a full (e.g. Monday) or abbreviated (e.g. Mon) format.
  • PT.Distinct:
    • Returns a distinct list of values in a range. Empty cells and cells containing errors will be ignored.
  • PT.Interpolate:
    • Performs linear or cubic spline interpolation.
  • PT.IsPublicHoliday:
    • Checks if the specified date is a South African public holiday.
  • PT.IsWeekend:
    • Checks if the specified date falls on a weekend or not.
  • PT.IsWorkDay:
    • Checks if the specified date is a workday. Takes weekends and public holidays into account.
  • PT.ModifiedFollowing:
    • Returns a date after applying the modified following date convention on the specified date.
  • PT.Now:
    • Gets the current server date and time.
  • PT.NrWorkDays:
    • Returns the number of whole working days between (and including) the StartDate and EndDate.
  • PT.PHDesc:
    • Returns a description of the holiday if the specified date is a South African public holiday.
  • PT.Sort:
    • Sorts an array in either ascending or descending order. Follows the sorting conventions of the Excel tool bar Sort function.
  • PT.Split:
    • Splits a string on a specified delimiter and returns either the element with the specified index or a column vector of all the elements of the string.
  • PT.Today:
    • Gets the current server date.
  • PT.WorkDays:
    • Returns the business days between two dates, excluding weekends and South African public holidays.