You are on page 1of 9

School of Commerce, Finance & Accountancy

B. COM (Financial Analytics) Program

COA 311L: Applied R for Analytics

CIA 4: Portfolio Construction

Student Name

Arshika : 22111006

Shawn Ebinazer: 22111042

Devesh Bajpai: 22111012

Batch 2022

Submitted to

Prof. Sneha babu


INTRODUCTION:
In this CIA, we have constructed a portfolio containing the data of shares of different companies
namely Tata Steel, Wipro and Titan and we have used the values of Gold in India through 2010-
2021. Here, we have analyzed the portfolio to find out which asset is giving more return over
time and which asset would be the best to invest into.

PORTFOLIO CONSTRUCTION PROCESS:


```{r}

# Load necessary libraries

library(tidyverse)

library(lubridate)

# Read the stock data

stocks <- FINAL_50_STOCK_1

stocks$DATE <- as.Date(paste(stocks$DATE, "-01-01", sep = "")) # Convert to Date type

# Select and clean stock data (TATASTEEL, WIPRO, TITAN)

stocks_portfolio <- select(stocks, DATE, TATASTEEL, WIPRO, TITAN)

stocks_portfolio <- stocks_portfolio %>% fill(TATASTEEL, WIPRO, TITAN, .direction =


"down")

# Read the economic data

india_data <- Gold_Data

india_data$Date <- as.Date(paste(india_data$Date, "-01-01", sep = "")) # Convert to Date


type
# Merging the datasets on Date

combined_portfolio <- merge(stocks_portfolio, india_data, by.x = "DATE", by.y = "Date", all


= TRUE)

# Calculating daily returns

combined_portfolio <- combined_portfolio %>%

mutate(TATASTEEL_return = (TATASTEEL / lag(TATASTEEL) - 1) * 100,

WIPRO_return = (WIPRO / lag(WIPRO) - 1) * 100,

TITAN_return = (TITAN / lag(TITAN) - 1) * 100,

Gold_return = (`India(INR)` / lag(`India(INR)`) - 1) * 100)

# Calculating standard deviation (volatility) for each asset

std_devs <- combined_portfolio %>%

summarise(TATASTEEL_sd = sd(TATASTEEL_return, na.rm = TRUE),

WIPRO_sd = sd(WIPRO_return, na.rm = TRUE),

TITAN_sd = sd(TITAN_return, na.rm = TRUE),

Gold_sd = sd(Gold_return, na.rm = TRUE))

# Calculating correlation matrix for diversification analysis

cor_matrix <- combined_portfolio %>%

select(TATASTEEL_return, WIPRO_return, TITAN_return, Gold_return) %>%

cor(use = "complete.obs")

# Sharpe Ratio (assuming risk-free rate is 0 for simplicity)


sharpe_ratios <- combined_portfolio %>%

summarise(TATASTEEL_sharpe = mean(TATASTEEL_return, na.rm = TRUE) /


sd(TATASTEEL_return, na.rm = TRUE),

WIPRO_sharpe = mean(WIPRO_return, na.rm = TRUE) / sd(WIPRO_return, na.rm =


TRUE),

TITAN_sharpe = mean(TITAN_return, na.rm = TRUE) / sd(TITAN_return, na.rm =


TRUE),

Gold_sharpe = mean(Gold_return, na.rm = TRUE) / sd(Gold_return, na.rm = TRUE))

# Print results

print(std_devs)

print(cor_matrix)

print(sharpe_ratios)

```

```{r}

# 1. Time Series Plot for Prices

ggplot(combined_portfolio, aes(x = DATE)) +

geom_line(aes(y = TATASTEEL, color = "TATASTEEL")) +

geom_line(aes(y = WIPRO, color = "WIPRO")) +

geom_line(aes(y = TITAN, color = "TITAN")) +

geom_line(aes(y = `India(INR)`, color = "Gold")) +

labs(title = "Asset Prices Over Time", y = "Price", color = "Asset") +

theme_minimal()
# 2. Time Series Plot for Returns

ggplot(combined_portfolio, aes(x = DATE)) +

geom_line(aes(y = TATASTEEL_return, color = "TATASTEEL")) +

geom_line(aes(y = WIPRO_return, color = "WIPRO")) +

geom_line(aes(y = TITAN_return, color = "TITAN")) +

geom_line(aes(y = Gold_return, color = "Gold")) +

labs(title = "Asset Returns Over Time", y = "Daily Return (%)", color = "Asset") +

theme_minimal()

# 3. Correlation Heatmap

cor_data <- combined_portfolio %>%

select(TATASTEEL_return, WIPRO_return, TITAN_return, Gold_return) %>%

cor(use = "complete.obs")

melted_cor_data <- melt(cor_data)

ggplot(melted_cor_data, aes(Var1, Var2, fill = value)) +

geom_tile() +

scale_fill_gradient2(low = "blue", high = "red", mid = "white", midpoint = 0, limit = c(-1,


1)) +

labs(title = "Correlation Heatmap", x = "", y = "") +

theme_minimal()

```

