New Markowitz / Matlab

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

New Markowitz / Matlab

vicnorton
We are currently working on a paper

   New Markowitz: a package to aid in portfolio selection

   ABSTRACT
   We present a GNU Octave package to aid in financial portfolio
   selection, with examples of its use on current data. Our minnormy
   function, at the core of the package, is a variation on Harry
   Markowitz’s critical line algorithm.

to be published in the Portfolio Management section of "The Archives"
<http://arxiv.org>. An example in the paper uses the 2014 performance of
243 exchange traded funds, each of which had at least $1 billion in
assets under managemnt at the end of 2014. In that example we compute
the efficient portfolio of these funds that had a total return of
exactly 15% in 2014. (Efficient here means least standard deviation of
return.)

For your curiosity the 243 funds and their 2014 statistics are listed
at
  http://vic.norton.name/finance-math/stats243_2014.pdf
in decreasing order of assets under management at the end of 2014. The
efficient portfolio descibed above is
  0.00018  XLP  - Consumer Staples Select Sector SPDR ETF
  0.08359  TLT  - iShares 20+ Year Treasury Bond
  0.04336  ICF  - iShares Cohen & Steers REIT
  0.08937  BNDX - Vanguard Total Intl Bd Idx ETF
  0.16371  PGX  - PowerShares Preferred
  0.02371  IYT  - iShares Transportation Average
  0.00894  FXG  - First Trust Consumer Staples AlphaDEX
  0.01587  EPI  - WisdomTree India Earnings
  0.00555  FBT  - First Trust NYSE Arca Biotech Index
  0.08274  HYD  - Market Vectors High-Yield Muni ETF
  0.07932  PGF  - PowerShares Financial Preferred
  0.22353  TFI  - SPDR Nuveen Barclays Capital Muni Bond
  0.00842  EMLP - First Trust North American Energy Infras
  0.17171  UUP  - PowerShares DB US Dollar Index Bullish
at 2014-12-31 closing prices.

Apparently Matlab/MathWorks has routine(s) that accomplish the same task.
  http://www.mathworks.com/help/finance/mean-variance-portfolio-optimization.html
We are not aware of any such Octave packages. We expect that Matlab
might have a problem with our data since the corresponding covariance of
returns matrix has L2-condition-number over 100,000,000.

We do not have access to Matlab, but we would be very much interested in
how it performs on our data. Our package (with data) is available for
testing at
  http://vic.norton.name/finance-math/newmarkowitz-tests.tar.gz
Any information on Matlab performance would be greatly appreciated.

Regards,

Vic Norton

P.S. The rtndecomp function is part of the New Markowitz package. This
function is described at <http://arxiv.org/abs/1206.2333>.

P.P.S. Our New Markowitz package requires at least Octave 3.8 since it
has functions nested inside of a function.


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: New Markowitz / Matlab

vicnorton

On Jan 12, 2015, at 8:00 AM, Vic Norton <[hidden email]> wrote:

> We do not have access to Matlab, but we would be very much interested in
> how it performs on our data. Our package (with data) is available for
> testing at
>  http://vic.norton.name/finance-math/newmarkowitz-tests.tar.gz
> Any information on Matlab performance would be greatly appreciated.

I'm afraid I wasn't very clear here. "newmarkowitz-test.tar.gz" is NOT an Octave package. This archive contains the folder "New Markowitz Tests", which, in turn, contains four files:
  README
  newmarkowitz-1.0.0.tar.gz
  oneBdata2014.m
  meanvariance_tests.m
The second file is the New Markowitz package. The two Octave scripts depend on this package.

-
Vic
_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: New Markowitz / Matlab

Julien Bect
Le 12/01/2015 15:57, Vic Norton a écrit :
> On Jan 12, 2015, at 8:00 AM, Vic Norton<[hidden email]>  wrote:
>> >We do not have access to Matlab, but we would be very much interested in
>> >how it performs on our data. Our package (with data) is available for
>> >testing at
>> >  http://vic.norton.name/finance-math/newmarkowitz-tests.tar.gz
>> >Any information on Matlab performance would be greatly appreciated.

