[R-SIG-Finance] LSPM - Unexpected Results

Noah Silverman noah at smartmediacorp.com
Tue Dec 28 01:20:20 CET 2010


Answers below

On 12/27/10 12:07 PM, Joshua Ulrich wrote:
> On Mon, Dec 27, 2010 at 1:10 PM, Noah Silverman <noah at smartmediacorp.com> wrote:
>> Josh,
>>
>> 1)
>> R version: 2.11.0
>> LSPM Version:  (Don't know where to check)
>>
> packageDescription("LSPM")  # revision 49 is most recent
>
I realized that on that machine, both R and LSPM weren't the newest
versions.  So I did a clean install of the latest R and the latest
LSPM.  Subsequently, what took about 20 hours before looks like it will
finish in about 5.  (This version is linked to the BLAS library, and was
custom configured for the 64 bit cpu on this machine.)

>> 2)
>> I'm fine with it taking many hours - that's to be expected.  There are
>> 48 observations for each of the 13 assets.
>>
>> 3)
>> The last output line from the optimizer is:
>> 0 0.5908 0.545 0.0954 0.41 0 0.0969 0.0078 0.6066 0.4896 0.0113 0.7568 1
>> -0.5036 -1 best value:  -1
>>
>> The last two values are negative, which I am now assuming are the "z"
>> values.  But do not know what "z" values are - don't see any mention of
>> them in the Handbook of Portfolio Mathematics.
>>
> They're discussed in The Leverage Space Trading Model.  They control
> the aggressiveness of your position sizing when your equity is above /
> below target.
I'll have to read that section.  Thank You.


>> 4)
>> Is there documentation about how to specify the margin and other
>> constraints?  The help files in R left me a bit lost.
>>
> Sorry about the lack of documentation... here's how to specify margin
> constraints:
> http://blog.fosstrading.com/2010/08/margin-constraints-with-lspm.html
>
> Other constraints can be specified and passed via the
> constrFun/constrVal arguments, just like you specified the drawdown
> constraint.
>
If I understand your blog correctly, the margin constraints are not part
of the optimal f calculation, but come into play afterward.  I'll try
your code and let you know what the results are


>> I'm trying this while looking at a portfolio that is a "fund of funds".
>> So, they want to invest 100% of their fund and can't short anything.
>> Furthermore, they can only re-balance every 90 days, which only adds
>> further constraint.
>>
>>
>> I'm using the jpt example function from your blog with n=4 and the
>> following call in R:
>> DEctrl <- list(NP=100, itermax=1000, trace=1 )
>> res <- maxProbProfit(jpt, 1e-6, 6, probDrawdown, 0.1, DD=0.2,
>> calc.max=4, snow=cl, control=DEctrl)
>>
> Why are you setting itermax=1000?
An initial run of 100 didn't look like it was producing optimal
results.  I thought that I'd try an extreme value and can always adjust
it lower if needed.  However, since speed isn't an issue here, I don't
mind the extra processing time if it leads to a better result.


Thanks!



>> Thanks!!!!
>>
>> --
>> Noah
>>
>>
> --
> Joshua Ulrich  |  FOSS Trading: www.fosstrading.com
>
>
>>
>> On 12/27/10 10:23 AM, Joshua Ulrich wrote:
>>> Noah,
>>>
>>> On Mon, Dec 27, 2010 at 12:02 PM, Noah Silverman
>>> <noah at smartmediacorp.com> wrote:
>>>> Hi,
>>>>
>>>> I've been playing with the LSPM library from optimizing a portfolio of
>>>> 13 assets (Using the interesting Leverage Space model developed by Ralph
>>>> Vince.)
>>>>
>>> Which version (and revision) of LSPM are you using?  Which version of R?
>>>
>>>> Using the function:  maxProbProfit
>>>>
>>>> res <- maxProbProfit(jpt, 1e-6, 6, probDrawdown, 0.1, DD=0.2,
>>>> calc.max=4, snow=cl, control=DEctrl)
>>>>
>>>> It takes a LONG time for the optmizer to find a solution.
>>>>
>>> It's always going to take a long time, especially with 13 assets and
>>> 100 optimizer iterations (the default).  How many observations are in
>>> your lsp object?  A reproducible example, or just some sample data,
>>> would really help here.
>>>
>>>> It has found a solution that has a 100% probability of profit given the
>>>> constraints.
>>>>
>>>> The odd thing is that several of the values (optimal F) are negative.
>>>> My understanding is that indicates shorting the asset.  This assets in
>>>> this portfolio can't be shorted.
>>>>
>>> I doubt any f values are negative because they're bound between [0,1]
>>> during the optimization.  My guess is that you're referring to the two
>>> "z" values, which will always be negative.
>>>
>>> Here's a quick example from ?maxProbProfit:
>>>
>>> require(LSPM)
>>> data(port)
>>> ipop <- cbind(runif(50,0,0.01),runif(50,0,0.01),runif(50,0,0.01),
>>>   runif(50,-1,-0.8),runif(50,-1,-0.8))
>>> DEctrl <- list(itermax=11, NP=50, initial=ipop)
>>> res <- maxProbProfit(port, 1e-6, 4, probDrawdown, 0.1,
>>>   DD=0.2, calc.max=4, control=DEctrl)
>>>
>>>> res
>>> $f
>>> [1] 0.002308994 0.001884296 0.116972712
>>>
>>> $z
>>>     zminus      zplus
>>> -0.9256852 -0.9976883
>>>
>>> $profitProb
>>> [1] 0.9963587
>>>
>>>
>>>> I've never read about shorting with the LSPM model, is this common?
>>>> Is there a way to indicate, as a constraint, not to short?
>>>> I have a portfolio of X dollars to allocate, so the percentages must sum
>>>> to one, how do I do this once I get the F values?
>>>>
>>> You need to do this during the optimization via the "margin" and
>>> "equity" arguments.
>>>
>>> HTH,
>>> --
>>> Joshua Ulrich  |  FOSS Trading: www.fosstrading.com
>>>
>>>
>>>
>>>> Thanks in advance for any and all suggestions!
>>>>
>>>> --
>>>> Noah
>>>>
>>>> _______________________________________________
>>>> R-SIG-Finance at r-project.org mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>>>> -- Subscriber-posting only. If you want to post, subscribe first.
>>>> -- Also note that this is not the r-help list where general R questions should go.
>>>>
>> _______________________________________________
>> R-SIG-Finance at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>> -- Subscriber-posting only. If you want to post, subscribe first.
>> -- Also note that this is not the r-help list where general R questions should go.
>>



More information about the R-SIG-Finance mailing list