Various R (and more) code for stock analysis