0% found this document useful (0 votes)
92 views23 pages

Reading Material - Module-4 - Portfolio Optimization and Analytics

Uploaded by

sitaramr54
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views23 pages

Reading Material - Module-4 - Portfolio Optimization and Analytics

Uploaded by

sitaramr54
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Financial Analytics

FINANCIAL ANALYTICS
Curated by Kiran Kumar K V

Author Contact: 99644-02318 | [email protected] | linkedin.com/in/kirankvk


Financial Analytics

Content Structure

1. Introduction to Financial Analytics


1.1. Different Applications of Financial Analytics
1.2. Overview of sources of Financial Data
1.3. Overview of Bonds, Stocks, Securities Data Cleansing
2. Statistical aspects of Financial Time Series Data
2.1. Plots of Financial Data (Visualizations)
2.2. Sample Mean, Standard Deviation, and Variance
2.3. Sample Skewness and Kurtosis
2.4. Sample Covariance and Correlation
2.5. Financial Returns
2.6. Capital Asset Pricing Model
2.7. Understanding distributions of Financial Data
3. Introduction to Time Series Analysis
3.1. Examining Time Series
3.2. Stationary Time Series
3.3. Auto-Regressive Moving Average Processes
3.4. Power Transformations
3.5. Auto-Regressive Integrated Moving Average Processes
3.6. Generalized Auto-Regressive Conditional
Heteroskedasticity
4. Portfolio Optimization and Analytics
4.1. Optimal Portfolio of Two Risky Assets
4.2. Data Mining with Portfolio Optimization
4.3. Constraints, Penalization, and the Lasso
4.4. Extending to Higher Dimensions
4.5. Constructing an efficient portfolio
4.6. Portfolio performance evaluation
5. Introduction to special topics
5.1. Credit Default using classification algorithms
5.2. Introduction to Monte Carlo simulation
5.3. Sentiment Analysis in Finance
5.4. Bootstrapping and cross validation
5.5. Prediction using fundamentals
5.6. Simulating Trading Strategies

Author Contact: 99644-02318 | [email protected] | linkedin.com/in/kirankvk


Financial Analytics

Module-3: Portfolio Optimization and Analytics

1. Optimal Portfolio with Two Risky Assets


A security refers to a tradable financial asset that holds monetary value and represents
ownership, debt, or rights to ownership in a company or entity. Securities can take various
forms, including stocks (equities), bonds, options, futures, and mutual funds. A portfolio, on
the other hand, refers to a collection or combination of assets. A security represents an
individual financial asset, while a portfolio is a collection of assets that may include various
securities, along with other investment vehicles. Securities are building blocks of a portfolio,
which is constructed to achieve specific investment objectives and manage risk effectively.
One of the primary purposes of creating portfolios is to diversify risk. By spreading
investments across different asset classes, industries, regions, and securities, investors can
reduce the impact of adverse events affecting any single investment. Diversification helps to
smooth out investment returns over time and mitigate the potential for significant losses.
Computing Returns on a Security
1. Holding Period Return (HPR):
The holding period return measures the total return earned on an investment over a specific
holding period, including both capital appreciation (or depreciation) and any income
generated from dividends or interest.
The formula for calculating the holding period return is:

If you bought a stock for Rs. 50, received Rs. 2 in dividends, and the stock price increased to
Rs. 60 during the holding period, the holding period return would be:

2. Average Return of a Security:


The average return of an individual security over a specific period is calculated by taking the
mean of the security's returns over that period. If you have the historical returns of the security
for each period, you can use the following formula to compute the average return:

Author Contact: 99644-02318 | [email protected] | linkedin.com/in/kirankvk


Financial Analytics

Suppose you have the following annual returns for a stock over a 5-year period: 10%, 5%, -
2%, 8%, and 12%. To calculate the average return, you would sum up these returns and divide
by the number of periods:

Keep in mind that these calculations provide simple measures of return and may not account
for factors such as taxes, transaction costs, or inflation. Additionally, when using price-based
returns, it's essential to adjust for stock splits, dividends, and other corporate actions that
affect the security's price.
Computing Risk Measures on a Security
To compute the variance and standard deviation of returns of a security, you'll need historical
data on the security's returns over a specific period.
1. Variance of Returns:
The variance of returns measures the dispersion or variability of the security's returns around
its mean return. It provides insights into the level of risk or volatility associated with the
security. The formula for calculating the variance of returns is:

2. Standard Deviation of Returns:


The standard deviation of returns is the square root of the variance and provides a measure
of the dispersion of returns in the same units as the returns themselves. It quantifies the level
of risk associated with the security's returns. The formula for calculating the standard
deviation of returns is:

Author Contact: 99644-02318 | [email protected] | linkedin.com/in/kirankvk


Financial Analytics

Suppose you have the following annual returns for a security over a 5-year period: 10%, 5%,
-2%, 8%, and 12%. To calculate the variance and standard deviation of returns:

So, the variance of returns for the security is approximately 29.8% and the standard deviation
of returns is approximately 5.46%.
3. Beta of Returns:
To compute the beta of an individual security, you need historical data on the returns of the
security as well as the returns of a market index over the same time period. Beta measures
the sensitivity of a security's returns to the returns of the overall market.
Finally, calculate the beta of the security by dividing the covariance between the security and
the market index by the variance of the market returns. (Covariance of returns computation
is shown in the next section)

A beta greater than 1 indicates that the security tends to be more volatile than the market,
while a beta less than 1 indicates that the security tends to be less volatile than the market.
Given that the covariance and variance of market returns as below, let's compute the beta:
Covariance between Security and Market: 23.3%
Variance of Market Returns: 18.3%

Author Contact: 99644-02318 | [email protected] | linkedin.com/in/kirankvk


Financial Analytics

Computing Bivariate Risk Measures on two Securities


1. Covariance of Returns
Covariance measures the degree to which the returns of two securities move together. A
positive covariance indicates that the returns tend to move in the same direction, while a
negative covariance indicates that the returns move in opposite directions. The formula for
calculating the covariance of returns between two securities 𝑋 and 𝑌 is:

2. Correlation of Returns:
Correlation measures the strength and direction of the linear relationship between the returns
of two securities. It is a standardized measure that ranges from -1 to 1, where -1 indicates a
perfect negative correlation, 0 indicates no correlation, and 1 indicates a perfect positive
correlation. The formula for calculating the correlation of returns between two securities 𝑋
and 𝑌 is:

Suppose you have the following annual returns for two securities, Security X and Security Y,
over a 5-year period:
Security X: 10%, 5%, -2%, 8%, and 12%
Security Y: 8%, 4%, -1%, 7%, and 10%
To calculate the covariance and correlation of returns between Security X and Security Y:

Author Contact: 99644-02318 | [email protected] | linkedin.com/in/kirankvk


Financial Analytics

Compute Mean Returns

Compute Variance of Returns

Compute Standard Deviation of Returns:

Compute Covariance of Returns

Compute Correlation between Returns

Computing Portfolio Risk & Return Measures


To compute the portfolio return, portfolio standard deviation, and portfolio beta, you need
to know the returns, standard deviations, and betas of the individual securities in the portfolio,
as well as the portfolio weights.

Author Contact: 99644-02318 | [email protected] | linkedin.com/in/kirankvk


Financial Analytics

1. Portfolio Return
The portfolio return is the weighted average of the returns of the individual securities in the
portfolio. The formula to compute the portfolio return is:

2. Portfolio Standard Deviation


The portfolio standard deviation is a measure of the total risk or volatility of the portfolio,
considering both the individual securities' risk and their correlations. The formula to compute
the portfolio standard deviation is:

3. Portfolio Beta
The portfolio beta measures the sensitivity of the portfolio's returns to the returns of the
market index. It is a weighted average of the betas of the individual securities in the portfolio.
The formula to compute the portfolio beta is:

Let's compute the portfolio return, standard deviation, and beta for the below example.

Author Contact: 99644-02318 | [email protected] | linkedin.com/in/kirankvk


Financial Analytics

Computing Expected Return of a Portfolio using CAPM:


The Capital Asset Pricing Model (CAPM) calculates the expected return of an asset or portfolio
based on its beta and the expected return of the market. The formula for expected return
according to CAPM is:

Author Contact: 99644-02318 | [email protected] | linkedin.com/in/kirankvk


Financial Analytics

Portfolio Performance Evaluation Measures:


Portfolio performance evaluation measures provide insights into the risk-adjusted returns of
a portfolio compared to a benchmark or risk-free rate. Three common measures are the
Sharpe ratio, Treynor ratio, and Jensen's alpha.
1. Sharpe Ratio:
The Sharpe ratio measures the excess return per unit of risk, where risk is measured by the
portfolio's standard deviation. It's calculated as:

2. Treynor Ratio:
The Treynor ratio measures the excess return per unit of systematic risk, where systematic risk
is measured by the portfolio's beta. It's calculated as:

Jensen's alpha measures the risk-adjusted return of the portfolio after adjusting for systematic
risk. It's calculated as the difference between the actual portfolio return and the expected
return predicted by the Capital Asset Pricing Model (CAPM):

Author Contact: 99644-02318 | [email protected] | linkedin.com/in/kirankvk


Financial Analytics

Building an Optimum Portfolio with Two Risky Assets


To find the optimal portfolio, one typically constructs the efficient frontier by varying the
weights assigned to assets A and B and calculating the corresponding expected return and
standard deviation for each combination of weights. The optimal portfolio lies on the efficient
frontier and is determined based on the investor's risk tolerance and return objectives. This
can be done using mathematical optimization techniques, such as quadratic programming,
to find the weights that maximize the portfolio's expected return given a certain level of risk
or minimize the portfolio's risk given a certain level of expected return.
Assuming we have two risky assets A and B, we can build an EFFICIENT FRONTIER creating a
combination of weights of A and B. Below code is used to generate an efficient frontier both
in tabular as well as graphical manner:

Author Contact: 99644-02318 | [email protected] | linkedin.com/in/kirankvk


Financial Analytics

Author Contact: 99644-02318 | [email protected] | linkedin.com/in/kirankvk


Financial Analytics

Author Contact: 99644-02318 | [email protected] | linkedin.com/in/kirankvk


Financial Analytics

In an efficient frontier, inefficient portfolios refer to those that offer suboptimal risk-return
trade-offs compared to portfolios that lie on the frontier itself. These portfolios provide
inferior risk-return characteristics compared to portfolios on the efficient frontier. These
portfolios either offer lower expected returns for a given level of risk or higher risk for a given
level of expected return.

Author Contact: 99644-02318 | [email protected] | linkedin.com/in/kirankvk


Financial Analytics

Inefficient Portfolios

The minimum variance portfolio represents the portfolio with the lowest level of risk or
volatility achievable within a given investment universe. It is characterized by the smallest
possible standard deviation or variance of returns among all portfolios on the efficient
frontier.

Minimum Variance Portfolio

The efficient frontier represents the set of optimal portfolios that offer the highest expected
return for a given level of risk or the lowest risk for a given level of expected return. EF
illustrates the range of possible portfolios that maximize returns for a given level of risk, or
minimize risk for a given level of return.
Characteristics
 Convex Shape - The efficient frontier typically exhibits a convex shape, indicating that as
an investor seeks higher expected returns, they must accept increasing levels of risk.
 Optimal Portfolios - Portfolios lying on the efficient frontier are considered optimal
because they offer the best risk-return trade-offs available within the investment universe.
 Diversification - The efficient frontier underscores the importance of diversification in
portfolio construction. By combining assets with different risk-return profiles, investors
can achieve portfolios that lie on or close to the efficient frontier, thereby maximizing
returns while minimizing risk.

Author Contact: 99644-02318 | [email protected] | linkedin.com/in/kirankvk


Financial Analytics

Efficient Frontier

2. Data Mining with Portfolio Optimization


When using historical asset prices data for portfolio construction, several key processes
should be followed to extract meaningful insights.
 Data Collection - Gather historical asset prices data from reliable sources such as financial
databases, APIs, or directly from financial markets.
 Data Cleaning and Preprocessing - Clean the data by handling missing values, outliers,
and errors to ensure data quality. Convert raw data into a structured format suitable for
analysis, including adjusting for stock splits and dividends.
 Feature Engineering - Extract relevant features from the historical prices data, such as
moving averages, relative strength index (RSI), or other technical indicators. Create
additional features such as volatility measures, trading signals, or lagged variables to
capture important market dynamics.
 Exploratory Data Analysis (EDA) - Conduct EDA to understand the distribution of asset
prices, identify trends, patterns, and correlations. Visualize the data using charts,
histograms, and other graphical methods to gain insights into historical price movements.

3. Constraints, Penalization, and the Lasso


When creating an optimal portfolio by maximizing the Sharpe ratio, you can impose various
constraints on the solver to ensure that the portfolio meets specific requirements or adheres
to certain guidelines. Here are some common constraints that can be given in the solver:
 Budget Constraint - Ensure that the sum of weights assigned to all assets in the portfolio
equals 1, representing fully invested capital.
 Minimum and Maximum Allocation Constraints - Limit the allocation of each asset to
a specified range to prevent extreme concentrations in any single asset.
 Sector or Industry Constraints - Enforce constraints on the weights of assets belonging
to different sectors or industries to maintain sector diversification.
 Liquidity Constraints - Set minimum trading volumes or liquidity thresholds for assets