Hello Vic,

Which script would you like me to run in Matlab ? meanvariance_tests.m ?

@++
Julien

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: New Markowitz / Matlab

vicnorton

On Jan 12, 2015, at 12:08 PM, Julien Bect <[hidden email]> wrote:

> Le 12/01/2015 15:57, Vic Norton a écrit :
>> On Jan 12, 2015, at 8:00 AM, Vic Norton<[hidden email]>  wrote:
>>> >We do not have access to Matlab, but we would be very much interested in
>>> >how it performs on our data. Our package (with data) is available for
>>> >testing at
>>> >  http://vic.norton.name/finance-math/newmarkowitz-tests.tar.gz
>>> >Any information on Matlab performance would be greatly appreciated.
>
> Hello Vic,
>
> Which script would you like me to run in Matlab ? meanvariance_tests.m ?
>
> @++
> Julien


Hi Julien,

Both scripts are to be run in Octave--after the New Markowitz package has been installed. They are for illustration.

However, the computation
   [E, F, f0] = rtndecomp(R0,0, pput);  # pput = 252 market days per year
in "meanvariance_tests.m" should produce an
   AssetMean: E
and
   AssetCovar: V = f0 ^2 + F' * F
that can be used in some Matlab function to produce efficient portfolios.

I don't own Matlab. I don't know what the appropriate Matlab function is. However MathWorks help at
   http://www.mathworks.com/help/finance/mean-variance-portfolio-optimization.html
implies that such a function exists.

Such a Matlab function, call it
   P = matlabEVtoP(E, V),
would have to produce a matrix of portfolios P (from our E and V) comparable to our
   P = minnormy(F).
With Matlab's P you could compute an efficient 15% return portfolio. How does this portfolio compare with our efficient 15% return portfolio pX0? That's an interesting question. I expect Matlabs portfolio to be close, but it might be somewhat off due to the use of the poorly conditioned covariance matrix V in P = matlabEVtoP(E, V).

I'm also interested in computation times. How does Matlab's
   P = matlabEVtoP(E, V)
compare in speed with our combination
   [E, F, f0] = rtndecomp(R0, 0, pput),
   P = minnormy(F).
I expect our two functions will be significantly faster than Matlab's one, but that's just a guess.

I appreciate your help, Julien, but don't waste a lot of time on this. I'm quite sure that what I am doing compares favorably with anything Matlab has got. In any case I hope to have my work completely written up before long.

Regards,

Vic


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: New Markowitz / Matlab

Julien Bect
Le 12/01/2015 19:52, Vic Norton a écrit :
> I appreciate your help, Julien, but don't waste a lot of time on this.

If you want me to run something in Matlab, please provide a Matlab script.

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: New Markowitz / Matlab

Julien Bect
*** Please keep the public mailing list in the loop ***

Le 13/01/2015 15:48, Vic Norton a écrit :

