R program

45 views
Skip to first unread message

Hiro

unread,
Jun 19, 2011, 5:52:07 PM6/19/11
to Leverage Space Trading
Hi Josh,

I got 0.5545627 in the probability of drawdown under the condition of
0.3.
Why did I get it?

Hiro

> probDrawdown(port,DDN,hrz,calcmax,errorparam,sigmaparam) # should not be >0.3
[1] 0.5545627

Joshua Ulrich

unread,
Jun 19, 2011, 7:12:57 PM6/19/11
to leverage-sp...@googlegroups.com
Sampling can cause this. Can you send the values for all the
necessary objects (DDN,hrz,calcmax,errorparam,sigmaparam) and the
output of dput(port)?
--
Joshua Ulrich  |  FOSS Trading: www.fosstrading.com

Hiro

unread,
Jun 23, 2011, 8:42:53 PM6/23/11
to Leverage Space Trading
Hi Josh,
Here is what I have;

> # Create a Leverage Space Portfolio object
> port <- lsp(outcomes,probs)
>
> # DEoptim parameters (see ?DEoptim)
> np=80 # 10 * (number of mktsys + 2) [for z+ and z-]
> imax=10 #maximum number of iterations
> crossover=0.6 #probability of crossover
>
> NR <- NROW(port$f)
> DEctrl <- list(NP=np,itermax=imax, CR=crossover, trace=TRUE)
>
> library(snow)
> hrz <- 12 # horizon = number of periods into the future
> DDN <-0.30000000000000004 # n% DrawDown
> calcmax <-5 # maximum calculated cycles
> PDD <-0.3# probability of n% DrawDown
> errorparam <-0.0010# error size for shortcut
> sigmaparam <-3.0# sigmas for shortcut
>
> targetreturn <-0.01 # targetreturn command line parameter
> zminusmin <--0.9 # the lowest value z minus can be
> res <- maxProbProfit(port,targetreturn,hrz,probDrawdown, PDD, zminusmin, DD=DDN, calc.max=calcmax, error=errorparam, sigma=sigmaparam, snow=NULL, control=DEctrl)
iteration: 10 best member: 0 0.2474 0 0.512 0.2457 1 -0.6499 -0.9
best value: -1
>
> res
$f
[1] 0.0000000 0.2473907 0.0000000 0.5119651 0.2457229 1.0000000

$z
par7 par8
-0.64986 -0.90000

$profitProb
[1] 0.9999853

> port$f <- res$f # put the optimal f values into the lsp object
> probDrawdown(port,DDN,hrz,calcmax,errorparam,sigmaparam) # should not be >0.3
[1] 0.5545627

Hiro Narita
> > [1] 0.5545627- 引用テキストを表示しない -
>
> - 引用テキストを表示 -

Joshua Ulrich

unread,
Jun 23, 2011, 8:44:31 PM6/23/11
to leverage-sp...@googlegroups.com
That's the same as your last email. I need the contents of the "port"
object, which you can get from running dput(port) at the R prompt.

--
Joshua Ulrich | FOSS Trading: www.fosstrading.com

2011/6/23 Hiro <hiroyukin...@gmail.com>:

Hiro

unread,
Jun 24, 2011, 5:32:37 AM6/24/11
to Leverage Space Trading
Hi Josh,
I am not sure what is port object.
Is this what you are asking for?
Hiro