to ensure that the portfolio remains liquid and easily tradable.
 Risk Constraints - Limit the overall portfolio risk by imposing constraints on metrics such
as volatility, value-at-risk (VaR), or maximum drawdown.

Author Contact: 99644-02318 | [email protected] | linkedin.com/in/kirankvk


Financial Analytics

 Transaction Cost Constraints - Consider transaction costs by including constraints on


turnover or trading volume to minimize transaction expenses.
 Factor Exposure Constraints - Control exposure to specific risk factors (e.g., market risk,
interest rate risk) by setting constraints on factor loadings or betas.
 Regulatory Constraints - Adhere to regulatory requirements or investment guidelines by
incorporating constraints related to compliance, such as sector limits or maximum
leverage ratios.
 Custom Constraints - Implement custom constraints tailored to specific investment
objectives, risk preferences, or market conditions.

4. Extending to Higher Dimensions


In addition to the regular constraints and optimizations commonly used in portfolio
construction, there are several complex extensions and improvisations that can enhance the
process. Here are some advanced techniques:
Transaction Cost Modeling
Incorporate detailed transaction cost models that account for market impact, liquidity
constraints, and trading costs associated with portfolio rebalancing. Optimize the portfolio to
minimize total transaction costs while achieving desired risk-return objectives.
Conditional Value-at-Risk (CVaR) Optimization
Extend traditional mean-variance optimization by incorporating Conditional Value-at-Risk
(CVaR), also known as expected shortfall, as a risk measure. Optimize the portfolio to minimize
the CVaR, which provides a measure of the expected losses beyond a certain confidence level.
Robust Optimization
Apply robust optimization techniques that explicitly account for uncertainty in input
parameters, such as expected returns and covariance matrix. Optimize the portfolio to
minimize the worst-case scenario loss under various uncertainty scenarios, ensuring resilience
to model estimation errors.
Factor-based Portfolio Construction
Utilize factor models to decompose asset returns into systematic factors (e.g., market risk,
size, value, momentum) and idiosyncratic risks. Construct portfolios that explicitly target
exposure to desired factors while controlling for unintended factor exposures.
Dynamic Portfolio Optimization
Implement dynamic portfolio optimization approaches that adaptively adjust portfolio
weights over time based on changing market conditions, economic indicators, or regime
shifts. Incorporate techniques such as Kalman filtering, regime-switching models, or machine
learning algorithms to capture time-varying relationships in asset returns.

Author Contact: 99644-02318 | [email protected] | linkedin.com/in/kirankvk


Financial Analytics

Multi-Objective Optimization
Extend portfolio optimization to consider multiple conflicting objectives simultaneously, such
as maximizing returns, minimizing risk, and achieving specific constraints. Employ multi-
objective optimization algorithms to identify Pareto-optimal solutions that represent trade-
offs between competing objectives.
Hierarchical Risk Parity (HRP)
Apply hierarchical clustering techniques to group assets into clusters based on their pairwise
correlations. Construct portfolios using the HRP framework, which allocates weights to
clusters rather than individual assets, promoting diversification and stability across different
market regimes.
Machine Learning-based Portfolio Construction
Leverage machine learning algorithms, such as neural networks, random forests, or deep
learning models, to extract complex patterns from historical data and generate optimized
portfolios. Explore techniques like reinforcement learning for portfolio allocation in dynamic
and non-linear environments.
Integration of Alternative Assets
Extend portfolio optimization to include alternative assets classes such as private equity,
hedge funds, real estate, or commodities. Develop custom optimization models that account
for illiquidity, non-normal return distributions, and unique risk factors associated with
alternative investments.
Economic Scenario Generation
Generate a comprehensive set of economic scenarios using Monte Carlo simulations,
historical bootstrapping, or scenario-based modeling techniques. Optimize portfolios to
perform well across a wide range of economic scenarios, including stress testing and scenario
analysis.

5. Constructing an efficient portfolio


An investor's utility function plays a crucial role in determining the most optimum portfolio
for them. The utility function represents the investor's preferences and captures their attitude
towards risk and return. By maximizing their utility function, investors aim to select the
portfolio that provides the highest level of satisfaction or well-being given their risk-return
preferences.
 Investors with higher risk aversion typically have concave utility functions, indicating
diminishing marginal utility of wealth. These investors prioritize minimizing downside risk
and may be willing to accept lower returns for reduced volatility. As a result, they may
prefer portfolios with lower risk levels, even if it means sacrificing some potential returns.
 Conversely, risk-seeking investors may have convex utility functions, indicating
