Keyboard Shortcuts
ctrl + shift + ? :
Show all keyboard shortcuts
ctrl + g :
Navigate to a group
ctrl + shift + f :
Find
ctrl + / :
Quick actions
esc to dismiss
Likes
Search
Get and close all positions at a specific time
Take a look at the of the API Reference Guide. When you place orders, you can also use to attach a condition for when the order should become active. One such condition is the TimeCondition which allows you to place an order sometime throughout the day but that does not become active until 3:45pm (or any other time). ´³¨¹°ù²µ±ð²Ô |
Nick
¿ªÔÆÌåÓýYou could have the exit orders in an OCA group and add one more
to buy/sell at market with a "good after" time of 3:45. On 10/20/2021 3:38 PM,
movais996@... wrote:
|
Thanks Jurgen!
I saw your approach and it's a really good one. However my use-case turned out to be really straight forward (cancel all api and tws orders and close all positions at 3:45). So I ended up using reqGlobalCancel() for cancelling orders and reqAccountUpdated() alongwith updatePortfolio() to get positions on each entity and place orders opposite to positions.?? |
Your approach will work most of the time, but things do go wrong and you exposure yourself to some degree of risk that your orders and positions do not get closed and will stay open past the end of the trading session:
´³¨¹°ù²µ±ð²Ô |
to navigate to use esc to dismiss