I am attempting to use R to backtest a spread (self generated, not exchange based) and use that to generate signals for a pairs trading strategy. I am using Quantstrat and Financial Instrument package to do so. I can get a strategy to run and it will test the 2 underlying futures and the spread itself. However the spread trading results are very strange, its treating it as if the spread itself was the instrument and so it makes loses 1$ per tick. Instead of executing the trade on the underlying futures.
Example: strategy using ES and YM as underlying. Generate a spread using the notional Ratio of ES/ YM. Test using bollinger bands. The spread result will be something like -10$ for the spread, and test the bollinger band system on both the underlyings.
Has anyone else figured out how to use the spread function? I have not seen any demo code for it and am really struggling. If there is interest I can try to post some reproducible code so people can play with it and see what I am talking about.
Any resources or help on using spreads in quantstrat would be great. Thanks. Hopefully some r experts here can help. Big Mike IlyaKipnis