Is it possible to implement a basket or portfolio stoploss in quantstrat? That is, I would like to trade a number of symbols simultaneously and use accumulated p/l across all symbols as a global stoploss/take profit. I have not seen any examples of this in quanstrat, likely as this method of position management is normally seen in foreign exhange trading and not stocks. Is it possible to do or would it require getting a list of possible entry prices for all symbols and performing post-hoc position managent? Cheers, BobbyT
Basket stop loss implementation quantstrat
5 messages · Aaron, Brian G. Peterson
On Mon, 2016-12-12 at 17:17 +0000, Aaron wrote:
Is it possible to implement a basket or portfolio stoploss in quantstrat? That is, I would like to trade a number of symbols simultaneously and use accumulated p/l across all symbols as a global stoploss/take profit. I have not seen any examples of this in quanstrat, likely as this method of position management is normally seen in foreign exhange trading and not stocks. Is it possible to do or would it require getting a list of possible entry prices for all symbols and performing post-hoc??position management?
quantstrat isn't really optimized for this kind of rule. You could do it with a rebalance rule, but it will add a cross-symbol loop on every rebalance period. Brian
1 day later
Hi Brian, Thank you for the reply. I'm going to go out on a limb and assume that rebalancing in this way will come at the cost of considerable overhead(?). I plan on testing 28 symbols with a minimum data periodicity of 15 minutes (over a period of ~10 years). How significant would the extra overhead be in a situation like this? I have not yet got into rebalancing rules in quantstrat. Is there an example I could look up which could point me in the right direction? Also, as my objective appears to be outside the scope of normal quantstrat applications, are you able to provide some sketch code as to how such an operation would be managed? I'm more than happy to have a dig at this myself but somewhere to start would be nice. Cheers, Aaron
From: Brian G. Peterson <brian at braverock.com>
Sent: Tuesday, 13 December 2016 5:32 AM
To: Aaron; r-sig-finance at r-project.org
Subject: Re: [R-SIG-Finance] Basket stop loss implementation quantstrat
Sent: Tuesday, 13 December 2016 5:32 AM
To: Aaron; r-sig-finance at r-project.org
Subject: Re: [R-SIG-Finance] Basket stop loss implementation quantstrat
On Mon, 2016-12-12 at 17:17 +0000, Aaron wrote: > Is it possible to implement a basket or portfolio stoploss in > quantstrat? That is, I would like to trade a number of symbols > simultaneously and use accumulated p/l across all symbols as a global > stoploss/take profit. > > I have not seen any examples of this in quanstrat, likely as this > method of position management is normally seen in foreign exhange > trading and not stocks. > > Is it possible to do or would it require getting a list of possible > entry prices for all symbols and performing post-hoc position > management? quantstrat isn't really optimized for this kind of rule. You could do it with a rebalance rule, but it will add a cross-symbol loop on every rebalance period. Brian
Yes, it comes at a cost, as I said in my message, and as the documentation for applyStrategy.rebalancing describes. In the demo folder, see any of the 'rebalancing' demos for sample code. Regards, Brian
On Tue, 2016-12-13 at 19:37 +0000, Aaron wrote:
Hi Brian, Thank you for the reply. I'm going to go out on a limb and assume that rebalancing in this way will come at the cost of considerable overhead(?). I plan on testing 28 symbols with a minimum data periodicity of 15 minutes (over a period of ~10 years). How significant would the extra overhead be in a situation like this? I have not yet got into rebalancing rules in quantstrat. Is there an example I could look up which could point me in the right direction? Also, as my objective appears to be outside the scope of normal quantstrat applications, are you able to provide some sketch code as to how such an operation would be managed? I'm more than happy to have a dig at this myself but somewhere to start would be nice. Cheers, Aaron
________________________________ From: Brian G. Peterson <brian at braverock.com> Sent: Tuesday, 13 December 2016 5:32 AM To: Aaron; r-sig-finance at r-project.org Subject: Re: [R-SIG-Finance] Basket stop loss implementation quantstrat On Mon, 2016-12-12 at 17:17 +0000, Aaron wrote: Is it possible to implement a basket or portfolio stoploss in quantstrat? That is, I would like to trade a number of symbols simultaneously and use accumulated p/l across all symbols as a global stoploss/take profit. I have not seen any examples of this in quanstrat, likely as this method of position management is normally seen in foreign exhange trading and not stocks. Is it possible to do or would it require getting a list of possible entry prices for all symbols and performing post-hoc??position management? quantstrat isn't really optimized for this kind of rule. You could do it with a rebalance rule, but it will add a cross-symbol loop on every rebalance period. Brian [[alternative HTML version deleted]] _______________________________________________ R-SIG-Finance at 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.
Thank you Brian. This at least gives me somewhere to start. Much better than I had a few days back. I have not had a chance to look over the demos thoroughly yet but am I correct in assuming that child rules (of the rebalancing rules) would need to be put in place for both stoploss and take profit? Or is it the other way around; the rebalancing rule exists as a child to the stoploss/take profit rules? Or have I completely overshot the runway here? Cheers, Aaron
From: Brian G. Peterson <brian at braverock.com>
Sent: Wednesday, 14 December 2016 7:05 AM
To: Aaron; r-sig-finance at r-project.org
Subject: Re: [R-SIG-Finance] Basket stop loss implementation quantstrat
Sent: Wednesday, 14 December 2016 7:05 AM
To: Aaron; r-sig-finance at r-project.org
Subject: Re: [R-SIG-Finance] Basket stop loss implementation quantstrat
Yes, it comes at a cost, as I said in my message, and as the documentation for applyStrategy.rebalancing describes. In the demo folder, see any of the 'rebalancing' demos for sample code. Regards, Brian On Tue, 2016-12-13 at 19:37 +0000, Aaron wrote: > Hi Brian, > > > Thank you for the reply. > > > I'm going to go out on a limb and assume that rebalancing in this way > will come at the cost of considerable overhead(?). I plan on testing > 28 symbols with a minimum data periodicity of 15 minutes (over a > period of ~10 years). How significant would the extra overhead be in > a situation like this? > > > I have not yet got into rebalancing rules in quantstrat. Is there an > example I could look up which could point me in the right direction? > > > Also, as my objective appears to be outside the scope of normal > quantstrat applications, are you able to provide some sketch code as > to how such an operation would be managed? I'm more than happy to > have a dig at this myself but somewhere to start would be nice. > > > Cheers, > > Aaron > > > ________________________________ > From: Brian G. Peterson <brian at braverock.com> > Sent: Tuesday, 13 December 2016 5:32 AM > To: Aaron; r-sig-finance at r-project.org > Subject: Re: [R-SIG-Finance] Basket stop loss implementation > quantstrat > > On Mon, 2016-12-12 at 17:17 +0000, Aaron wrote: > > > > Is it possible to implement a basket or portfolio stoploss in > > quantstrat? That is, I would like to trade a number of symbols > > simultaneously and use accumulated p/l across all symbols as a > > global > > stoploss/take profit. > > > > I have not seen any examples of this in quanstrat, likely as this > > method of position management is normally seen in foreign exhange > > trading and not stocks. > > > > Is it possible to do or would it require getting a list of possible > > entry prices for all symbols and performing post-hoc position > > management? > quantstrat isn't really optimized for this kind of rule. > > You could do it with a rebalance rule, but it will add a cross-symbol > loop on every rebalance period. > > Brian > > > [[alternative HTML version deleted]] > > _______________________________________________ > R-SIG-Finance at 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.