My first attempt at co-integration. Run only on 2014 and still work in progress. Could someone please help with following issues:
This is a daily trading strategy but I had to run it on minute mode because when algo finds a profitable spread it should capture it immediately instead of waiting for next day's close when spreads could change. The solution I found was to run it on minute mode but use schedule function so that algo runs only once per day. Is there an alternative?
The implementation of Johansen's test I borrowed from internet fails very often because matrices are not invertible. I understand that it is possible to get "useful" matrices that are invertible from non-invertible matrices using regularization? Please advise if you know of any such methods. Because of this limitation there are long periods of time where algo doesn't trade at all because Johansen fails.
Ideally would like to run Johansen's test on all combinations of stocks to find a nice cointegrated basket of stocks. But handle_data timesout. Is there a better alternative?