The eternal non-solved issue yet of syncing accounts when connection-loss has created more posts than any other from years ago and still is around.
A very easy solution to implement for developers, would be a simple "Info poll from broker's account", compare it to strategy position and submit live orders to equalize them, like it's done from "start a strategy when accounts are selected to be synced with immediately submit live working historical orders".
While there's no a definitive solution, I'm trying to workaround it through some procedure. For a non very advanced programmer is not an easy task. So far I have this simple snippet to be at least informed of the "sync status"
foreach (Account acct in Cbi.Globals.Accounts) { if ( acct.Name == "xxxx") { PositionCollection positions = acct.Positions; foreach (Position pos in positions) { if (pos.Instrument.FullName == "$EURUSD") { if ( Position.MarketPosition != pos.MarketPosition || Position.Quantity != pos.Quantity; ) { SendMail ("[email protected]", "[email protected]", "ALARM: UNSYNCED ACCOUNTS! ", Position.MarketPosition.ToString() + " " + Position.Quantity.ToString()+" Versus IB " +pos.MarketPosition.ToString()+ " " + pos.Quantity.ToString()); } } } } }
Now, questions:
1. Once the "out of sync" is detected by the Strategy, could it be possible to design an automatic procedure to submit immediate live orders that didn't affect the actual Strategy Position ?
I don't ask for a source code, just to know if there's a possibility to do it. So far it seems than any automatic order that was submitted, immediately will change the Strategy position.
2. I'm aware that actually after a connection-loss, there's not any broker's account poll, BUT if previous disconnection, the Strategy submitted a live working order, and let's suppose that this was filled, when the connection is re-established, will NT at least to match that Order Status so my Strategy updates positions ?
Thanks a lot in advance
Comment