Profile Picture

Sync Positions Sizes between TWS and RightEdge

Posted By alpha23 7 Years Ago
Posted Thursday December 13 2012
Would it be possible to include code to sync sizes between TWS and RightEdge for the same position? While there are various discussions about TWS/RightEdge syncronization, a method to accomplish this will help. I'm unsure how to specifically accomplish in the TWS plugin but when the sizes are out of sync, other issues arise.

Thanks, Duane
Posted Sunday December 23 2012
Well, first of all if I'd recommend trying to avoid getting out of sync in the first place. So try to identify why it got out of sync and then fixing that problem (and of course you can ask us for help if necessary).

That said, the simplest way to re-sync the positions is to stop the system, run a script that modifies the live open positions list, and restart the live system (this post describes how). The current size of the system is based on the fills received, so you would add a completed trade to the position you want to adjust.

When running live, the concept is the same- you need a fill for RightEdge to change the position size. So you would submit an order for the change in size you want, but set a flag (ie in the CustomString or Tag properties) that would tell your broker plugin not to send it onto TWS but to send a fill message for it immediately instead.

Does this help?

Posted Monday December 24 2012

   I’m not intentionally attempting to get out of sync but it happens whenever there is a disconnect between RightEdge and TWS. This can occur when an exception is thrown, internet connectivity is lost, power is lost, etc.

I appreciate the work you put into the live open positions code; however, per my other posts this should really only be used as a backup, although a very important backup. The underlying synchronization problem should be addressed.

One solution would be to look at the orders, pending and filled, in TWS and adjust the orders in RightEdge to reflect what is in TWS. A string in the IB OrderReference can be used to indicate orders filled via a RightEdge system versus discretionary trades placed in TWS. Since the OrderReference can be set in the TWS order ticket, it additionally allows discretionary trades of a RightEdge system to be entered via the TWS interface - an added benefit to all RightEdge users since the TWS interface is comprehensive. It is also a great selling point because I’m not aware of other trading platforms that have this level of integration with TWS.

Does the utility to modify the LiveOpenPositions file work when the system is running? If yes, I could modify my own code to handle the re-sync but since I have proprietary code included as well, it would not benefit everyone that uses RightEdge. It would be better if the code was implemented by the RightEdge team. I use IB daily and would be happy to test against my systems.

Let me know your thoughts.

Thanks, Duane
Posted Saturday June 15 2013

To add to the discussion I've attached a document describing my solution to the synchronisation issue. Maybe it can inspire RE development to further improve the synchronisation functionality in one of the upcoming versions.

My solution uses an adapted TWSPlugin where correction orders update RE positions without IB positions being changed.



RightEdge - Synchronize with IB.pdf (503 views, 319.00 KB)
Posted Monday June 24 2013
That looks great! Would you be able to publish the code under the MIT Open Source License so that others can use it and we can potentially include it in RightEdge?

Posted Tuesday June 25 2013
Hi dplaisted,

Of course , anyone can use the code snippets as detailed in my document "Rightedge - Synchronize with IB.pdf" under the  MIT Open Source License.

Thats's the purpose of posting it here.



Posted Friday June 28 2013

Thank you for posting. I haven't yet implemented but it appears to be well thought out. I, and I'm sure everyone else using RightEdge/IB, very much appreciate the work you did.


Edited: Friday June 28 2013 by alpha23
Posted Sunday February 15 2015
This is a great topic... We are working on our own broker plugin right now, and of course broker sync is a critical component.  I'm posting here to see if anything has changed as of now, Feb 2015.  

Has someone implemented the approach described in the very professionally-written document by Roedies?  Or perhaps someone has implemented the procedure for modifying the LiveOpenPositions.xml file?  If you have experiences and/or opinions to share, I'd be happy to see them.  We'll start working on our own implementation soon, and anything the community can share would be helpful.  We can share back our own learnings if people are interested.

We are concerned with a few situations:
1) RightEdge occasionally loses contact with the broker (due to network issues or whatnot), so we need to write code to check the broker "heartbeat" and re-connect if it goes quiet.  Re-syncing should be done automatically in a sensible way.
2) Sometimes we shut down the platforms during the session, close some positions manually, then restart.  We need to handle this type of re-sync as well, probably with user input to update RE as needed.
3) We're running multiple auto-trading platforms which trade the same account.  So it's absolutely normal to expect that trades will be made in the account by a platform other than RightEdge, and we need a procedure to make sure things don't get confused.  

In each case, we need our RE system to resume managing the open positions that it "owns".

Thanks in advance...

Similar Topics

Reading This Topic

2005-2019 © RightEdge Systems