Debugging some strange issues with an implementation of a custom Risk Model in the Framework - attached a simple example algorithm below.

Expected behavior:

  • Every Monday, emit an insight to Long EURUSD with duration 1 week
  • Portfolio Model computes quantity (100% of portfolio value) and returns array of targets
  • Risk Model checks for drawdowns in portfolio value (set to a very small number in example), and liquidates positions
  • Portfolio should be fully liquidated for the rest of the week until the next insight emission
Actual behavior:
  • Logs confirm that the drawdown is being hit, and is returning PortfolioTarget(symbol, 0). However, the algorithm remains invested.
  • Only a single order was placed at algorithm start despite Risk Model being triggered. Expecting place order, liquidate, do nothing for rest of week, then repeat every week.
Sample Logs:2015-01-06 04:44:00 Risk Model triggered with realized -0.00% drawdown. Liquidated. 2015-01-06 04:45:00 Risk Model triggered with realized -0.00% drawdown. Liquidated. 2015-01-06 04:46:00 Risk Model triggered with realized -0.00% drawdown. Liquidated. 2015-01-06 04:47:00 Risk Model triggered with realized -0.00% drawdown. Liquidated.

This is related to thisĀ discussion, where Derek's answer implied that the Risk Model should be continuously returning PortfolioTarget(symbol, 0) once liquidated to achieve the expected behavior. Anyone see where the potential issue may be?