cTrader

AlgoWay Blog

Guides, manuals and platform references.

Core
JSON & Alerts
MT5 / Expert Advisors
Errors
Integrations
Other Publications
AlgoWay Strategy Lab

IOC, FOK and GTC Orders: Time in Force and Partial Fills

Three order tickets showing partial fill, full fill and a resting order

A canceled order can leave you with a position. If part of an immediate-or-cancel order executes, canceling the remainder does not undo the shares or contracts already bought. That distinction is the reason to understand time in force before treating an order-status label as an account balance.

IOC accepts an immediate partial fill, FOK requires an immediate complete fill, and GTC allows an order to keep working subject to the broker's rules. In automated trading, these choices determine whether a signal leaves no position, a smaller position or an unfilled order that may execute later.

When designing a workflow around AlgoWay's TradingView-to-Interactive-Brokers guide, separate the intended trade from the destination's accepted order and execution reports. This article explains order semantics; it does not establish that every time-in-force option is exposed by every AlgoWay route. Check the selected integration's documented controls rather than adding an assumed field to a webhook message.

Price and lifetime answer different questions

A buy limit sets the highest acceptable execution price; a sell limit sets the lowest. It does not promise execution. Investor.gov's order-type explanation distinguishes those price constraints from market and stop orders. Time in force adds instructions about how long an order can work and, for IOC or FOK, what immediate execution is acceptable.

InstructionImmediate partial execution?Unfilled quantity
IOC: immediate or cancelAllowedCanceled immediately
FOK: fill or killNot allowedEntire order canceled unless immediately filled in full
GTC: good till canceledAllowed unless other conditions prevent itCan keep working until filled, canceled or expired under broker rules

These definitions follow IBKR's order reference. Availability depends on the product, venue and order combination. GTC also does not itself grant permission to trade outside regular hours.

One limit price, three possible account states

Suppose an account has no position and sends a limit buy for 12 shares at $25.00. Assume exactly five shares are immediately executable at or below that limit, with no other eligible liquidity. Ignore fees and assume the venue supports the selected instruction. This is a constructed example, not an observed order.

  • With IOC: five shares fill; seven are canceled. The account now holds five shares and has no working remainder from that order.
  • With FOK: the required 12 shares cannot fill immediately, so the whole order is canceled. The account remains flat.
  • With an ordinary GTC limit: five shares may fill while seven remain working. Those seven might fill later or never fill.

The three outcomes require different next actions. If a bot blindly resends the original 12-share instruction after the IOC cancellation and that new order fills completely, the account reaches 17 shares. A retry intended to “finish” the trade has exceeded the original target by five.

If the desired final holding is still 12 shares, the unfilled requirement in this example is seven. Before sending even that amount, reconcile current holdings and any other working orders. With the GTC version, submitting seven more while the old seven remain active creates a second path to excess exposure.

GTC is persistent, not immortal

IBKR documents automatic GTC cancellation rules, including expiry at the end of the calendar quarter following the quarter of submission and certain corporate actions. Check the displayed expiry rather than reading “good till canceled” as a promise of indefinite life. Other brokers can use different policies.

There is another distinction: all-or-none is not the same as fill-or-kill. IBKR describes AON orders that can wait for the full quantity; FOK adds the requirement for immediate completion. A quantity condition and a lifetime condition should not be guessed from similar-sounding names.

Session eligibility needs its own check. For example, Alpaca's order documentation treats extended-hours eligibility and permitted order/time-in-force combinations separately. A long lifetime cannot make an otherwise ineligible order executable in every session. Our guide to limit orders that touch but do not fill covers the price, queue and session questions in more detail.

Specify what the automation should do next

Write the response policy before choosing an abbreviation:

  1. After a partial fill: is the smaller position acceptable, should the remainder be attempted again, or should the strategy abandon the setup? Include a limit on retries and a deadline for the original signal.
  2. While an order rests: which event makes the old instruction stale? Examples to define include a new opposite signal, the end of the strategy's entry window or a changed target position.
  3. Before a replacement: confirm the old order's final state and filled quantity. A request to cancel is not a reason to assume no further reconciliation is needed.
  4. For protective exits: base the intended protection on the actual position. A requested entry quantity is not proof that the full quantity was acquired.

For a paper test, record requested size, filled size, remaining size, final status and resulting position for each scenario your environment can produce. Paper fills are not evidence of live liquidity. The useful check is whether your workflow handles the reported state correctly, including a partial fill followed by cancellation. An order can be finished while the trade it created is very much alive.

Last updated: October 11, 2026