Horizon Advanced Orders
Horizon provides synthetic advanced order types managed entirely by the engine. Stop-losses, take-profits, bracket orders, and OCO links are not sent to the exchange. They live in-engine and fire through the normal risk pipeline when triggered.Contingent orders (stop-loss, take-profit) are evaluated every tick via
engine.check_contingent_triggers(). When using hz.run(), this is called automatically. If you manage the loop yourself, you must call it explicitly.Core Concepts
Contingent Orders
Synthetic orders that wait for a trigger condition before submitting to the exchange. They go through the full risk pipeline when fired.
OCO (One-Cancels-Other)
Two contingent orders linked together. When one triggers, the other is automatically canceled.
Bracket Orders
An entry order paired with a stop-loss and take-profit, automatically linked as OCO.
Order Amendment
Modify price or size of a live order. Paper exchange amends in-place; live exchanges do cancel + resubmit.
Types
TriggerType
ContingentOrder
Each contingent order exposes the following fields:Trigger Logic
Understanding when contingent orders fire is critical.- Stop-Loss
- Take-Profit
Stop-losses protect against adverse price movement.
Engine Methods
add_stop_loss
add_take_profit
trigger_price and trigger_pnl are set, the order fires when either condition is met.
submit_bracket
(entry_id, sl_id, tp_id). The SL and TP are automatically linked as OCO.
check_contingent_triggers
hz.run().
cancel_contingent
True if the order was found and canceled, False if it was already triggered or not found.
pending_contingent_orders
amend_order
- Paper Exchange
- Live Exchanges
Amends the order in-place and returns the same order ID. The order’s
amendment_count is incremented.Examples
Standalone Stop-Loss
1
Set up the engine and enter a position
2
Add a stop-loss to protect the position
3
Check triggers on each tick
Bracket Order
A bracket order is the most common advanced order pattern: enter a position with automatic downside protection and profit target.Automatic OCO via Bracket
Usesubmit_bracket() to automatically link stop-loss and take-profit as OCO. When one triggers, the other is auto-canceled.
Inspecting Pending Orders
Amending Orders
Using Advanced Orders in hz.run()
When usinghz.run(), contingent triggers are checked automatically. You can set up contingent orders inside your pipeline functions.