Sell To Open twice bug?

In my stock system,I will close all trade at 15:59. And for fail-safe, I arranged an auto-close at 15:59.
A bug occured yestoday. A position has been STC for twice. And the second STC has been calculate to the profit. Here is the trade log:
1058944889/15/16 9:32BTO1,968XCRA 5.55
1059057919/15/16 15:59STC1,968XCRA 5.66
1059057929/15/16 15:59STC1,968XCRA 5.66
Auto-close 15:59
I hope you can fix the bug and correct my system profit.
And another question is, If I follow my system in IB, and two STC order has sended to IB. Would the second STC order turn to Sell Short to the market?

Looks like what you are trying to do is as follows:

  1. You are using the C2 API, and your own software program sends signals to close specific trades at 15:59 ET.

  2. And you ask C2 to “auto-close” positions at the same exact instant in time, 15:59 ET.

That’s generally not a good idea.

Don’t try to do the same thing twice, simultaneously.

If you want to rely on C2’s own internal “close all positions at time X” feature as a safety measure, that’s fine, but schedule it for at least 1 minute later than whenever you close your own positions using the API. (This implies you will need to move your own API actions a bit earlier; perhaps by one minute or .5 minutes).

Regarding your question about autotrading: it is conceivable that in cases like this, where signals arrive simultaneously from two different sources, that they can indeed step on each other, so that an extra trade is made. C2’s “AutoSync” will clean up the mess, automatically – however, in cases like these (when the problem happens at 15:59 ET, right before market close), it might have to wait for the next market opening time.

Finally, I have fixed the incorrect trade PL calc. It may take a few minutes to show up in your browser.

Thank you for reply and fix the PL calc.