portfolio: Portfolio Object Manager

Description Value Methods Author(s)

Description

Manage your portfolio never be so easy. This object will save all your portfolio and help you manage them all at once. You can do backtesting by combining this object with powerful tools such as TTR package to generate a technical analysis.

Value

Object of type portfolio

Methods

Public methods


Method add_portfolio()

Add portfolio that you have into the object. Each portfolio will be stored using prefix portfolio.

Usage
portfolio$add_portfolio(data, symbol = deparse(substitute(data)))
Arguments
data:

The portfolio that you add

symbol:

The name of the portfolio you were added

Returns

Object of type portfolio


Method add_col()

Add colum to your portfolio data. In some cases, you have your own custom column. In that case, you can add some by using this method.

Usage
portfolio$add_col(x, colname, symbols = NULL)
Arguments
x:

vector for the data

symbol:

The name of the portfolio you want to add to. Please be aware, if you set this leave as NULL, it may not work as expected. It is because it will add the column to all portfolio that may have different dimension.

Returns

Object of type portfolio


Method add_indicator()

Instead of adding a column, you might want to add an indicator to your portfolio. Using this method you can directly calculate the indicator and add the data to your portfolio.

Usage
portfolio$add_indicator(
  .fun,
  colnames,
  indicator_name = deparse(substitute(.fun)),
  to_vector = FALSE,
  ...
)
Arguments
.fun:

the function to calculate the desired indicator

colnames:

The name of the column to store the new indikator. If left blank, it will take the name of the function.

to_vector:

To indicate you want to drop the dataframe using drop = TRUE argument.

...:

This ellipsis used to store the arguments needed by the function. Refers to each function to use it.

Returns

Object of type portfolio


Method remove_na()

In trading data, the famous indicators are EMA, SMA or so on that in fact need to lag data. The backwards is that it leaves so many NAs. Call this method to clean the messy.

Usage
portfolio$remove_na()
Returns

Object of type portfolio


Method clone()

The objects of this class are cloneable with this method.

Usage
portfolio$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Author(s)

Suberlin Sinaga @2021


blakcjack/ims documentation built on Dec. 19, 2021, 9:52 a.m.