Urgent on the help

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Urgent on the help

Yunlei.Hu

 Dear all

I am using quadratic programming to solve the portfolio optimization in
cosidering transaction cost. Is there any R optimization package can do
this?

Solve.QP require the positive definite matrix in Dmat, while in my case,
this matrix in the objective function is not positive definite.

>  It is in a bit of emergency. I would be really appreciated if anybody
> can give me the reply ASAP.
>
> Many thanks
>  Yunlei
>
_______________________________________________

This e-mail may contain information that is confidential, privileged or otherwise protected from disclosure. If you are not an intended recipient of this e-mail, do not duplicate or redistribute it by any means. Please delete it and any attachments and notify the sender that you have received it in error. Unless specifically indicated, this e-mail is not an offer to buy or sell or a solicitation to buy or sell any securities, investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Barclays. Any views or opinions presented are solely those of the author and do not necessarily represent those of Barclays. This e-mail is subject to terms available at the following link: www.barcap.com/emaildisclaimer. By messaging with Barclays you consent to the foregoing.  Barclays Capital is the investment banking division of Barclays Bank PLC, a company registered in England (number 1026167) with its registered offi!
 ce at 1 Churchill Place, London, E14 5HP.  This email may relate to or be sent from other members of the Barclays Group.

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.
Reply | Threaded
Open this post in threaded view
|

Re: Urgent on the help

markleeds
A few months back, someone mentioned  a paper on the internet that showed
how to modify the QP to handle transaction costs. I have the paper at work
but I don't remember the name of it and I haven't read it. If you check the
archives, I imagine the old thread must be there and the link also.





-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of
[hidden email]
Sent: Tuesday, July 22, 2008 4:17 AM
To: [hidden email]
Subject: [R-SIG-Finance] Urgent on the help


 Dear all

I am using quadratic programming to solve the portfolio optimization in
cosidering transaction cost. Is there any R optimization package can do
this?

Solve.QP require the positive definite matrix in Dmat, while in my case,
this matrix in the objective function is not positive definite.

>  It is in a bit of emergency. I would be really appreciated if anybody
> can give me the reply ASAP.
>
> Many thanks
>  Yunlei
>
_______________________________________________

This e-mail may contain information that is confidential, privileged or
otherwise protected from disclosure. If you are not an intended recipient of
this e-mail, do not duplicate or redistribute it by any means. Please delete
it and any attachments and notify the sender that you have received it in
error. Unless specifically indicated, this e-mail is not an offer to buy or
sell or a solicitation to buy or sell any securities, investment products or
other financial product or service, an official confirmation of any
transaction, or an official statement of Barclays. Any views or opinions
presented are solely those of the author and do not necessarily represent
those of Barclays. This e-mail is subject to terms available at the
following link: www.barcap.com/emaildisclaimer. By messaging with Barclays
you consent to the foregoing.  Barclays Capital is the investment banking
division of Barclays Bank PLC, a company registered in England (number
1026167) with its registered offi!
 ce at 1 Churchill Place, London, E14 5HP.  This email may relate to or be
sent from other members of the Barclays Group.

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.
Reply | Threaded
Open this post in threaded view
|

Re: Urgent on the help

Debashis Dutta
In reply to this post by Yunlei.Hu
Hi Yuilei,
 
For immediate reference, I enclose two papers. See if  these come to your use. give me a little time to run through the codes.
 
Kind Regards,
Debashis

 
On 22/07/2008, [hidden email] <[hidden email]> wrote:

Dear all

I am using quadratic programming to solve the portfolio optimization in
cosidering transaction cost. Is there any R optimization package can do
this?

Solve.QP require the positive definite matrix in Dmat, while in my case,
this matrix in the objective function is not positive definite.

>  It is in a bit of emergency. I would be really appreciated if anybody
> can give me the reply ASAP.
>
> Many thanks
>  Yunlei
>
_______________________________________________

