Logo Conditional Order Logic For Execution Triggers

Conditional Order Logic For Execution Triggers

Cộng đồng
HimanshuJ16
conditional-order-logic-for-execution-triggers

Use when implementing client-side conditional orders such as if-touched, bracket, one-cancels-other or cross-asset triggers, evaluating a nested Boolean tree against market data and releasing each child exactly once.

Tổng quan

Nhà phát hànhHimanshuJ16
Kho mãAlgo-Trading-Skills
Tên kỹ năngconditional-order-logic-for-execution-triggers
Sao
50
Bản fork
7
Tệp đi kèm
5
Giấy phépApache-2.0
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 5 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được HimanshuJ16 công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Conditional Order Logic For Execution Triggers trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/HimanshuJ16/Algo-Trading-Skills/tree/main/skills/conditional-order-logic-for-execution-triggers
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/HimanshuJ16/Algo-Trading-Skills.git /tmp/Algo-Trading-Skills
mkdir -p .claude/skills
cp -r /tmp/Algo-Trading-Skills/skills/conditional-order-logic-for-execution-triggers .claude/skills/conditional-order-logic-for-execution-triggers
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Conditional Order Logic For Execution Triggers trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Conditional Order Logic For Execution Triggers ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Conditional Order Logic For Execution Triggers với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

When to Use

Use this skill when implementing client-side conditional order logic (If-Touched, bracket, One-Cancels-the-Other, or cross-asset triggers) in an OMS/EMS. Conditional orders remain dormant in local memory until incoming market data evaluates a nested Boolean condition tree to TRUE, upon which child orders are released for pre-trade risk checking and venue routing.

Client-side simulation is the right answer when the trigger the strategy needs does not exist at the venue or the broker: a condition spanning two instruments, a condition mixing price with volume and wall-clock time, or a trigger on an exchange that does not accept the order type at all. NYSE and NYSE MKT stopped accepting stop orders and GTC orders on 26 February 2016 and cancelled the resting ones, so equity stop logic on those books lives in a broker's or a client's simulator, not on the exchange.

When NOT to Use

  • A native or broker-resident conditional order does the same job. IBKR's conditional orders support price, time, margin, execution, volume and percent-change conditions combined with AND/OR, and IBKR states that active orders remain active after exiting Trader Workstation — you can be filled without being logged in. CME Globex triggers stop orders natively against the last trade price. A broker- or exchange-resident trigger survives your process crashing, your feed dropping and your host rebooting. This engine survives none of those: if the process is down when the market touches the level, nothing fires and nothing tells you so. Prefer native; simulate only what native cannot express.
  • Latency-sensitive triggering against fast markets. A client-side trigger fires one network round trip after the price prints, then the child order still has to travel to the venue. For stop logic on a fast-moving book, an exchange-resident stop (with protection points, where the venue offers them) fills closer to the level.
  • As a risk control. A kill switch or exposure limit must not depend on a condition tree that goes quiet when the data feed dies. Keep circuit breakers in a path that fails closed — see execution-algorithm-kill-switch-integration.
  • On an instrument that may be halted or in an auction. A dormant trigger evaluating a stale pre-open or halted book will fire on the first print of a re-opening auction. Gate the tree with an explicit session/state condition; see execution-algo-behavior-under-halted-instrument.

Prerequisites

  • Streaming market data for the target instrument and every referenced benchmark, each quote carrying a timestamp (epoch seconds, UTC) if staleness enforcement is wanted.
  • A decision on the trigger price type per condition — last trade, bid, ask, or mid. FIX TriggerPriceType(1107) enumerates exactly this choice (Best Offer, Last Trade, Best Bid, Best Bid or Last Trade, Best Offer or Last Trade, Best Mid), and it changes when the trigger fires.
  • A unique client order identifier and a fully specified child order (symbol, side, quantity, order_type, price for limits).
  • A downstream pre-trade risk check: a fired trigger emits an intent, not an authorised order.

Workflow

  1. Condition Tree Construction: Build atomic nodes — PriceCondition, VolumeCondition, TimeCondition, CrossAssetCondition — and compose them with AndCondition / OrCondition / NotCondition. Choose the price field deliberately (last vs bid vs ask): a >= trigger read off the bid and one read off the last trade fire at different moments on the same tape. Empty composites are rejected at construction, because an empty AND gate is vacuously true and would fire on the first tick.
  2. Staleness Policy: Pass max_quote_age_seconds to any condition whose input can go stale — always to cross-asset legs, whose benchmark feed can disconnect while the primary keeps ticking. With it set, a quote whose timestamp is missing or older than the limit evaluates to UNKNOWN, not to a value.
  3. Conditional Order Registration: Wrap the tree and a validated ChildOrderPayload in a ConditionalOrderTrigger, then ConditionalOrderEngine.register(trigger, oco_group=...). Triggers sharing an oco_group are one-cancels-the-other; a bracket registers its target and its stop in one group so both legs cannot reach the venue.
  4. Tick Processing: Call engine.process_tick(market_state, now=...) on each update. The engine pins one evaluation clock for the whole tick, so a time condition cannot read a different instant than its siblings in the same tree.
  5. Trigger Firing and Dispatch: The engine returns the child orders released by this tick. Firing is a single atomic DORMANT → TRIGGERED transition under a lock — evaluation and state change happen together, so two feed-handler threads delivering the same tick cannot both release the order. On fire, dormant OCO siblings are cancelled.
  6. Undecided is not false: The tree evaluates in three-valued (Kleene) logic. A missing or stale input yields UNKNOWN; only a definite TRUE fires. Route UNKNOWN to monitoring — a trigger that has been undecided for minutes means a feed is down, and it will not fire when the level trades.

