Hi Ravi,

To give you some background:

The function compute_strategy_before_fees returns portfolio returns and
standard deviation. Our optimal portfolio will maximise the returns
whilst keeping the standard deviation at a certain level.

We have an input matrix C that the function uses to calculate the asset
weights in the portfolio over time. Problem is that I am a complete R
novice and would not know where to start in optimising this in R.

Could you please give some guidance on using the R functions?

Thanks,
Eduard 

-----Original Message-----
From: Ravi Varadhan [mailto:rvarad...@jhmi.edu] 
Sent: 05 February 2009 19:37
To: Eduard Pieterse (Macquarie Securities)
Cc: r-help@r-project.org
Subject: Re: [R] Non-linear optimisation

Hi,

I don't understand your Matlab code.  However, let me say this:

 - you could use "L-BFGS-B" algorithm in optim() or nlminb(), if you
only have box constraints

 - you could use ConstrOptim(), if you only have linear inequality
constraints

 - you could use Rdonlp2 if you have more general equality/inequality
constraints

Best,
Ravi.

____________________________________________________________________

Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology School of Medicine Johns
Hopkins University

Ph. (410) 502-2619
email: rvarad...@jhmi.edu


----- Original Message -----
From: ehxpieterse <eduard.piete...@macquarie.com>
Date: Thursday, February 5, 2009 2:03 pm
Subject: [R]  Non-linear optimisation
To: r-help@r-project.org


>  Hi there,
>  
>  I have a piece of Matlab code I use to optimise a trding strategy. If

> there  are any Matlab/R specialists out there, I would appreciate your

> help in  doing the exact same optimisation in R.
>  
>  I suspect I would use nlm() in R but am not sure where to define my  
> constraints.
>  
>  I have attached my Matlab code below for reference.
>  
>  Many thanks.
>  
>  Constraints
>  function [c,ceq]=TriskellConstraints(X)  global objFunc_vol;  [a,b] =

> objFunc_vol(X);
>  c(1) = b-6.5;
>  c(2) = std(X(:))-6.5;
>  ceq = [];
>  end
>  
>  Optimise
>  global objFunc_vol
>  objFunc_vol = @(C) compute_strategy_before_fees(prices, C, floor, 
> cap,  m_ret_reb, prices_TR, hedge_fund, vg, euribor, last_reb_date, 
> Maturity,  fixed_fees, var_fees);
>  
>  objFunc_vol(C);
>  
>  objFunc = @(C) compute_strategy_before_fees(prices, C, floor, cap,  
> m_ret_reb, prices_TR, hedge_fund, vg, euribor, last_reb_date, 
> Maturity,  fixed_fees, var_fees);
>  
>  objFunc(C);
>  
>  options = optimset('MaxIter',10000000,'MaxFunEvals',10000000);
>  
>  tic;
>  
>  % OPTIMISE
>  
>  %M =
>  
> fmincon(objFunc,C,[],[],[],[],repmat(-20,12,9),repmat(20,12,9),@Triske
> llConstraints,options);
>  M =
>  
> fmincon(objFunc_vol,C,[],[],[],[],repmat(-20,12,9),repmat(20,12,9),@Tr
> iskellConstraints,options);  [Z, ZZ] = 
> compute_strategy_after_fees(prices, C, floor, cap, m_ret_reb,  
> prices_TR, Hedge_Fund, vg, euribor, last_reb_date, Maturity, 
> fixed_fees,  var_fees, dates, variation_cap_property, eurusd);  [Y, 
> YY] = compute_strategy_after_fees(prices, M, floor, cap, m_ret_reb,  
> prices_TR, Hedge_Fund, vg, euribor, last_reb_date, Maturity, 
> fixed_fees,  var_fees, dates, variation_cap_property, eurusd);
>  
>  timespent = toc/60; %converts to minutes
>  
>  
>  --
>  View this message in context: 
>  Sent from the R help mailing list archive at Nabble.com.
>  
>  ______________________________________________
>  R-help@r-project.org mailing list
>  
>  PLEASE do read the posting guide
>  and provide commented, minimal, self-contained, reproducible code. 

If there is any advice in this email, it is general advice only and has been 
prepared by Macquarie Group or one of its related entities (“Macquarie”). 

Macquarie has made every reasonable effort to ensure the information provided 
is correct, but Macquarie makes no representation nor any warranty as to 
whether the information is accurate, complete or up to date. To the extent 
permitted by law, Macquarie accepts no responsibility for any errors or 
misstatements, negligent or otherwise. The information provided may be based on 
assumptions or market conditions and may change without notice. 
Macquarie, its associates, officers or employees may also have interests in the 
financial products referred to in this information by acting in various roles. 
They may buy or sell the financial products as principal or agent and as such 
may effect transactions which are not consistent with any recommendations (if 
any in this information).  Macquarie or its associates may also receive fees or 
brokerage for acting in the above capacities.

The information in this email is confidential. If you ar...{{dropped:9}}

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to