# Quantstrat Position Accounting System: Netting vs Hedging Systems

8 messages
Open this post in threaded view
|

## Quantstrat Position Accounting System: Netting vs Hedging Systems

 Dear all, In quantstrat, as described in package documentation, orders turn into transactions,  transactions turn into positions, positions turn into trades. And the underlying logic of how you define a position (using netting or hedging system) or a trade (flat-to-flat or FIFO etc) significantly affects the mechanics of money management rules (stop loss etc) and trade statistics (profit factor etc). For defining positions, the netting vs hedging systems are defined as follows: https://www.metatrader5.com/en/mobile-trading/iphone/help/trade/general_conceptThe original implementation of quantstrat is based on a netting system where after having a long position, each additional long trade increases the current position amount (unless you have a position limit) and the stop-loss/take profit is applied to the total position as a whole and not to the individual long trades separately. My question is that is there a way to apply stop loss and take profit to each opened trade independently, regardless of order side (long or short) and previous positions? If yes, would you provide an example of it? Best regards Ayhan         [[alternative HTML version deleted]] _______________________________________________ [hidden email] 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.
Open this post in threaded view
|

## Re: Quantstrat Position Accounting System: Netting vs Hedging Systems

Open this post in threaded view
|

## Re: Quantstrat Position Accounting System: Netting vs Hedging Systems

Open this post in threaded view
|

## Re: Quantstrat Position Accounting System: Netting vs Hedging Systems

 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]] _______________________________________________ [hidden email] 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.
Open this post in threaded view
|

## Re: Quantstrat Position Accounting System: Netting vs Hedging Systems

 Thank you for the clarification. On Sun, 8 Nov 2020 at 16:21, Ilya Kipnis <[hidden email]> 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]] _______________________________________________ [hidden email] 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.
Open this post in threaded view
|

## Re: Quantstrat Position Accounting System: Netting vs Hedging Systems

 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 <[hidden email]> wrote: > Thank you for the clarification. > > On Sun, 8 Nov 2020 at 16:21, Ilya Kipnis <[hidden email]> 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]] _______________________________________________ [hidden email] 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.