Full procedure: see references/workflows.md. Standards reference: see references/standards.md. Printable pre-flight checklist: see assets/checklist.md.

Common Pitfalls

  • Firing duplicate orders: Checking status == DORMANT and setting TRIGGERED as two separate steps. Two threads can interleave between the check and the set and both release the child order. Evaluate and transition under one lock.
  • Treating missing data as False: Under two-valued logic a missing quote reads as FALSE, so NotCondition(missing) reads as TRUE and releases a live order on data you never received. Negation is where a fail-safe FALSE stops being safe.
  • A dropped benchmark silently rewriting the trigger: AAPL >= 150 AND SPY >= 500 with the SPY feed dead is not "wait"; under two-valued logic it is a permanent FALSE that never fires, and if the composition is OR it becomes a bare AAPL >= 150 outright trigger. Set max_quote_age_seconds on cross-asset legs and alert on UNKNOWN.
  • Exact float equality as a trigger: last == 150.00 against a decimal price feed effectively never matches. Use a band with an explicit tolerance, or an ordering operator.
  • Silently ignoring an unknown operator: Returning False for a typo'd '=>' produces a trigger that can never fire and reports no error — discovered when the order never arrives. Validate operators at construction.
  • Naive datetimes in time conditions: A trigger meant for 15:50 New York fires at 15:50 in whatever zone the host happens to be in. Require timezone-aware targets.
  • Confusing the trigger price type: Simulated triggers only fire on the field you feed them. IBKR's trigger methods exist for the same reason (double bid/ask, last, double last, bid/ask, last-or-bid/ask, mid-point) and apply only to simulated orders — a natively handled stop ignores them entirely.
  • Blocking the hot path: Heavy parsing, disk I/O or network calls inside the market-data callback that evaluates the tree. Keep evaluation to arithmetic on already-parsed values.
  • Treating a fired trigger as a fill: The trigger produces an order intent. It still has to pass pre-trade risk, reach the venue, and be accepted — and it can be rejected.

Verification

  • Build (AAPL.last >= 150.00) AND (SPY.last >= 500.00) on a ConditionalOrderEngine. Feed AAPL 150.50 / SPY 499.00: the trigger must stay DORMANT and process_tick must return []. Feed SPY 500.50: it must transition to TRIGGERED and return exactly one child order payload; a third tick must return nothing.
  • Register a bracket as one oco_group and drive the take-profit level: the stop-loss leg must be CANCELLED and must stay silent when its own level trades afterwards.
  • Drive one satisfying tick from 16 threads concurrently and assert exactly one payload is released.
  • Feed a cross-asset tree with the benchmark quote removed and confirm evaluate_tristate returns None (UNKNOWN), not False, and that NotCondition over it does not fire.
  • Set max_quote_age_seconds=5.0 and feed a quote timestamped 30 seconds ago: no fire, and a stale-quote warning logged.
  • Run python -m unittest discover -s skills/conditional-order-logic-for-execution-triggers/scripts and confirm a 100% pass rate.

Related Skills

  • broker-order-type-capability-matrix
  • execution-algorithm-kill-switch-integration
  • execution-algo-behavior-under-halted-instrument
  • order-placement-idempotency
  • close-auction-participation-strategy

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Conditional Order Logic For Execution Triggers làm được gì?

Use when implementing client-side conditional orders such as if-touched, bracket, one-cancels-other or cross-asset triggers, evaluating a nested Boolean tree against market data and releasing each child exactly once.

Vì sao nên dùng Conditional Order Logic For Execution Triggers trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Conditional Order Logic For Execution Triggers là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Conditional Order Logic For Execution Triggers trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/HimanshuJ16/Algo-Trading-Skills/tree/main/skills/conditional-order-logic-for-execution-triggers. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Conditional Order Logic For Execution Triggers?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Conditional Order Logic For Execution Triggers với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Conditional Order Logic For Execution Triggers với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Conditional Order Logic For Execution Triggers có miễn phí không?

Có. Kỹ năng này được HimanshuJ16 phát hành trên GitHub theo giấy phép Apache-2.0. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