[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79BYECV2VNQ5BC3R6DRC669":3,"skill-same:01M79BYECV2VNQ5BC3R6DRC669":48},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M79BYECV2VNQ5BC3R6DRC669","fix-protocol-financial-trading",null,"Master high-frequency FIX (Financial Information eXchange) protocol messaging (FIX 4.2\u002F4.4\u002F5.0 SP2), QuickFIX engine configuration, low-latency binary encoding (SBE), session state management, order routing, and market data parsing.","hamzabellouch\u002Fagent-skills","hamzabellouch","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F237856042?v=4","01M79BRYW7XAMK3YDWQEMTWGWS","Hamza Bellouch","01M79BRYWXQV3JK2TGVTX8GN2A",8,"MIT","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FBusiness\u002FFintech_and_Accounting\u002FFinancial_and_Payment_Gateways\u002Ffix-protocol-financial-trading\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: fix-protocol-financial-trading\ndescription: Master high-frequency FIX (Financial Information eXchange) protocol messaging (FIX 4.2\u002F4.4\u002F5.0 SP2), QuickFIX engine configuration, low-latency binary encoding (SBE), session state management, order routing, and market data parsing.\n---\n\n# FIX Protocol Financial Trading & Messaging Architecture\n\nThis skill package defines enterprise standards for high-frequency financial trading systems, order management systems (OMS), and execution management systems (EMS) utilizing **FIX (Financial Information eXchange)** protocol versions 4.2, 4.4, and 5.0 SP2 (FIXML \u002F SBE).\n\n---\n\n## 1. Core Session & Application Architecture\n\n### Session Layer Management & Resend Recovery\n- **Session State Persistence**: Maintain strictly synchronized sequence numbers (`MsgSeqNum`, Tag 34) for incoming and outgoing messages. Store session state in memory-mapped files (MMAP) or persistent low-latency disk storage.\n- **Sequence Gap Handling & Recovery**:\n  - When an incoming `MsgSeqNum` is greater than expected, immediately issue a `ResendRequest` (MsgType `2`, Tag 35=2).\n  - Respond to incoming `ResendRequest` messages by re-sending administrative messages as `SequenceReset-GapFill` (MsgType `4`, Tag 35=4, Tag 123 `GapFillFlag=Y`) and re-sending application messages with `PossDupFlag=Y` (Tag 43).\n- **Heartbeat & Test Request Loop**: Send `Heartbeat` (Tag 35=0) at specified `HeartBtInt` (Tag 108) intervals. If no activity is received within `HeartBtInt + Margin`, issue a `TestRequest` (Tag 35=1) with a unique `TestReqID` (Tag 112). Drop session if response is absent.\n\n### Low-Latency Messaging Engineering\n- **Zero-GC & Zero-Copy Memory Management**: Eliminate object allocations on hot execution paths. Utilize ring buffers (e.g., LMAX Disruptor pattern) and pre-allocated byte buffers for message serialization.\n- **Encoding Formats**: Use **SBE (Simple Binary Encoding)** or **FAST (FIX Adapted for STreaming)** for ultra-low latency market data feeds over UDP multicast, replacing legacy tag-value pairs.\n- **Transport Security & Network Topologies**: Enforce mTLS 1.3 or IPsec VPN tunnels across dedicated cross-connects (Equinix NY4, LD4, TY3). Enable `TCP_NODELAY` (disable Nagle's algorithm) and pin thread CPU affinity.\n\n---\n\n## 2. Key FIX Tag Reference Matrix\n\n| Tag # | Field Name | Required \u002F Enum | Description |\n| :--- | :--- | :--- | :--- |\n| **8** | `BeginString` | `FIX.4.2` \u002F `FIX.4.4` \u002F `FIXT.1.1` | Protocol version identifier |\n| **9** | `BodyLength` | Integer | Length of message body between Tag 9 and Tag 10 |\n| **35** | `MsgType` | `D` (New Order), `8` (ExecReport), `2` (ResendReq) | Message type code |\n| **49** | `SenderCompID` | String | Submitting institution identifier |\n| **56** | `TargetCompID` | String | Receiving counterparty\u002Fexchange identifier |\n| **34** | `MsgSeqNum` | Integer (1-based counter) | Message sequence counter |\n| **11** | `ClOrdID` | Unique String | Client assigned unique identifier for order |\n| **55** | `Symbol` | String | Financial instrument ticker (e.g., `AAPL`, `EUR\u002FUSD`) |\n| **54** | `Side` | `1`=Buy, `2`=Sell, `5`=Sell Short | Order side specification |\n| **40** | `OrdType` | `1`=Market, `2`=Limit, `3`=Stop, `P`=Pegged | Order type execution style |\n| **38** | `OrderQty` | Quantity \u002F Decimal | Total quantity of shares\u002Fcontracts |\n| **44** | `Price` | Currency Price | Limit price per unit |\n| **10** | `CheckSum` | 3-digit zero-padded String | Modulo 256 sum of all characters up to `10=` |\n\n---\n\n## 3. Production Code Implementations\n\n### Python Implementation: Production QuickFIX Initiator for Order Routing\n\n```python\nimport sys\nimport time\nimport logging\nimport quickfix as fix\nimport quickfix44 as fix44\n\nlogging.basicConfig(level=logging.INFO, format=\"%(asctime)s [%(levelname)s] %(message)s\")\n\nclass FIXOrderRoutingApplication(fix.Application):\n    def __init__(self):\n        super().__init__()\n        self.session_id = None\n\n    def onCreate(self, sessionID: fix.SessionID):\n        logging.info(f\"Session Created: {sessionID}\")\n\n    def onLogon(self, sessionID: fix.SessionID):\n        logging.info(f\"Logon Successful: {sessionID}\")\n        self.session_id = sessionID\n\n    def onLogout(self, sessionID: fix.SessionID):\n        logging.warning(f\"Session Logged Out: {sessionID}\")\n        self.session_id = None\n\n    def toAdmin(self, message: fix.Message, sessionID: fix.SessionID):\n        msg_type = fix.MsgType()\n        message.getHeader().getField(msg_type)\n        if msg_type.getValue() == fix.MsgType_Logon:\n            # Add Username\u002FPassword credentials for authentication\n            message.setField(fix.RawData(\"SuperSecretAuthToken\"))\n            message.setField(fix.RawDataLength(len(\"SuperSecretAuthToken\")))\n\n    def fromAdmin(self, message: fix.Message, sessionID: fix.SessionID):\n        pass\n\n    def toApp(self, message: fix.Message, sessionID: fix.SessionID):\n        logging.info(f\"Sending Outbound App Message: {message}\")\n\n    def fromApp(self, message: fix.Message, sessionID: fix.SessionID):\n        self._route_app_message(message, sessionID)\n\n    def send_limit_order(self, cl_ord_id: str, symbol: str, side: str, qty: float, price: float):\n        \"\"\"\n        Constructs and sends a FIX 4.4 NewOrderSingle (MsgType D)\n        \"\"\"\n        if not self.session_id:\n            raise RuntimeError(\"Cannot send order: FIX Session not active\")\n\n        order = fix44.NewOrderSingle()\n        order.setField(fix.ClOrdID(cl_ord_id))\n        \n        # Side: 1=Buy, 2=Sell\n        side_val = fix.Side_BUY if side.upper() == \"BUY\" else fix.Side_SELL\n        order.setField(fix.Side(side_val))\n        \n        order.setField(fix.TransactTime())\n        order.setField(fix.OrdType(fix.OrdType_LIMIT))\n        order.setField(fix.Symbol(symbol))\n        order.setField(fix.OrderQty(qty))\n        order.setField(fix.Price(price))\n        order.setField(fix.TimeInForce(fix.TimeInForce_DAY))\n\n        # Send order asynchronously via QuickFIX engine\n        success = fix.Session.sendToTarget(order, self.session_id)\n        if not success:\n            logging.error(f\"Failed to submit ClOrdID: {cl_ord_id}\")\n        else:\n            logging.info(f\"Submitted Limit Order {cl_ord_id} for {symbol}\")\n\n    def _route_app_message(self, message: fix.Message, sessionID: fix.SessionID):\n        msg_type = fix.MsgType()\n        message.getHeader().getField(msg_type)\n\n        if msg_type.getValue() == fix.MsgType_ExecutionReport:\n            exec_id = fix.ExecID()\n            cl_ord_id = fix.ClOrdID()\n            ord_status = fix.OrdStatus()\n            symbol = fix.Symbol()\n            cum_qty = fix.CumQty()\n            avg_px = fix.AvgPx()\n\n            message.getField(exec_id)\n            message.getField(cl_ord_id)\n            message.getField(ord_status)\n            message.getField(symbol)\n            message.getField(cum_qty)\n            message.getField(avg_px)\n\n            logging.info(\n                f\"ExecutionReport Received | ExecID: {exec_id.getValue()} | \"\n                f\"ClOrdID: {cl_ord_id.getValue()} | Status: {ord_status.getValue()} | \"\n                f\"Symbol: {symbol.getValue()} | CumQty: {cum_qty.getValue()} | AvgPx: {avg_px.getValue()}\"\n            )\n\ndef main():\n    settings = fix.SessionSettings(\"fix_initiator.cfg\")\n    application = FIXOrderRoutingApplication()\n    store_factory = fix.FileStoreFactory(settings)\n    log_factory = fix.FileLogFactory(settings)\n    initiator = fix.SocketInitiator(application, store_factory, settings, log_factory)\n\n    logging.info(\"Starting FIX Socket Initiator...\")\n    initiator.start()\n\n    try:\n        while True:\n            time.sleep(1)\n    except KeyboardInterrupt:\n        logging.info(\"Stopping FIX Initiator...\")\n        initiator.stop()\n\nif __name__ == \"__main__\":\n    main()\n```\n\n---\n\n### TypeScript Implementation: High-Throughput Zero-Allocation FIX Parser\n\n```typescript\nexport class FastFixParser {\n  private static readonly SOH = 0x01; \u002F\u002F SOH (Start of Header \\x01)\n\n  \u002F**\n   * Fast zero-copy zero-allocation parser for Tag-Value FIX buffers\n   *\u002F\n  public parse(buffer: Buffer): Map\u003Cnumber, string> {\n    const fields = new Map\u003Cnumber, string>();\n    let cursor = 0;\n    const len = buffer.length;\n\n    while (cursor \u003C len) {\n      const tagStart = cursor;\n      while (cursor \u003C len && buffer[cursor] !== 0x3d \u002F* '=' *\u002F) {\n        cursor++;\n      }\n      if (cursor >= len) break;\n\n      const tag = parseInt(buffer.toString('ascii', tagStart, cursor), 10);\n      cursor++; \u002F\u002F Skip '='\n\n      const valStart = cursor;\n      while (cursor \u003C len && buffer[cursor] !== FastFixParser.SOH) {\n        cursor++;\n      }\n\n      const value = buffer.toString('utf8', valStart, cursor);\n      fields.set(tag, value);\n      cursor++; \u002F\u002F Skip SOH\n    }\n\n    this.validateChecksum(buffer, fields.get(10));\n    return fields;\n  }\n\n  \u002F**\n   * Computes checksum modulo 256 over all bytes up to tag 10=\n   *\u002F\n  private validateChecksum(buffer: Buffer, expectedChecksum?: string): void {\n    if (!expectedChecksum) return;\n\n    const sohIndex = buffer.lastIndexOf('\\x0110=');\n    if (sohIndex === -1) return;\n\n    let sum = 0;\n    for (let i = 0; i \u003C= sohIndex; i++) {\n      sum += buffer[i];\n    }\n    const computed = (sum % 256).toString().padStart(3, '0');\n\n    if (computed !== expectedChecksum) {\n      throw new Error(`FIX Checksum Error: Computed=${computed}, Expected=${expectedChecksum}`);\n    }\n  }\n\n  \u002F**\n   * Formats a raw key-value map into a raw FIX wire protocol Buffer\n   *\u002F\n  public serialize(msgType: string, senderCompId: string, targetCompId: string, seqNum: number, tags: Map\u003Cnumber, string>): Buffer {\n    let bodyStr = `35=${msgType}\\x0149=${senderCompId}\\x0156=${targetCompId}\\x0134=${seqNum}\\x01`;\n    \n    for (const [tag, val] of tags.entries()) {\n      if ([8, 9, 35, 49, 56, 34, 10].includes(tag)) continue;\n      bodyStr += `${tag}=${val}\\x01`;\n    }\n\n    const bodyLength = Buffer.byteLength(bodyStr, 'ascii');\n    const headerStr = `8=FIX.4.4\\x019=${bodyLength}\\x01`;\n    const fullMsgWithoutChecksum = headerStr + bodyStr;\n\n    let sum = 0;\n    const msgBuffer = Buffer.from(fullMsgWithoutChecksum, 'ascii');\n    for (let i = 0; i \u003C msgBuffer.length; i++) {\n      sum += msgBuffer[i];\n    }\n    const checksumStr = `10=${(sum % 256).toString().padStart(3, '0')}\\x01`;\n\n    return Buffer.concat([msgBuffer, Buffer.from(checksumStr, 'ascii')]);\n  }\n}\n```\n\n---\n\n## 4. Anti-Patterns & Critical Mistakes\n\n1. **Dynamic Memory Allocation in the Hot Path**\n   - *Impact*: Garbage collection pauses (GC stalls) cause execution latencies to spike from microseconds to hundreds of milliseconds, triggering slippage or rejected limit orders.\n   - *Remediation*: Pre-allocate object pools, fix ring buffer sizes, and use off-heap memory.\n\n2. **Incorrect Gap Fill Processing (`SequenceReset-GapFill`)**\n   - *Impact*: Exchange disconnects the session or rejects subsequent valid orders due to unsynchronized sequence numbers.\n   - *Remediation*: Ensure admin messages (Logon, Heartbeat, TestRequest) are skipped using `GapFillFlag=Y` while incrementing `NewSeqNo` (Tag 36) appropriately.\n\n3. **Synchronous Disk I\u002FO on Session Persistence**\n   - *Impact*: Blocking file appends stall the event loop thread during market volatility bursts.\n   - *Remediation*: Perform async I\u002FO or flush memory-mapped files off the critical path using dedicated background writer threads.\n\n4. **Ignoring Sub-Millisecond Timestamp Precision**\n   - *Impact*: Regulatory non-compliance under MiFID II (RTS 25) requiring clock synchronization accuracy within 100 microseconds for high-frequency trading.\n   - *Remediation*: Format `SendingTime` (Tag 52) and `TransactTime` (Tag 60) with microsecond (`YYYYMMDD-HH:MM:SS.uuuuuu`) or nanosecond resolution against PTP (Precision Time Protocol \u002F IEEE 1588) synchronized clocks.\n\n---\n\n## 5. Verification & Testing Playbook\n\n- **Mock Acceptor Integration**: Connect Initiator against QuickFIX Acceptor harness or TT\u002FFIX Simulator.\n- **Sequence Number Gap Injection Test**: Force gap by sending `MsgSeqNum = N + 5` and verify incoming `ResendRequest` generation and proper `SequenceReset` handling.\n- **Latency Profiling**: Measure end-to-end wire-to-cancel throughput using `perf` and low-overhead tick counters (`RDTSC`).\n","# FIX Protocol Financial Trading & Messaging Architecture\n\nThis skill package defines enterprise standards for high-frequency financial trading systems, order management systems (OMS), and execution management systems (EMS) utilizing **FIX (Financial Information eXchange)** protocol versions 4.2, 4.4, and 5.0 SP2 (FIXML \u002F SBE).\n\n---\n\n## 1. Core Session & Application Architecture\n\n### Session Layer Management & Resend Recovery\n- **Session State Persistence**: Maintain strictly synchronized sequence numbers (`MsgSeqNum`, Tag 34) for incoming and outgoing messages. Store session state in memory-mapped files (MMAP) or persistent low-latency disk storage.\n- **Sequence Gap Handling & Recovery**:\n  - When an incoming `MsgSeqNum` is greater than expected, immediately issue a `ResendRequest` (MsgType `2`, Tag 35=2).\n  - Respond to incoming `ResendRequest` messages by re-sending administrative messages as `SequenceReset-GapFill` (MsgType `4`, Tag 35=4, Tag 123 `GapFillFlag=Y`) and re-sending application messages with `PossDupFlag=Y` (Tag 43).\n- **Heartbeat & Test Request Loop**: Send `Heartbeat` (Tag 35=0) at specified `HeartBtInt` (Tag 108) intervals. If no activity is received within `HeartBtInt + Margin`, issue a `TestRequest` (Tag 35=1) with a unique `TestReqID` (Tag 112). Drop session if response is absent.\n\n### Low-Latency Messaging Engineering\n- **Zero-GC & Zero-Copy Memory Management**: Eliminate object allocations on hot execution paths. Utilize ring buffers (e.g., LMAX Disruptor pattern) and pre-allocated byte buffers for message serialization.\n- **Encoding Formats**: Use **SBE (Simple Binary Encoding)** or **FAST (FIX Adapted for STreaming)** for ultra-low latency market data feeds over UDP multicast, replacing legacy tag-value pairs.\n- **Transport Security & Network Topologies**: Enforce mTLS 1.3 or IPsec VPN tunnels across dedicated cross-connects (Equinix NY4, LD4, TY3). Enable `TCP_NODELAY` (disable Nagle's algorithm) and pin thread CPU affinity.\n\n---\n\n## 2. Key FIX Tag Reference Matrix\n\n| Tag # | Field Name | Required \u002F Enum | Description |\n| :--- | :--- | :--- | :--- |\n| **8** | `BeginString` | `FIX.4.2` \u002F `FIX.4.4` \u002F `FIXT.1.1` | Protocol version identifier |\n| **9** | `BodyLength` | Integer | Length of message body between Tag 9 and Tag 10 |\n| **35** | `MsgType` | `D` (New Order), `8` (ExecReport), `2` (ResendReq) | Message type code |\n| **49** | `SenderCompID` | String | Submitting institution identifier |\n| **56** | `TargetCompID` | String | Receiving counterparty\u002Fexchange identifier |\n| **34** | `MsgSeqNum` | Integer (1-based counter) | Message sequence counter |\n| **11** | `ClOrdID` | Unique String | Client assigned unique identifier for order |\n| **55** | `Symbol` | String | Financial instrument ticker (e.g., `AAPL`, `EUR\u002FUSD`) |\n| **54** | `Side` | `1`=Buy, `2`=Sell, `5`=Sell Short | Order side specification |\n| **40** | `OrdType` | `1`=Market, `2`=Limit, `3`=Stop, `P`=Pegged | Order type execution style |\n| **38** | `OrderQty` | Quantity \u002F Decimal | Total quantity of shares\u002Fcontracts |\n| **44** | `Price` | Currency Price | Limit price per unit |\n| **10** | `CheckSum` | 3-digit zero-padded String | Modulo 256 sum of all characters up to `10=` |\n\n---\n\n## 3. Production Code Implementations\n\n### Python Implementation: Production QuickFIX Initiator for Order Routing\n\n```python\nimport sys\nimport time\nimport logging\nimport quickfix as fix\nimport quickfix44 as fix44\n\nlogging.basicConfig(level=logging.INFO, format=\"%(asctime)s [%(levelname)s] %(message)s\")\n\nclass FIXOrderRoutingApplication(fix.Application):\n    def __init__(self):\n        super().__init__()\n        self.session_id = None\n\n    def onCreate(self, sessionID: fix.SessionID):\n        logging.info(f\"Session Created: {sessionID}\")\n\n    def onLogon(self, sessionID: fix.SessionID):\n        logging.info(f\"Logon Successful: {sessionID}\")\n        self.session_id = sessionID\n\n    def onLogout(self, sessionID: fix.SessionID):\n        logging.warning(f\"Session Logged Out: {sessionID}\")\n        self.session_id = None\n\n    def toAdmin(self, message: fix.Message, sessionID: fix.SessionID):\n        msg_type = fix.MsgType()\n        message.getHeader().getField(msg_type)\n        if msg_type.getValue() == fix.MsgType_Logon:\n            # Add Username\u002FPassword credentials for authentication\n            message.setField(fix.RawData(\"SuperSecretAuthToken\"))\n            message.setField(fix.RawDataLength(len(\"SuperSecretAuthToken\")))\n\n    def fromAdmin(self, message: fix.Message, sessionID: fix.SessionID):\n        pass\n\n    def toApp(self, message: fix.Message, sessionID: fix.SessionID):\n        logging.info(f\"Sending Outbound App Message: {message}\")\n\n    def fromApp(self, message: fix.Message, sessionID: fix.SessionID):\n        self._route_app_message(message, sessionID)\n\n    def send_limit_order(self, cl_ord_id: str, symbol: str, side: str, qty: float, price: float):\n        \"\"\"\n        Constructs and sends a FIX 4.4 NewOrderSingle (MsgType D)\n        \"\"\"\n        if not self.session_id:\n            raise RuntimeError(\"Cannot send order: FIX Session not active\")\n\n        order = fix44.NewOrderSingle()\n        order.setField(fix.ClOrdID(cl_ord_id))\n        \n        # Side: 1=Buy, 2=Sell\n        side_val = fix.Side_BUY if side.upper() == \"BUY\" else fix.Side_SELL\n        order.setField(fix.Side(side_val))\n        \n        order.setField(fix.TransactTime())\n        order.setField(fix.OrdType(fix.OrdType_LIMIT))\n        order.setField(fix.Symbol(symbol))\n        order.setField(fix.OrderQty(qty))\n        order.setField(fix.Price(price))\n        order.setField(fix.TimeInForce(fix.TimeInForce_DAY))\n\n        # Send order asynchronously via QuickFIX engine\n        success = fix.Session.sendToTarget(order, self.session_id)\n        if not success:\n            logging.error(f\"Failed to submit ClOrdID: {cl_ord_id}\")\n        else:\n            logging.info(f\"Submitted Limit Order {cl_ord_id} for {symbol}\")\n\n    def _route_app_message(self, message: fix.Message, sessionID: fix.SessionID):\n        msg_type = fix.MsgType()\n        message.getHeader().getField(msg_type)\n\n        if msg_type.getValue() == fix.MsgType_ExecutionReport:\n            exec_id = fix.ExecID()\n            cl_ord_id = fix.ClOrdID()\n            ord_status = fix.OrdStatus()\n            symbol = fix.Symbol()\n            cum_qty = fix.CumQty()\n            avg_px = fix.AvgPx()\n\n            message.getField(exec_id)\n            message.getField(cl_ord_id)\n            message.getField(ord_status)\n            message.getField(symbol)\n            message.getField(cum_qty)\n            message.getField(avg_px)\n\n            logging.info(\n                f\"ExecutionReport Received | ExecID: {exec_id.getValue()} | \"\n                f\"ClOrdID: {cl_ord_id.getValue()} | Status: {ord_status.getValue()} | \"\n                f\"Symbol: {symbol.getValue()} | CumQty: {cum_qty.getValue()} | AvgPx: {avg_px.getValue()}\"\n            )\n\ndef main():\n    settings = fix.SessionSettings(\"fix_initiator.cfg\")\n    application = FIXOrderRoutingApplication()\n    store_factory = fix.FileStoreFactory(settings)\n    log_factory = fix.FileLogFactory(settings)\n    initiator = fix.SocketInitiator(application, store_factory, settings, log_factory)\n\n    logging.info(\"Starting FIX Socket Initiator...\")\n    initiator.start()\n\n    try:\n        while True:\n            time.sleep(1)\n    except KeyboardInterrupt:\n        logging.info(\"Stopping FIX Initiator...\")\n        initiator.stop()\n\nif __name__ == \"__main__\":\n    main()\n```\n\n---\n\n### TypeScript Implementation: High-Throughput Zero-Allocation FIX Parser\n\n```typescript\nexport class FastFixParser {\n  private static readonly SOH = 0x01; \u002F\u002F SOH (Start of Header \\x01)\n\n  \u002F**\n   * Fast zero-copy zero-allocation parser for Tag-Value FIX buffers\n   *\u002F\n  public parse(buffer: Buffer): Map\u003Cnumber, string> {\n    const fields = new Map\u003Cnumber, string>();\n    let cursor = 0;\n    const len = buffer.length;\n\n    while (cursor \u003C len) {\n      const tagStart = cursor;\n      while (cursor \u003C len && buffer[cursor] !== 0x3d \u002F* '=' *\u002F) {\n        cursor++;\n      }\n      if (cursor >= len) break;\n\n      const tag = parseInt(buffer.toString('ascii', tagStart, cursor), 10);\n      cursor++; \u002F\u002F Skip '='\n\n      const valStart = cursor;\n      while (cursor \u003C len && buffer[cursor] !== FastFixParser.SOH) {\n        cursor++;\n      }\n\n      const value = buffer.toString('utf8', valStart, cursor);\n      fields.set(tag, value);\n      cursor++; \u002F\u002F Skip SOH\n    }\n\n    this.validateChecksum(buffer, fields.get(10));\n    return fields;\n  }\n\n  \u002F**\n   * Computes checksum modulo 256 over all bytes up to tag 10=\n   *\u002F\n  private validateChecksum(buffer: Buffer, expectedChecksum?: string): void {\n    if (!expectedChecksum) return;\n\n    const sohIndex = buffer.lastIndexOf('\\x0110=');\n    if (sohIndex === -1) return;\n\n    let sum = 0;\n    for (let i = 0; i \u003C= sohIndex; i++) {\n      sum += buffer[i];\n    }\n    const computed = (sum % 256).toString().padStart(3, '0');\n\n    if (computed !== expectedChecksum) {\n      throw new Error(`FIX Checksum Error: Computed=${computed}, Expected=${expectedChecksum}`);\n    }\n  }\n\n  \u002F**\n   * Formats a raw key-value map into a raw FIX wire protocol Buffer\n   *\u002F\n  public serialize(msgType: string, senderCompId: string, targetCompId: string, seqNum: number, tags: Map\u003Cnumber, string>): Buffer {\n    let bodyStr = `35=${msgType}\\x0149=${senderCompId}\\x0156=${targetCompId}\\x0134=${seqNum}\\x01`;\n    \n    for (const [tag, val] of tags.entries()) {\n      if ([8, 9, 35, 49, 56, 34, 10].includes(tag)) continue;\n      bodyStr += `${tag}=${val}\\x01`;\n    }\n\n    const bodyLength = Buffer.byteLength(bodyStr, 'ascii');\n    const headerStr = `8=FIX.4.4\\x019=${bodyLength}\\x01`;\n    const fullMsgWithoutChecksum = headerStr + bodyStr;\n\n    let sum = 0;\n    const msgBuffer = Buffer.from(fullMsgWithoutChecksum, 'ascii');\n    for (let i = 0; i \u003C msgBuffer.length; i++) {\n      sum += msgBuffer[i];\n    }\n    const checksumStr = `10=${(sum % 256).toString().padStart(3, '0')}\\x01`;\n\n    return Buffer.concat([msgBuffer, Buffer.from(checksumStr, 'ascii')]);\n  }\n}\n```\n\n---\n\n## 4. Anti-Patterns & Critical Mistakes\n\n1. **Dynamic Memory Allocation in the Hot Path**\n   - *Impact*: Garbage collection pauses (GC stalls) cause execution latencies to spike from microseconds to hundreds of milliseconds, triggering slippage or rejected limit orders.\n   - *Remediation*: Pre-allocate object pools, fix ring buffer sizes, and use off-heap memory.\n\n2. **Incorrect Gap Fill Processing (`SequenceReset-GapFill`)**\n   - *Impact*: Exchange disconnects the session or rejects subsequent valid orders due to unsynchronized sequence numbers.\n   - *Remediation*: Ensure admin messages (Logon, Heartbeat, TestRequest) are skipped using `GapFillFlag=Y` while incrementing `NewSeqNo` (Tag 36) appropriately.\n\n3. **Synchronous Disk I\u002FO on Session Persistence**\n   - *Impact*: Blocking file appends stall the event loop thread during market volatility bursts.\n   - *Remediation*: Perform async I\u002FO or flush memory-mapped files off the critical path using dedicated background writer threads.\n\n4. **Ignoring Sub-Millisecond Timestamp Precision**\n   - *Impact*: Regulatory non-compliance under MiFID II (RTS 25) requiring clock synchronization accuracy within 100 microseconds for high-frequency trading.\n   - *Remediation*: Format `SendingTime` (Tag 52) and `TransactTime` (Tag 60) with microsecond (`YYYYMMDD-HH:MM:SS.uuuuuu`) or nanosecond resolution against PTP (Precision Time Protocol \u002F IEEE 1588) synchronized clocks.\n\n---\n\n## 5. Verification & Testing Playbook\n\n- **Mock Acceptor Integration**: Connect Initiator against QuickFIX Acceptor harness or TT\u002FFIX Simulator.\n- **Sequence Number Gap Injection Test**: Force gap by sending `MsgSeqNum = N + 5` and verify incoming `ResendRequest` generation and proper `SequenceReset` handling.\n- **Latency Profiling**: Measure end-to-end wire-to-cancel throughput using `perf` and low-overhead tick counters (`RDTSC`).\n",{"name":5,"description":7},"main","e905af21e5f1e1c3ca605e9656c3a7930360a84e","Business\u002FFintech_and_Accounting\u002FFinancial_and_Payment_Gateways\u002Ffix-protocol-financial-trading",1,"https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills","https:\u002F\u002Fhamzabellouch.github.io\u002F","https:\u002F\u002Fgithub.com\u002Fhamzabellouch","hamzabellouch.github.io","CEO & Founder of @tknoglobal | Researcher in Technology & Applied Sciences.","2026-10-17 03:20:19",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add hamzabellouch\u002Fagent-skills --skill fix-protocol-financial-trading",{"tool":40,"command":41},"bunx","bunx skills add hamzabellouch\u002Fagent-skills --skill fix-protocol-financial-trading",{"tool":43,"command":44},"pnpm","pnpm dlx skills add hamzabellouch\u002Fagent-skills --skill fix-protocol-financial-trading","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FBusiness\u002FFintech_and_Accounting\u002FFinancial_and_Payment_Gateways\u002Ffix-protocol-financial-trading\u002FSKILL.md",true,[],[49,56,63,70,77,84],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":19},"01M79FHH2H815A9TAP6WNKH4Q8","security-audit","Comprehensive security guidance, source code audit, vulnerability assessment, and penetration test review for codebases, APIs, microservices, CLI tools, libraries, and LLM-backed applications. Triggers on requests to audit a codebase, conduct security reviews, find vulnerabilities or flaws, pen-test source code, or when the user asks in Arabic (فحص أمني، تدقيق الكود أمنياً، مراجعة الثغرات، فحص أمان المشروع). Supports Guidance mode (focused review) and Full Audit mode (deterministic 6-phase harness).","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FSecurity_Audit_and_Code_Review\u002Fsecurity-audit\u002FSKILL.md",[],[],{"skillNo":57,"name":58,"nameZh":6,"description":59,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":19},"01M79FHBGXVBY6VQ1X7ETAZMF1","malware-analysis-reversing","Production malware analysis workflows, reverse engineering methodologies, isolated sandbox triage, static\u002Fdynamic binary analysis, memory forensics, and YARA detection rule authoring.","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FOffensive_Security_and_Pentesting\u002Fmalware-analysis-reversing\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":19},"01M79FH6EACDR801TZCE4R8SAC","application-security-pentesting","Production Application Security (AppSec) standards, OWASP Top 10 vulnerability remediation, SAST\u002FDAST pipeline integration, secure code review, threat modeling, and defensive security posture.","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FOffensive_Security_and_Pentesting\u002Fapplication-security-pentesting\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M79FH0VKVT44FK923K520ZQA","oauth2-oidc-security-flows","Implement enterprise OAuth 2.1 and OpenID Connect (OIDC) authorization code flow with Proof Key for Code Exchange (PKCE), state and nonce verification, refresh token rotation, token revocation, and centralized IdP federation (Keycloak, Auth0, Okta). Trigger when building secure authentication, single sign-on (SSO), or third-party delegated authorization.","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FIdentity_and_Access_Management_IAM\u002Foauth2-oidc-security-flows\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":19},"01M79FGVVB3R4T88XXD8FRSV5B","jwt-session-management-hardening","Harden JWT-based authentication and session lifecycles using asymmetric signing (RS256\u002FEdDSA), JWKS rotation, strict claims validation, Redis-backed sliding window sessions, revocation lists, and secure HttpOnly cookie storage. Trigger when implementing token validation, session revocation, or hardening API authentication.","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FIdentity_and_Access_Management_IAM\u002Fjwt-session-management-hardening\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M79FGNCPZ85CVEY0B3NE4H3B","soc2-compliance-automation","Best practices for implementing SOC 2 Type II compliance controls, continuous evidence collection, infrastructure policy-as-code, and automated security monitoring. Use when automating Trust Services Criteria (Security, Availability, Confidentiality, Processing Integrity, Privacy), audit logging, IAM least privilege, or CI\u002FCD security gates.","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FGovernance_Compliance_and_Legal_Tech\u002Fsoc2-compliance-automation\u002FSKILL.md",[],[]]