Quantstrat: Multiple instruments, pre-generated signals
Ilya,
Yes, you definitely can. You can definitely inject pre-generated signals as additional columns on your data ahead of time, and then use add.signal to work with them later, skipping the add.indicator step entirely.
So if the strategy involves 1000 stocks quantstrat's object would get 1000 additional columns?
Quantstrat/R *can* handle such an amount of data, but understand that quantstrat will loop over each instrument individually,
Does this mean, when there are multiple entry signals at the same day and time and I like to discard some of them (because of insufficient cash) that I can not do this on a random basis? The idea would be to add a Monte Carlo simulation at such points, but I'm not sure how long such a calculation would take.
and the loops occur by signal observations.
What do you mean by this?
That said, the "handle these prior to close" is a bit *vague* as far as objective implementation goes. What does "prior to close" mean? 3:55 PM EST?
I just referred to the time stop rule one paragraph above. The exit should be like a three-leg logical or-rule: My trades start at EntryDate, EntryTime and exit (at the latest) with the close of the last bar of ExitDate. But a trade is closed out earlier, if a take profit or a stop loss is met. So if at any day during the trade's lifetime a bar at 3:55 PM EST (or whenever) mets a take profit or a stop loss, the trade should be closed - even if the last bar of ExitDate is not yet reached. Thanks Mike
On Wed, Dec 18, 2024 at 5:40?PM Mike <mike9 at posteo.nl> wrote:
My strategy involves a universe with more than 1000 stocks. Since the entry rules are complex, I've generated the entry signals with a separate program. The resulting table for entry signals includes these columns: Symbol, EntryDate, EntryTime, ExitDate. The backtest has to run on intraday basis. I have intraday data OHLCV for every stock involved. The period to be tested spans several years. Each trade has to be closed market on close on ExitDate at the latest (time stop). Stop loss and take profit have to be handled prior to close on ExitDate. Stop loss has to be tightened up once if a profit target is met. Can I backtest such a type of strategy using quantstrat? Especially: - Can I inject pre-generated signals to quantstrat? - Can quantstrat/R handle such an amount of data? Mike