> On Jan 12, 2015, at 2:38 PM, Julien Bect <[hidden email]> wrote:
>
>> Le 12/01/2015 19:52, Vic Norton a écrit :
>>> I appreciate your help, Julien, but don't waste a lot of time on this.
>> If you want me to run something in Matlab, please provide a Matlab script.
> Hi Julien,
>
> I've done a bit more research. In view of
>    http://www.mathworks.com/help/finance/estimate-efficient-portfolios_bswmb3d-1.html
> the code (MatLab?)
>    pM = Portfolio;
>    pM = setAssetMoments(pM, E', V);
>    pM = setDefaultConstraints(pM);
>    pMwgt = estimateFrontierByReturn(pM, 0.15);
> should produce something close to my portfolio pX0:
>    The efficient, 2013-12-31-close portfolio with return 15.00% in 2014.
>    This portfolio was selected from 243 exchange traded funds/notes with
>    at least $1 billion in assets under management at the end of 2014.
>    The funds are listed in decreasing order of assets under management.
>     44.  0.00018  XLP  - Consumer Staples Select Sector SPDR ETF
>     64.  0.07551  TLT  - iShares 20+ Year Treasury Bond
>    112.  0.03723  ICF  - iShares Cohen & Steers REIT
>    121.  0.09452  BNDX - Vanguard Total Intl Bd Idx ETF
>    144.  0.16191  PGX  - PowerShares Preferred
>    153.  0.02175  IYT  - iShares Transportation Average
>    154.  0.00850  FXG  - First Trust Consumer Staples AlphaDEX
>    158.  0.01427  EPI  - WisdomTree India Earnings
>    159.  0.00433  FBT  - First Trust NYSE Arca Biotech Index
>    194.  0.08284  HYD  - Market Vectors High-Yield Muni ETF
>    195.  0.07967  PGF  - PowerShares Financial Preferred
>    219.  0.23419  TFI  - SPDR Nuveen Barclays Capital Muni Bond
>    239.  0.00782  EMLP - First Trust North American Energy Infras
>    241.  0.17728  UUP  - PowerShares DB US Dollar Index Bullish
> The first two columns here show to positive portfolio "weights".
>
> This output depends on being able to compile
>    [E, F, f0] = rtndecomp(R0, 0, 252);
>    V = f0^2 + F' * F;
> in MatLab, where rtndecomp function comes from the
>    newmarkowitz-1.0.0.tar.gz
> package inside of newmarkowitz-tests.tar.gz.
>
> I am appending a script acrhive
>    matlabtest01.m.zip
> that will do this computation based on the above (MatLab?) code.
> You should be able to run it in Octave or in MatLab, with
>    doMatLabTest01 = 0;
> When
>    doMatLabTest01 = 1;
> it tries to run the (MatLab?) code
>    pM = Portfolio;
>    pM = setAssetMoments(pM, E', V);
>    pM = setDefaultConstraints(pM);
>    pMwgt = estimateFrontierByReturn(pM, 0.15);
>
> I hope this helps.
>
> Regards,
>
> Vic


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: New Markowitz / Matlab

Julien Bect
In reply to this post by vicnorton
*** Please keep the public mailing list in the loop ***

Le 13/01/2015 16:40, Vic Norton a écrit :

> Just to make sure we are on the same page.
>
> The matlabtest01.m code I sent you depends on
>    oneBdata.m   - data file inside "New Markowitz Tests"
>    rtndecomp.m  - function file inside "New Markowitz Tests/newmarkowitz-1.0.0.tar.gz"
>    minnormy.m   - function file inside "New Markowitz Tests/newmarkowitz-1.0.0.tar.gz"
> All of these files are contained in
>    http://vic.norton.name/finance-math/newmarkowitz-tests.tar.gz
>
> Regards,
>
> Vic
Vic,

Your script and functions cannot be used in Matlab.

Comments should be with % instead of #. Operators like ++ and -- are not
allowed. etc.

@++
Julien


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave

matlabtest01.m (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: New Markowitz / Matlab

vicnorton
Thanks for the comments, Julien. I guess I'll put the package on hold for a while. It will clearly need to be rewritten (if I expect it to run in MatLab).

Regards,

Vic

On Jan 13, 2015, at 10:51 AM, Julien Bect <[hidden email]> wrote:

> *** Please keep the public mailing list in the loop ***
>
> Le 13/01/2015 16:40, Vic Norton a écrit :
>> Just to make sure we are on the same page.
>>
>> The matlabtest01.m code I sent you depends on
>>   oneBdata.m   - data file inside "New Markowitz Tests"
>>   rtndecomp.m  - function file inside "New Markowitz Tests/newmarkowitz-1.0.0.tar.gz"
>>   minnormy.m   - function file inside "New Markowitz Tests/newmarkowitz-1.0.0.tar.gz"
>> All of these files are contained in
>>   http://vic.norton.name/finance-math/newmarkowitz-tests.tar.gz
>>
>> Regards,
>>
>> Vic
>
> Vic,
>
> Your script and functions cannot be used in Matlab.
>
> Comments should be with % instead of #. Operators like ++ and -- are not allowed. etc.
>
> @++
> Julien
>
> <matlabtest01.m>


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: New Markowitz / Matlab

vicnorton
In reply to this post by Julien Bect

On Jan 13, 2015, at 10:51 AM, Julien Bect <[hidden email]> wrote:

> Vic,
>
> Your script and functions cannot be used in Matlab.
>
> Comments should be with % instead of #. Operators like ++ and -- are not allowed. etc.
>
> @++
> Julien


Hi Julien,

I started changing the #'s to %'s. That's no problem. But I won't change my ++'s until Octave rewrites the "Increment Operators" section of its manual:
   http://www.gnu.org/software/octave/doc/interpreter/Increment-Ops.html#Increment-Ops

I quote from that section:
   x++
       This expression causes the variable x to be incremented.
       The value of the expression is the old value of x.

Thinking further about it, I guess I'll just forget about MatLab. I like ++'s. I hope Octave doesn't drop them.

Regards,

Vic


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: New Markowitz / Matlab

Julien Bect
Le 13/01/2015 20:24, Vic Norton a écrit :

> On Jan 13, 2015, at 10:51 AM, Julien Bect<[hidden email]>  wrote:
>
>> >Vic,
>> >
>> >Your script and functions cannot be used in Matlab.
>> >
>> >Comments should be with % instead of #. Operators like ++ and -- are not allowed. etc.
>> >
>> >@++
>> >Julien
> Hi Julien,
>
> I started changing the #'s to %'s. That's no problem. But I won't change my ++'s until Octave rewrites the "Increment Operators" section of its manual:
>     http://www.gnu.org/software/octave/doc/interpreter/Increment-Ops.html#Increment-Ops
>
> I quote from that section:
>     x++
>         This expression causes the variable x to be incremented.
>         The value of the expression is the old value of x.
>
> Thinking further about it, I guess I'll just forget about MatLab. I like ++'s. I hope Octave doesn't drop them.

Vic,

Just to be clear: I'm not asking you to change anything in your package
to make it Matlab-compatible.

I'm just saying, if you want me or someone else to test something for
you in Matlab, you have to provide scripts that run in Matlab.

@++
Julien

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: New Markowitz / Matlab

vicnorton

On Jan 13, 2015, at 2:57 PM, Julien Bect <[hidden email]> wrote:

> Just to be clear: I'm not asking you to change anything in your package to make it Matlab-compatible.
>
> I'm just saying, if you want me or someone else to test something for you in Matlab, you have to provide scripts that run in Matlab.


Right, Julien. I'm really only interested in Octave; I'm a card carrying member of the Free Software Foundation.

Be that as it may, here is a script that should run in MatLab. I would be very interested in the MatLab result.
   http://vic.norton.name/finance-math/newmarkowitz/matlabtest.m.zip

Also, for your curiosity, I've uploaded a picture of the 2014 performance of
   SPY  - SPDR S&P 500 (the largest and oldest exchange traded fund)
   BND  - Vanguard Total Bond Market ETF (the largest bond ETF)
   VIC  - An unattended ETF portfolio in BND, XLP, XLV, and XLU
   X156 - An unattended portfolio of 6 ETFs that gained exactly 15% in 2014
The X156 portfolio  performed very much like the efficient p15 in the matlabtest. It was much, much less volatile than SPY, but it earned a bit more. (SPY earned 13.5% in 2014.)
   http://vic.norton.name/finance-math/newmarkowitz/growth2014.pdf

Thanks for your continuing comments and help!

Regards,

Vic
_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave