In the Kalman filters thread, Nitay Rabinovich shared a simple EMA crossover signal that showed some promise, so I'm continuing the conversation here in its own thread. 

I've taken the EMA Crossover logic and adapted it for universe trading in the attached backtest. Note this is not built from Nitay Rabinovich's universe version, but is built from my universe template code, with some added features for position management. A next version should integrate features from both versions.  

Some noteworthy features in this version:  

  1. Minimum Volume threshold: only trade the coin if it has had at least this much recent volume traded
  2. Max Exposure Pct: Total % of available capital to trade with at any time
  3. Max holdings: Total # of positions that can be held simultaneously
  4. Rebalancing Weekly: If True, rebalance every week, otherwise only rebalance when we add/remove positions  
  5. ‘UseMomWeight’ : If True, use rebalance weights based on momentum (top gainers=more weight). Otherwise use equal weighting.
  6. Order annotation: Orders are annotated with additional information: eg profit at time of close, reason for opening / closing the order, etc.
     

Note: 
1) There are errors in the log that have to do with order size, specifically that the minimum order size (in quote currency) was not reached. This may be resolved by adopting a more manual approach to position sizing, checking available cash, and calculating the qty to purchase.  Nitay Rabinovich's original code does this.
2) This was specifically written for Daily resolution, and the logic relies on ‘OnData’ being called daily (because we update our rolling windows when this is called). Next steps for this algo should be to modify it to use minute resolution with daily consolidation, and update rollingwindows only after the consolidated daily bar is formed (not in OnData, which would now fire every minute). Nitay Rabinovich's unives
 

Author