Skip to content

Instructions how to create Portfolio DataFrame

Vladislav Pyatnitskiy edited this page Feb 4, 2024 · 4 revisions

The most crucial part of working with Portfolio Information is DataFrame. This page is aimed to explain how to create specific type of DataFrame to work with all other script in this repository.

Creating DataFrame with Securities' information

Before building Portfolio DataFrame, it is necessary to type info about current securities. Information should include ticker (name of the company on stock market), start date (buy date), end date (sell date) and number of securities. To do the following you need to create nested list with information. After that nested list should be transformed into DataFrame, which will be used to create time series data.

These steps can be seen in this script:

https://github.com/vladislavpyatnitskiy/Portfolio_Analysis/blob/main/Scripts/Securities%20info%20entry.R

Portfolio DataFrame

Having created DataFrame with portfolio information, you will be finally able to create time series data of portfolio. Everything you need is to put previous DataFrame into this script:

https://github.com/vladislavpyatnitskiy/Portfolio_Analysis/blob/main/Scripts/Portfolio%20DataFrame%20Builder.R

Now you have right peace which will allow to get all functionality of the repository.

DataFrame of returns

Portfolio DataFrame contains values of securities prices, number and total values but not appropriate to calculate returns. Therefore, I have written script that calculates Portfolio Return:

https://github.com/vladislavpyatnitskiy/Portfolio_Analysis/blob/main/Scripts/Portfolio%20Returns%20Calculation.R

Clone this wiki locally