Quote from Mike805:
Thanks for this - very useful information.
I am still having trouble synching on events, is there any difference in the TWS demo versus the real thing? It seems that no matter what I do, the portfolio update either takes a very long time, or, the request updates call doesn't return. Not sure what to do...
In general, maybe you guys can recommend a course of action as I'm spending too much time on this already?
I have an existing risk manager Excel spreadsheet that is key to my operation; it basically parses all trade signals from my signal generation system, assigns allocation amounts and then sends orders to TWS for execution.
What I would like to see are a set of functions incorporated in this sheet that do the following:
1. Close 50% of the portfolio of either the following:
--Close 50% of all longs : adding liquidity on BATS.
--Close 50% of all shorts : adding liquidity on BATS.
--Close 50% of all longs : taking liquidity on SMART.
--Close 50% of all shorts : taking liquidity on SMART.
2. Close 100% of all positions by adding on BATS.
3. Close 100% of portfolio by sending MOC's for all positions.
4. Cancel all open orders.
I am willing to pay for this, or, exchange some of the functionality I've already built up.
Thanks,
Mike
use the activex/excel page for positions in the morning, collect opening day positions to insert in system, then use ONLY ats state positions (incrementing and decrementing during the day on fills, not querying ib server). if you have accurate updated positions, set up a vba clock in your main function:
If time > #3:59:00 PM# Then
#turn off enableevents, screenupdating, calculation
closePositions
turnATSOFF
End If
this routine grabs your orders, cancels them, and submits the orders you're talking about. if your system already submits orders, this should be trivially easy to implement. the key, however, is to make sure the system shuts off BEFORE you run your mass cancel / modify. you'd hate to have the system recursively react to your own shutdown actions.

300").ClearContents