This e-mail may contain information that is confidential, privileged or otherwise protected from disclosure. If you are not an intended recipient of this e-mail, do not duplicate or redistribute it by any means. Please delete it and any attachments and notify the sender that you have received it in error. Unless specifically indicated, this e-mail is not an offer to buy or sell or a solicitation to buy or sell any securities, investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Barclays. Any views or opinions presented are solely those of the author and do not necessarily represent those of Barclays. This e-mail is subject to terms available at the following link: www.barcap.com/emaildisclaimer. By messaging with Barclays you consent to the foregoing.  Barclays Capital is the investment banking division of Barclays Bank PLC, a company registered in England (number 1026167) with its registered offi!
ce at 1 Churchill Place, London, E14 5HP.  This email may relate to or be sent from other members of the Barclays Group.

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.


_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.

paper_nag.pdf (257K) Download Attachment
po.pdf (314K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Urgent on the help

Debashis Dutta
Hi Yuilei,
 
For immediate reference, I enclose one papers. See if  this comes to your use. give me a little time to run through the codes.
 
Kind Regards,
Debashis


On 01/09/2008, Debashis Dutta <[hidden email]> wrote:
Hi Yuilei,
 
For immediate reference, I enclose two papers. See if  these come to your use. give me a little time to run through the codes.
 
Kind Regards,
Debashis

 
On 22/07/2008, [hidden email] <[hidden email]> wrote:

Dear all

I am using quadratic programming to solve the portfolio optimization in
cosidering transaction cost. Is there any R optimization package can do
this?

Solve.QP require the positive definite matrix in Dmat, while in my case,
this matrix in the objective function is not positive definite.

>  It is in a bit of emergency. I would be really appreciated if anybody
> can give me the reply ASAP.
>
> Many thanks
>  Yunlei
>
_______________________________________________

This e-mail may contain information that is confidential, privileged or otherwise protected from disclosure. If you are not an intended recipient of this e-mail, do not duplicate or redistribute it by any means. Please delete it and any attachments and notify the sender that you have received it in error. Unless specifically indicated, this e-mail is not an offer to buy or sell or a solicitation to buy or sell any securities, investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Barclays. Any views or opinions presented are solely those of the author and do not necessarily represent those of Barclays. This e-mail is subject to terms available at the following link: <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.barcap.com/emaildisclaimer" target="_blank">www.barcap.com/emaildisclaimer. By messaging with Barclays you consent to the foregoing.  Barclays Capital is the investment banking division of Barclays Bank PLC, a company registered in England (number 1026167) with its registered offi!
ce at 1 Churchill Place, London, E14 5HP.  This email may relate to or be sent from other members of the Barclays Group.

_______________________________________________
[hidden email] mailing list
<a onclick="return top.js.OpenExtLink(window,event,this)" href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance" target="_blank">https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.




_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.

paper_nag.pdf (257K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Urgent on the help

Debashis Dutta
In reply to this post by Yunlei.Hu
Hi Yunlei,

Try solve.QP function of Quadprog package. It is


> solve.QP
function (Dmat, dvec, Amat, bvec, meq = 0, factorized = FALSE)
{
    n <- nrow(Dmat)
    q <- ncol(Amat)
    if (missing(bvec))
        bvec <- rep(0, q)
    if (n != ncol(Dmat))
        stop("Dmat is not symmetric!")
    if (n != length(dvec))
        stop("Dmat and dvec are incompatible!")
    if (n != nrow(Amat))
        stop("Amat and dvec are incompatible!")
    if (q != length(bvec))
        stop("Amat and bvec are incompatible!")
    if ((meq > q) || (meq < 0))
        stop("Value of meq is invalid!")
    iact <- rep(0, q)
    nact <- 0
    r <- min(n, q)
    sol <- rep(0, n)
    crval <- 0
    work <- rep(0, 2 * n + r * (r + 5)/2 + 2 * q + 1)
    iter <- rep(0, 2)
    res1 <- .Fortran("qpgen2", as.double(Dmat), dvec = as.double(dvec),
        as.integer(n), as.integer(n), sol = as.double(sol), crval =
as.double(crval),
        as.double(Amat), as.double(bvec), as.integer(n), as.integer(q),
        as.integer(meq), iact = as.integer(iact), nact = as.integer(nact),
        iter = as.integer(iter), work = as.double(work), ierr =
as.integer(factorized),
        PACKAGE = "quadprog")
    if (res1$ierr == 1)
        stop("constraints are inconsistent, no solution!")
    else if (res1$ierr == 2)
        stop("matrix D in quadratic function is not positive definite!")
    list(solution = res1$sol, value = res1$crval, unconstrainted.solution =
res1$dvec,
        iterations = res1$iter, iact = res1$iact[1:res1$nact])
}
<environment: namespace:quadprog>
>

Let me know whether I have understood your your problem properly.

Regards,
Deashis


On 22/07/2008, [hidden email] <[hidden email]>
wrote:

>
>
> Dear all
>
> I am using quadratic programming to solve the portfolio optimization in
> cosidering transaction cost. Is there any R optimization package can do
> this?
>
> Solve.QP require the positive definite matrix in Dmat, while in my case,
> this matrix in the objective function is not positive definite.
>
> >  It is in a bit of emergency. I would be really appreciated if anybody
> > can give me the reply ASAP.
> >
> > Many thanks
> >  Yunlei
> >
> _______________________________________________
>
> This e-mail may contain information that is confidential, privileged or
> otherwise protected from disclosure. If you are not an intended recipient of
> this e-mail, do not duplicate or redistribute it by any means. Please delete
> it and any attachments and notify the sender that you have received it in
> error. Unless specifically indicated, this e-mail is not an offer to buy or
> sell or a solicitation to buy or sell any securities, investment products or
> other financial product or service, an official confirmation of any
> transaction, or an official statement of Barclays. Any views or opinions
> presented are solely those of the author and do not necessarily represent
> those of Barclays. This e-mail is subject to terms available at the
> following link: www.barcap.com/emaildisclaimer. By messaging with Barclays
> you consent to the foregoing.  Barclays Capital is the investment banking
> division of Barclays Bank PLC, a company registered in England (number
> 1026167) with its registered offi!
> ce at 1 Churchill Place, London, E14 5HP.  This email may relate to or be
> sent from other members of the Barclays Group.
>
> _______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>

        [[alternative HTML version deleted]]

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.
Reply | Threaded
Open this post in threaded view
|

Re: Urgent on the help

Krishna Kumar-2
In reply to this post by Yunlei.Hu
Hi Yunlei,

There are many recipes to find the nearest non-singular matrix. Peter Jackel has a nice paper outlining three popular approaches to this.

The R package corpcor has an implementation of Higham's approach.

>require(corpcor)
>posDefmat<-make.positive.definite(mat,tol)

Should do the trick now it  would be a good idea to compares this to Rebonato's method, which  is essentially setting the negative or close to zero eigen values to a small positive number (1e-5) and rescale to get the non-singular matrix back. This is a good practice  just to compare these things and see what magic dust(:-)). higham's procedure adds to the original matrix.

Hth

Best
Krishna
----
"When I get a little money, I buy books and if any
      is left, I buy food and clothes."  -- Erasmus

-----Original Message-----
From: <[hidden email]>

Date: Tue, 22 Jul 2008 09:17:11
To: <[hidden email]>
Subject: [R-SIG-Finance] Urgent on the help



 Dear all

I am using quadratic programming to solve the portfolio optimization in
cosidering transaction cost. Is there any R optimization package can do
this?

Solve.QP require the positive definite matrix in Dmat, while in my case,
this matrix in the objective function is not positive definite.

>  It is in a bit of emergency. I would be really appreciated if anybody
> can give me the reply ASAP.
>
> Many thanks
>  Yunlei
>
_______________________________________________

This e-mail may contain information that is confidential, privileged or otherwise protected from disclosure. If you are not an intended recipient of this e-mail, do not duplicate or redistribute it by any means. Please delete it and any attachments and notify the sender that you have received it in error. Unless specifically indicated, this e-mail is not an offer to buy or sell or a solicitation to buy or sell any securities, investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Barclays. Any views or opinions presented are solely those of the author and do not necessarily represent those of Barclays. This e-mail is subject to terms available at the following link: www.barcap.com/emaildisclaimer. By messaging with Barclays you consent to the foregoing.  Barclays Capital is the investment banking division of Barclays Bank PLC, a company registered in England (number 1026167) with its registered offi!
 ce at 1 Churchill Place, London, E14 5HP.  This email may relate to or be sent from other members of the Barclays Group.

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.
_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.