
This rule works with applyStrategy.rebalancing
to set the
maximum trade size by calling addPosLimit
.
rulePctEquity(trade.percent = 0.02, ..., longlevels = 1, shortlevels = 1,
digits = NULL, refprice = NULL, portfolio, account = NULL, symbol,
timestamp)
max percentage of equity to allow the strategy to trade in this symbol
any other passthrough parameters
numeric number of levels
numeric number of short levels, default longlevels
if not NULL(the default), will call round
with specified number of digits
if not NULL(the default), will divide the calculated tra
text name of the portfolio to place orders in, typically set automatically
text name of the account to fetch initial equity from, defaults to initEq in the search path
identifier of the instrument to cancel orders for, typically set automatically
timestamp coercible to POSIXct that will be the time the order will be inserted on, typically set automatically
To use it, you need to specify it as (part of) a rule of type 'rebalance'.
note that applyStrategy.rebalancing
will expect a
'rebalance_on' argument to be included in the arguments=list(...)
of the rule definition.
# NOT RUN {
# example rule definition
# }
# NOT RUN {
add.rule(strategy.name, 'rulePctEquity',
arguments=list(rebalance_on='months',
trade.percent=.02,
refprice=quote(last(getPrice(mktdata)[paste('::',curIndex,sep='')])[,1]),
digits=0
),
type='rebalance',
label='rebalance')
# }
Run the code above in your browser using DataLab