Skip to content

C6 — Partial fills are not tracked as a distinct state #446

Description

@eaitbrahim

PRD §3 C6.

Today

keel models market-IOC orders as fill-or-reject. keel/execution/reconcile.py polls resting orders and tracks pending → filled/canceled terminal states, upgrading recorded fill price and fees from estimated to venue-observed — but nothing distinguishes a partial fill as its own condition.

Competitors

Freqtrade tracks partial fills as first-class state, with an order_filled() callback firing on partial or full fills and an average entry price maintained across multiple fills. Jesse has a PARTIALLY FILLED order status in its order state machine.

Why it matters here specifically

Two keel-specific consequences, both on the live-money path:

  1. Sizing assumes the full quantity filled. qty = (equity × risk_pct) / |entry − stop|, and the bracket is placed for that quantity. A partial entry fill leaves a bracket sized for more than is held.
  2. Rail 8 (no averaging into losers) compares against the position's average cost basis. A partially-filled entry whose remainder is never recorded gives a wrong basis, and the rail then makes its decision on it.

Scope

  • Recognise partial fills in reconciliation as a distinct, non-terminal state.
  • Maintain an average entry price across fills.
  • Decide the bracket policy on a partial entry: amend to the filled quantity, or cancel and re-place. Note the broker port carries no bracket/OCO order kind (Coinbase's native bracket bypasses the port entirely), so this may be blocked on a port change — establish that first.
  • Confirm rail 8's basis calculation is correct under partial fills.

Prerequisite

Establish how often this actually occurs. keel places market IOC orders on liquid spot pairs at small notional, where partial fills should be rare — this may be a correctness gap that almost never fires, which changes its priority but not its validity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions