Stock analysis and trading algorithms using machine learning