increasing marginal utility of wealth. These investors are willing to take on higher levels of

Author Contact: 99644-02318 | [email protected] | linkedin.com/in/kirankvk


Financial Analytics

risk in exchange for the possibility of higher returns. They may prefer portfolios with higher
expected returns, even if they come with greater volatility.
Portfolio optimization involves selecting the portfolio that maximizes the investor's utility
function. This typically involves solving an optimization problem that considers the trade-off
between risk and return while taking into account the investor's utility function and
constraints such as budget constraints, asset class constraints, and regulatory constraints.
Case of Building an Efficient & Optimum Portfolio using Excel
Step-1. We considered 5 stocks  Apar Industries, Oil India, Apollo Tyres, Tata Chemicals &
Narayana Hrudayalaya
Step-2. Collected the below inputs:

Step-3. Assumed dummy weights

Step-4. Built excel formula that computed the below

Step-5. Using the SOLVER pack in Excel, determined the optimal weights

Optimal Weights that maximize the Sharpe

Repeat the same process to either maximize Treynor’s Ratio or Jensen’s Alpha

Author Contact: 99644-02318 | [email protected] | linkedin.com/in/kirankvk


Financial Analytics

Case of Building an Efficient & Optimum Portfolio using Python

Author Contact: 99644-02318 | [email protected] | linkedin.com/in/kirankvk


Financial Analytics

Author Contact: 99644-02318 | [email protected] | linkedin.com/in/kirankvk


Financial Analytics

6. Portfolio performance evaluation


Portfolio performance evaluation is the process of assessing the effectiveness of an
investment portfolio in achieving its objectives and delivering satisfactory returns relative to
its benchmark or peers. It involves analyzing various performance metrics and measures to
gauge the portfolio's success and identify areas for improvement.
Benchmark Comparison
 Compare the portfolio's performance against relevant benchmarks, such as market indices
(e.g., S&P 500, MSCI World), peer group averages, or custom benchmarks tailored to the
portfolio's investment strategy. Assess whether the portfolio outperformed or
underperformed its benchmark over a specific period.
Return Analysis
 Calculate and analyze the portfolio's returns over different time periods (e.g., daily,
monthly, quarterly, annual). Evaluate the portfolio's absolute return, relative return (excess
return over the benchmark), and risk-adjusted return (e.g., Sharpe ratio, Treynor ratio) to
assess its efficiency in generating returns.
Risk Assessment
 Measure and quantify the portfolio's risk exposure using metrics such as volatility,
standard deviation, beta (systematic risk), and tracking error (deviation from the
benchmark). Assess whether the portfolio's risk level aligns with the investor's risk
tolerance and investment objectives.
Attribution Analysis
 Decompose the portfolio's returns to identify the sources of performance (e.g., asset
allocation, security selection, market timing). Conduct attribution analysis to assess the
contributions of different factors or investment decisions to the portfolio's overall
performance.
Drawdown Analysis

Author Contact: 99644-02318 | [email protected] | linkedin.com/in/kirankvk


Financial Analytics

 Evaluate the portfolio's drawdowns, which represent peak-to-trough declines in portfolio


value. Measure the magnitude and duration of drawdowns to understand the portfolio's
downside risk and resilience during market downturns.
Style Analysis
 Conduct style analysis to assess the portfolio's exposure to different investment styles or
factors (e.g., value, growth, size, momentum). Determine whether the portfolio's style
characteristics align with its investment strategy and objectives.
Turnover and Trading Costs
 Analyze portfolio turnover, which measures the frequency of buying and selling securities
within the portfolio. Assess the impact of turnover on transaction costs, liquidity, and tax
efficiency, and evaluate whether trading activities add value to the portfolio.
Risk-adjusted Performance Measures
 Use risk-adjusted performance measures such as the Information Ratio, Sortino ratio, and
Jensen's alpha to evaluate the portfolio's performance relative to its risk exposure.
Determine whether the portfolio's excess returns justify the level of risk taken.
Peer Comparison and Peer Group Analysis
 Compare the portfolio's performance against peer group averages or similar investment
strategies to benchmark its performance within its peer group. Identify top-performing
peers and assess the portfolio's competitive position.
Regular Review and Monitoring
 Conduct regular reviews and ongoing monitoring of portfolio performance to track
progress, identify trends, and make necessary adjustments to the investment strategy.
Maintain transparency and communication with stakeholders regarding portfolio
performance and investment decisions.

~~~~~~~~~~

Author Contact: 99644-02318 | [email protected] | linkedin.com/in/kirankvk

You might also like