Description Usage Arguments Examples
View source: R/rules_indicators.R
Conditions will be calculated and then action will be done according to type. osFun arg is needed for definition of how much money you want to invest in enter type rules.
1 2 3 4 5 6 7 8 9 10 | addRule(this, condition, as, args = list(), type, side, oco = "base",
osFun = sameMoneyOs, osFun_args = alist(amount = getMoney(this)),
pathwise = FALSE, money, money_const, betas, betas_const, by_money = TRUE,
...)
## S3 method for class 'modelStrategy'
addRule(this, condition = TRUE, as, args = list(),
type = "enter", side = 1, oco, osFun = sameMoneyOs,
osFun_args = alist(amount = getMoney(this)), pathwise = FALSE, money,
money_const, betas, betas_const, by_money = TRUE, ...)
|
this |
modelStrategy |
condition |
expression, it must use name of indicators and local args |
as |
character, local name of rule |
args |
list, arguments that can be used in condition |
type |
character, type must be enter or exit |
side |
numeric, 1 or -1 |
oco |
character, environment of rule |
osFun |
function that calculates how many units of spread should be bought or sold |
osFun_args |
alist of args of osFun function |
pathwise |
logical, if it is FALSE, then calculation of rules and variables will be performed on the tables once per computation of coefficients, otherwise calculation of rules and variables will be performed on the scalars on each iteration |
money |
numeric / expression, how much money should be in position after execution of rule. Position manager will be added for correcting positions at every step |
money_const |
numeric / expression, the same as money, but without Position manager |
betas |
numeric / expression, number of instruments to buy and sell, position manager will be added |
betas_const |
numeric / expression, the same as betas, but without position manager |
by_money |
logical, if it is TRUE then expression in betas argument will be interpreted as money positions in instruments, else positions will be in pieces |
... |
params |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | ## Not run:
addRule(this, as = 'bb_dn_up',
condition = (Lag(spread,1) < Lag(bb[,'dn'],1)) &
(spread > bb[,'dn']) &
(spread < bb[,mavg']) &
(abs(spread - bb[,'mavg'])/spread > n) ,
type = 'enter',
args = list(n = 0.005),
side = 1,
oco = 'long',
osFun = sameMoneyOs,
osFun_args = alist(amount = 5000000))
addRule(this, as = 'bb_dn_up1',
condition = (Lag(spread < bb[,'dn'],1))[iii,] &
(spread > bb[,'dn'])[iii,] &
(spread < bb[,mavg'])[iii,] &
(abs(spread - bb[,'mavg'])/spread > n)[iii,] ,
type = 'enter',
pathwise = TRUE,
args = list(n = 0.005),
side = 1,
oco = 'long',
osFun = sameMoneyOs,
osFun_args = alist(amount = 5000000))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.