We have constructed the portfolio using the above code. At first, we have installed the
necessary libraries “tidyverse” and “lubridate”. Then we have imported our data set and
calculated the returns on each of the shares and gold.
ASSET ALLOCATION DECISION:
Our choice of specific assets, such as shares of Tata Steel, Wipro, and Titan, along with the value
of gold, in constructing an investment portfolio should be driven by careful consideration of
various factors. These factors are as follows:

1. Diversity : Tata Steel, Wipro, and Titan operate in different sectors: Tata Steel in the
metals industry, Wipro in information technology, and Titan in consumer goods
(especially jewelry and watches). Including assets from diverse sectors helps to achieve a
well-rounded and diversified portfolio, reducing the impact of poor performance in any
single sector.

2. Risk Mitigation: Different types of assets have different risk profiles. Stocks of
companies like Tata Steel, Wipro, and Titan may offer potential for capital appreciation
but come with equity market volatility. On the other hand, gold is often considered a
"safe-haven" asset, tending to retain value during economic downturns. Combining
equities with a commodity like gold can help mitigate overall portfolio risk.

3. Inflation: Gold is often considered a hedge against inflation. In times of rising inflation,
the value of gold may increase, providing a level of protection for the portfolio. This can
be particularly relevant for investors looking to preserve the purchasing power of their
investments over the long term.

4. Liquidity: Liquidity is an important factor, especially for individual investors. Tata Steel,
Wipro, Titan, and gold are generally liquid assets, making it easier to buy and sell them in
the market.

5. Industry Exposure: Tata Steel, Wipro, and Titan represent companies from different
industries, providing exposure to various economic sectors. This exposure allows
investors to benefit from growth opportunities in different segments of the economy.

PERFORMANCE EVALUATION:
The graph titled "Asset Returns Over Time," depicts the daily return percentages for four
assets: TATASTEEL, WIPRO, TITAN, and Gold. The X-axis represents the date,
ranging from around 2010 to beyond 2020, and the Y-axis represents the daily return
percentage.

Here's a brief analysis of the graph:

Volatility: The graph displays significant volatility in returns for all assets. This is evident
from the sharp peaks and troughs throughout the graph.

Comparison: At certain points, such as shortly before 2015 and towards the end of the
visible time period, all assets except for Gold show a sharp increase in returns. This could
suggest a market event that favorably impacted these stocks, or it could be indicative of
an outlier in the data due to a split, dividend, or data error.

Gold: The return of Gold (in orange) remains relatively stable with fewer fluctuations
compared to the stocks, until a steep increase towards the end of the timeline. Gold is
often considered a safer investment and this relative stability up until the sharp rise is
typical for this asset class.

Data Anomalies: The sudden vertical lines, particularly noticeable for Gold and TITAN
towards the end of the graph, could indicate either extreme actual changes in returns or
data anomalies. Such patterns are sometimes due to corporate actions like stock splits,
data errors, or missing data points where the line connects non-consecutive dates.
Missing Data: The warnings at the top of the RStudio indicate that there were rows with
missing values (NA) that were removed from the plot. This could suggest that the dataset
may have missing values on certain dates for one or more assets.

Divergence: Around 2015, WIPRO (in purple) shows a notable dip in returns while the
other assets don't, which could indicate an event specific to WIPRO or the sector it
belongs to.

Therefore, we can see that Tata Steel is offering the maximum returns over time among
all the assets.
We have also included other graphs such as Correlational Heatmap and asset prices over
time using time series (line graph).

You might also like