addPosLimit(portfolio, symbol, timestamp, maxpos, longlevels = 1, minpos = -maxpos, shortlevels = longlevels)
addPosLimit
works with osMaxPos
to set
and enforce position sizing limits. If levels=1
,
then all order sizing will be in the complete control of
the strategy rules, up to the maximum position specified
using addPosLimit
's maxpos
and minpos
arguments.Simply setting a position limit will not do anything. The
strategy entry rules also need to specify an the use of
order sizing function osMaxPos
, most
typically as an argument to ruleSignal
.
levels are a simplification of more complex (proprietary) techniques sometimes used for order sizing. the max orderqty returned will be the limit/levels. Obviously the strategy rules could ask for smaller order sizes, but this is the default. If you don't want to use levels, set them to 1.
It is also important to note that position limits may be
time-varying. If you only want one static maximum position
limit, then call addPosLimit
with a timestamp
argument before your first trade. If you want time varying
limits, typically in response to some rebalancing rule or
risk rule, set the timestamp
at the time which you
wish the limit to take effect.
osMaxPos
getPosLimit