implemented stock trading algorithm