Not sure what strikes you as so impossible about this, sounds straightforward and simple to me. As for auto logout, the gateway is the answer. @Timetwister , let me know if you need help in a PM
This is not necessary, you don't need to to this manually. There is a way in IB's API to get the expiry date of a futures contract. Knowing the expiry date, and today's date, your software can calculate the number of days remaining. No manual action required.