> # Load the LSPM package
> library(LSPM)
>
> outcomes <- cbind(
+
c(-288000,-77190.476,-77190.476,-77190.476,-77190.476,-77190.476,-77190.476,-77190.476,-77190.476,-77190.476,-77190.476,-77190.476,-77190.476,-77190.476,-77190.476,-77190.476,-77190.476,81781.25,81781.25,81781.25,81781.25,81781.25,81781.25,81781.25,81781.25,81781.25,81781.25,81781.25,81781.25,81781.25,81781.25,81781.25,81781.25,81781.25,81781.25,81781.25,81781.25,81781.25,81781.25,81781.25,360666.667,360666.667,360666.667,552000),
+
c(96416.667,-153928.571,-153928.571,-153928.571,-153928.571,96416.667,96416.667,96416.667,96416.667,96416.667,96416.667,96416.667,96416.667,440000,440000,440000,440000,-400000,-153928.571,-153928.571,-153928.571,-153928.571,-153928.571,-153928.571,-153928.571,-153928.571,96416.667,96416.667,96416.667,96416.667,96416.667,96416.667,96416.667,96416.667,96416.667,96416.667,96416.667,96416.667,440000,658000,96416.667,96416.667,440000,-153928.571),
+
c(-137625,75307.692,75307.692,75307.692,75307.692,75307.692,75307.692,75307.692,75307.692,75307.692,75307.692,353000,353000,75307.692,75307.692,75307.692,353000,75307.692,-137625,-137625,-137625,75307.692,75307.692,75307.692,75307.692,353000,-355000,-137625,-137625,75307.692,75307.692,75307.692,75307.692,75307.692,75307.692,75307.692,75307.692,353000,75307.692,353000,75307.692,535000,353000,353000),
+
c(80571.429,-204100,80571.429,80571.429,375750,-204100,80571.429,80571.429,80571.429,80571.429,375750,-204100,80571.429,-204100,-204100,80571.429,80571.429,80571.429,80571.429,80571.429,80571.429,-204100,80571.429,80571.429,80571.429,80571.429,-204100,80571.429,80571.429,-484000,-204100,80571.429,80571.429,80571.429,375750,375750,661000,80571.429,80571.429,80571.429,-204100,80571.429,80571.429,80571.429),
+
c(-105875,107305.556,-105875,107305.556,107305.556,107305.556,-105875,107305.556,107305.556,724000,107305.556,107305.556,107305.556,-105875,584500,107305.556,-105875,584500,107305.556,107305.556,107305.556,107305.556,-105875,107305.556,584500,107305.556,107305.556,107305.556,107305.556,-378000,107305.556,-105875,-105875,107305.556,107305.556,107305.556,584500,107305.556,-105875,-105875,107305.556,-105875,-105875,107305.556),
+
c(-72705.882,-72705.882,176500,176500,176500,176500,-72705.882,-72705.882,176500,692111.111,176500,176500,176500,692111.111,176500,176500,928000,176500,-427000,-72705.882,176500,-72705.882,176500,176500,176500,692111.111,-72705.882,-72705.882,176500,176500,-72705.882,-72705.882,176500,176500,-72705.882,176500,176500,692111.111,176500,692111.111,176500,692111.111,692111.111,692111.111))
>
> probs <- c(
+
0.01724137931,0.01724137931,0.01724137931,0.01724137931,0.01724137931,0.034482758621,0.034482758621,0.01724137931,0.068965517241,0.01724137931,0.01724137931,0.01724137931,0.01724137931,0.01724137931,0.01724137931,0.01724137931,0.01724137931,0.01724137931,0.01724137931,0.034482758621,0.01724137931,0.01724137931,0.01724137931,0.01724137931,0.01724137931,0.01724137931,0.01724137931,0.034482758621,0.01724137931,0.01724137931,0.01724137931,0.068965517241,0.01724137931,0.068965517241,0.01724137931,0.01724137931,0.01724137931,0.034482758621,0.01724137931,0.01724137931,0.01724137931,0.01724137931,0.01724137931,0.01724137931)
>

On 6月24日, 午前9:44, Joshua Ulrich <josh.m.ulr...@gmail.com> wrote:
> That's the same as your last email. I need the contents of the "port"
> object, which you can get from running dput(port) at the R prompt.
> --
> Joshua Ulrich | FOSS Trading:www.fosstrading.com
>

> 2011/6/23 Hiro <hiroyukinarita1...@gmail.com>:

> >> - 引用テキストを表示 -- 引用テキストを表示しない -
>
> - 引用テキストを表示 -

Joshua Ulrich

unread,
Jun 24, 2011, 1:09:22 PM6/24/11
to leverage-sp...@googlegroups.com
Hi Hiro,

Thanks, that was exactly what I needed. I get similar results when I
run your code. The probDrawdown result is so high because the z
values in the "port" object are still all zero (their default value).

The results are correct if you update the z values and the target
return in the "port" object with the results from the optimization:
> # z values and target return are zero
> probDrawdown(port,DDN,hrz,calcmax,errorparam,sigmaparam)
[1] 0.5897737
> port$z <- c(res$z,targetreturn) # update z values and target return
> probDrawdown(port,DDN,hrz,calcmax,errorparam,sigmaparam) # < 0.3
[1] 0.1325635

Best,


--
Joshua Ulrich | FOSS Trading: www.fosstrading.com

2011/6/24 Hiro <hiroyukin...@gmail.com>:

Reply all
Reply to author
Forward
0 new messages