[R-SIG-Finance] quantstrat & flexible orderqty
Brian G. Peterson
brian at braverock.com
Thu Mar 3 13:38:38 CET 2011
On 03/03/2011 04:18 AM, Immanuel wrote:
> Hello,
>
> looking at the quantstrat demos I realized that the only use fixed
> orderqty.
> ---
> stratMACROSS <- add.rule(strategy = stratMACROSS,name='ruleSignal',
> arguments = list(sigcol="ma50.gt.ma200",sigval=TRUE, orderqty=100,
> ordertype='market', orderside='long'),type='enter')
> ---
> By now I kow how to implement flexible orderqtys depending on account /
> portfolio equity in blotter.
> But if I use quantstrat the create trades loop is hidden, is there a way
> to use flexible orderqty anyway?
There are multiple ways of doing this. If you look at:
?ruleSignal
you'll see the argument 'osFUN'.
This allows you to write a custom order sizing rule for your strategy.
The default behavior is osNoOp. We've also provided osMaxPos as an
example. We commonly write custom order sizing functions for our
proprietary strategies that make decisions based on start of day equity,
leveling in/out of a position, current market volatility, custom risk
rule order sizing, etc.
You can also put some time based loop around your evaluation of the
strategy, if for whatever reason you require this. Understand that this
second approach involves potentially significant performance trade offs,
as you are introducing additional looping and dependencies between
strategy backtest evaluations that could otherwise be parallelized.
Regards,
- Brian
--
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock
More information about the R-SIG-Finance
mailing list