[R-SIG-Finance] Quantstrat Position Accounting System: Netting vs Hedging Systems

Brian G. Peterson br|@n @end|ng |rom br@verock@com
Thu Nov 12 12:28:17 CET 2020


The chained order quantity isn't directly passed to the triggered chain
rule right now.

Rules have access to the full current state, since they are path
dependent.  

So, you have two options here.  You can either 

- write a custom order sizing function that queries the order status to
check the chained rule and order to get the quantity

- propose a patch/pull request to rules.R and ruleSignal.R that could
process a chain.qty optional argument

see the code in rules.R to see how we pass chain.price, and it should
inform how you would take either of the above approaches.

Regards,

Brian

-- 
Brian G. Peterson
ph: +1.773.459.4973
im: bgpbraverock

On Thu, 2020-11-12 at 13:43 +0300, Ayhan yuksel wrote:
> One more question to solve my case
> 
> We can access the parent rule’s order price using chain.price
> argument  in
> rule functions.
> 
> Is it also possible to access parent rule’s order size as well? I
> searched
> but couldn't find it
> 
> Assume that the parent order may take variable position size for each
> trade. It takes one long position and then adds a second long
> position
> before hitting the stop loss for the first one. After that the stop
> loss
> for the first position is hit. We need to know the position size of
> the
> first trade in writing stop loss rule. Is it possible to access the
> position size of the parent rule?
> 
> Thanks for your help
> Regards
> 
> 
> 
> 
> 
> On 9 Nov 2020 Mon at 11:09 Ayhan yuksel <ayhanyuksel78 using gmail.com>
> wrote:
> 
> > Thank you for the clarification.
> > 
> > On Sun, 8 Nov 2020 at 16:21, Ilya Kipnis <ilya.kipnis using gmail.com>
> > wrote:
> > 
> > > Look at your stoploss rule and the orderqty it calls for. You
> > > actively
> > > specify orderqty = 'all'. That means to flatten the entire
> > > position.
> > > 
> > > As far as a stop loss on a partial position, in your particular
> > > case, you
> > > can simply set that with a better specified orderqty argument by
> > > specifying
> > > 100 lots instead of 'all'.
> > > 
> > 
> 
>         [[alternative HTML version deleted]]
> 
> _______________________________________________
> R-SIG-Finance using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R
> questions should go.
>



More information about the R-SIG-Finance mailing list