What I have so far...
Error checks
This algo will initiate the following error checks while the algo is in session (within Time start and Close time. After the alert, perform the action.
The following scenarios can happen in a live market environment. Orders go from “In Transit” to “Working” in live trading. Sometimes, there may be latencies as well that can cause these errors to occur. If they happen, check for errors and perform the action:
Error checks
This algo will initiate the following error checks while the algo is in session (within Time start and Close time. After the alert, perform the action.
- NO STOP OR NO TARGET- A position has no stop or target or both (naked position)
- Action: Resend the missing target or stop loss orders.
- PHANTOM ORDER - Open orders that are still active after the position is already flat.
- Action: Cancel all orders.
- INCORRECT STOP LOSS OR TARGET LOTS - Lot quantity for stop loss and target does not match the open position lots.
- Action: Cancel orders and resend new orders to match the open position lots.
- DUPLICATE INITIAL STOP ORDERS - Algo sends out duplicate stop orders (instead of just 1 buy/sell stop orders, there are 2x buy/sell stop orders.
- Action: Cancel all orders and resend orders per the rules.
The following scenarios can happen in a live market environment. Orders go from “In Transit” to “Working” in live trading. Sometimes, there may be latencies as well that can cause these errors to occur. If they happen, check for errors and perform the action:
- Delayed orders:
- Example: Buy stop order has executed, but the sell stop order is still in Transit and placed later (therefore has not been canceled per rules leaving it open).
- Action: Cancel the sell stop order since buy stop order is already triggered
- Stop order is executed, but as the target is being placed (in Transit), price has already crossed the target.
- Action: Exit the position at market since the price is already at target price
- Example: Buy stop order has executed, but the sell stop order is still in Transit and placed later (therefore has not been canceled per rules leaving it open).
- VPS/internet disconnection
- Action: check to make sure the above errors did not trigger. If it does, perform the respective actions.