Description Usage Arguments Details Value Author(s) See Also Examples
prices
returns a single price vector by selecting among
alternative vectors on the basis of the phases of states
.
1 2 3 4 5 |
uc |
numeric vector. prices mapped to phase 0 (unchanged). |
el |
numeric vector. prices mapped to phase 8 (enter long). |
es |
numeric vector. prices mapped to phase 4 (enter short). |
xl |
numeric vector. prices mapped to phase 2 (exit long). |
xs |
numeric vector. prices mapped to phase 1 (exit short). |
chg,ent,xit,lng,sht |
short-hand arguments. |
states |
numeric vector consisting of 1, 0, and -1 values. |
This is a convenience function for constructing a single price vector
from multiple vectors. Generally, all arguements get vectors of
identical length, but all arguments must be passed vectors whose
length is a multiple of the length of states
. The return can be
passed to the prices
argument of functions pnl
and
ror
.
A numeric vector of prices.
Robert Sams robert@sanctumfi.com
1 2 3 4 5 6 7 8 9 10 11 | s <- sample(c(1,0,-1), 100, TRUE)
spx <- spx[1:100,]
## Example 1: entries/exits at Open, unchanged at Close.
(ex1 <- prices(s, spx$Close, chg=spx$Open))
## Example 2: entries/exits at next day's Open, unchanged at Close.
(ex2 <- prices(s, spx$Close, chg=c(spx$Open[-1], NA)))
## Example 3: same as above, but with 10bps slippage at entries/exits.
(ex3 <- prices(s, spx$Close, lng=c(spx$Open[-1], NA) * 1.001, sht=c(spx$Open[-1], NA) * .999))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.