A typo caused my last algorithm to constantly buy/sell for no reason, this is what I believe that buying based on kalman filtering should look like (I realize that a lot of the decisions--like buying 200 stocks as opposed to some portion of the portfolio, etc. are simple, but this is more of a proof of concept than anything that I would want to trade on).