I'm also working on my own trading system, and I want to tackle this problem using the NASA way - have multiple pieces check each other.
So I will have a second independent little process which will also connect to the same trading account and monitor simple things, like ensuring the total net position does not go over a certain limit, or that there are no more than N orders in 10 minutes for example, or more than M positions open simultaneously. You can also check that the actual open positions correspond to what the strategy process thinks it actually holds. As a bonus you can run this checker process on a different machine/network provider.
Besides the checks in the main strategy, this will ensure that whatever weird bug occurs, nothing really bad can happen.
You can also download RightEdge and look inside the SDK help file. It has lots of classes for handling stuff like Position, BrokerInterface or Strategy. I looked at these interfaces to get a feel of how you go around designing such a piece of code.
EDIT: My approach would have avoided this situation, when an algo went insane: http://arstechnica.com/business/new...se-click-choked-the-nyse-cost-a-bank-150k.ars
So I will have a second independent little process which will also connect to the same trading account and monitor simple things, like ensuring the total net position does not go over a certain limit, or that there are no more than N orders in 10 minutes for example, or more than M positions open simultaneously. You can also check that the actual open positions correspond to what the strategy process thinks it actually holds. As a bonus you can run this checker process on a different machine/network provider.
Besides the checks in the main strategy, this will ensure that whatever weird bug occurs, nothing really bad can happen.
You can also download RightEdge and look inside the SDK help file. It has lots of classes for handling stuff like Position, BrokerInterface or Strategy. I looked at these interfaces to get a feel of how you go around designing such a piece of code.
EDIT: My approach would have avoided this situation, when an algo went insane: http://arstechnica.com/business/new...se-click-choked-the-nyse-cost-a-bank-150k.ars