Skip to main content

Order Execution

Position sizing

Always size before you trade. The size_position tool calculates safe share count from three constraints:
Returns: share count, dollar risk, capital used, margin impact.

Order types

Simple order

The bracket creates three linked orders:
  1. Entry — your entry order
  2. Take profit — limit sell at target (OCA-linked to stop)
  3. Stop loss — stop order at invalidation (OCA-linked to TP)
When either TP or SL fills, the other auto-cancels via OCA group.

Trailing stop bracket

Or use fixed trailing amount:

Modifying orders

Use modify_order to change price/quantity on an existing order without breaking bracket links:
Never cancel and re-place bracket legs — this breaks the OCA group. Always use modify_order to preserve bracket integrity.

Order management

Session guardrails

The session risk gate tracks:
  • Daily P&L — locks trading at max daily loss
  • Trade count — limits trades per session
  • Consecutive losses — cooldown after loss streaks
Check with session_state. Manual lock: session_lock. Reset: session_reset.