Back to list
TheHaywire

execution-hooks

by TheHaywire

Algorithmic trading system for MetaTrader 5

1🍴 1📅 Jan 17, 2026

SKILL.md


name: Execution Hooks description: Pre-trade risk gates and post-trade audit actions for institutional compliance.

Execution Hooks Skill

This skill provides the "Gate Keeper" logic for the Titan system. All trades MUST pass through these hooks to ensure institutional-grade risk management.

1. Pre-Trade Hook Protocol

Before ANY order is sent to MT5, run the pre-trade gate:

python .agent/hooks/pre_trade.py --symbol GOLD --direction BUY --lots 0.1

Checks Performed

CheckPurposeBlock Condition
HEARTBEATSystem healthStatus ≠ HEALTHY
MACRO_FILTERNews environmentVerdict = BLOCK
KELLY_SIZINGPosition limitsLots > Kelly × 1.5
TRADING_HOURSMarket calendarWeekend = True

Response Format

{
  "gate": "PASS" or "BLOCKED",
  "checks": [...],
  "reason": "Explanation if blocked"
}

If gate returns BLOCKED, you MUST:

  • Document the blocking reason
  • DO NOT proceed with order placement
  • Recommend waiting for conditions to clear

2. Post-Trade Hook Protocol

After ANY order is filled, run the post-trade actions:

python .agent/hooks/post_trade.py --symbol GOLD --direction BUY --lots 0.1 --entry 2650.0 --filled 2650.5 --ticket 123456

Actions Performed

ActionPurpose
TCA_ANALYSISCalculate slippage and assign grade (A/B/C)
AUDIT_LOGLog to institutional audit trail
ADAPTIVE_EXITRegister position for dynamic management
NOTIFICATIONQueue alert for monitoring

TCA Grading

GradeSlippage %Interpretation
A< 0.01%Excellent execution
B0.01% - 0.05%Acceptable
C> 0.05%Review broker quality

3. Integration with Orchestrator

The titan_orchestrator.py automatically calls both hooks when using --action execute:

python titan_orchestrator.py --action execute --symbol GOLD --direction BUY --lots 0.1

This single command:

  1. Runs pre-trade gate
  2. If PASS, sends order to MT5
  3. Runs post-trade actions
  4. Returns full execution report

Core Tools

  • pre_trade.py: Risk gate before order placement
  • post_trade.py: TCA and audit after order fill

Dependencies

  • mt5_bridge/scripts/heartbeat_monitor.py: For system health
  • data_intelligence/scripts/macro_context.py: For news filter
  • factor_risk/scripts/dynamic_kelly_allocator.py: For sizing limits
  • mt5_bridge/scripts/audit_trail_manager.py: For logging

Score

Total Score

60/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon