portfolio

Python function returns only the first value instead of a dataframe

浪子不回头ぞ 提交于 2021-02-05 08:35:59
问题 I have build a function where I append the returns of 5 portfolios to a dataframe which I want to return to a variable . When I run the commands within the function row by row(kind of debugging) I end upwith the variable 'folioReturn'(which is the one I want my script to return) having the right amount of values (e.x 5). But if I call the function, only the first value of the dataframe is returned. Does anyone know how I can get the whole dataframe ? def portfolioReturns (securities,

how to use fportfolio package in R for non time series input?

时光毁灭记忆、已成空白 提交于 2021-02-05 08:08:38
问题 For fportfolio package you need to put, as an input, a time series of returns and it internally calculate the expected return and the variance of the time series for then to be used in functions such as portfoliofrontier or tangencyportfolio. But in my case I have already the expected return matrix and the variance covariance matrix and I want to use the functions of fportfolio. How can I do this? thank in advance. 回答1: I do not use fportfolio ; but if you only need the means and the variance

Custom expected returns in the Portfolio Analytics package

北战南征 提交于 2020-05-28 15:51:50
问题 I have trouble incorporating custom expected returns in Portfolio Analytics package. Usually expected returns are some professional expectations / views or calculated separately from fundamental indicators. Portfolio Analytics allow to create custom moments function to calculate moments from past returns, but I don't understand how to incorporate already calculated returns to optimization problem. Any help is appreciated and here is small example dataset: #Download package and sample returns

Custom expected returns in the Portfolio Analytics package

谁说我不能喝 提交于 2020-05-28 15:44:46
问题 I have trouble incorporating custom expected returns in Portfolio Analytics package. Usually expected returns are some professional expectations / views or calculated separately from fundamental indicators. Portfolio Analytics allow to create custom moments function to calculate moments from past returns, but I don't understand how to incorporate already calculated returns to optimization problem. Any help is appreciated and here is small example dataset: #Download package and sample returns

Forecasting for DCC Copula GARCH model in R

巧了我就是萌 提交于 2020-01-16 07:32:15
问题 I'm trying to forecast the Copula Garch Model. I have tried to use the dccforecast function with the cGARCHfit but it turns out to be error saying that there is no applicable method for 'dccforecast' applied to an object of class cGARCHfit. So how do actually we forecast the dcc copula garch model? I have the following reproducible code. library(zoo) library(rugarch) library(rmgarch) data("EuStockMarkets") EuStockLevel <- as.zoo(EuStockMarkets)[,c("DAX","CAC","FTSE")] EuStockRet <- diff(log

R portfolio analytics chart.EfficientFrontier function

我只是一个虾纸丫 提交于 2019-12-25 07:49:30
问题 I am trying to use the chart.EfficientFrontier function in the portfolioanalytics package in R to chart an efficient frontier object that I have created but it keeps failing. Basically I am trying to find a frontier that will minimize annaulized standard deviation. Eventually once I get this working I would also like to maximize annualized return. Firstly I created an annualized standard deviation function using this code pasd <- function(R, weights){ as.numeric(StdDev(R=R, weights=weights)

How to allow for weights between -1 and 1 using constraints in Aeq x <= beq

半世苍凉 提交于 2019-12-24 08:57:05
问题 I am using quadprog to find a portfolio of optimal weights. So far, I have managed to implement long-only and short-only constraints as follows: FirstDegree = zeros(NumAssets,1); SecondDegree = Covariance; Long only Aeq = ones(1,NumAssets); beq = 1; A = -eye(NumAssets); b = zeros(NumAssets,1); x0 = 1/NumAssets*ones(NumAssets,1); MinVol_Weights = quadprog(SecondDegree,FirstDegree,A,b,Aeq,beq,[],[],x0, options); Short-only Aeq = ones(1,NumAssets); beq = -1; A = eye(NumAssets); b = zeros