FinancialPortfolios.FinancialPortfolioType
FinancialPortfolio

A (possibly named) collection of portfolio weights. Weights can be a dictionary-like object matching asset identifiers with weights or just a vector of weights.

Example

w = [0.5, 0.25, 0.25]
FP_vec = FinancialPortfolio(w)

nm = ["a", "b", "c"]
plain_dict = Dict(Iterators.zip(nm,w))
FP_plaindict = FinancialPortfolio(plain_dict)

using Dictionaries
fancy_dict = dictionary(plain_dict)
FP_fancydict = FinancialPortfolio(fancy_dict)
Base.keysMethod
keys(fp::FinancialPortfolio)

Recover the names or identifiers of the assets in the portfolio.

FinancialPortfolios.checkupdate!Method
checkupdate!(fp::FinancialPortfolio,ret)

Updates the weights of the portfolio in place. Returns the period portfolio return.

If ret does not contain an entry for one of the existing portfolio positions, this function assumes the position was closed.

positions must be an object like Dict or Dictionaries.AbstractDictionary.

Example

w = Dict(["stockA"=>0.8,"stockB"=>0.2])
r = Dict(["stockA"=>0.1])
FP = FinancialPortfolio(w)
checkupdate!(FP,r)
FP
FinancialPortfolios.portfolioreturnMethod
portfolioreturn(fp::FinancialPortfolio,ret)

Compute the weighted portfolio return. If the portfolio weights have names or identifiers, the returns should as well. The portfolio is allowed to contain only a subset of the supplied asset returns, but not the other way around.

Example

w = [0.5, 0.25, 0.25]
r = [0.1, 0.1, -0.1]
FP = FinancialPortfolio(w)
portfolioreturn(FP,r)
FinancialPortfolios.positionsMethod
positions(fp::FinancialPortfolio)

Recover the weights of the assets in the portfolio (as a fraction of total value).

FinancialPortfolios.update!Method
update!(fp::FinancialPortfolio,ret)

Updates the weights of the portfolio in place. Returns the period portfolio return.

The portfolio is allowed to contain only a subset of the supplied asset returns, but not the other way around.

Example

w = [0.5, 0.25, 0.25]
r = [0.1, 0.1, -0.1]
FP = FinancialPortfolio(w)
update!(FP,r)
FP