order-execution-patterns

order-execution-patterns is a skill for Claude Code, Codex from khanh-vu/claude-force. It costs 0 tokens per session (2,836 once invoked), scanned A, original, MIT.

Algorithms for placing a large trading order in smaller parts over time to reduce price movement and improve the final fill price.

In plain words
What is it for?
Use it to run time-based executions such as TWAP, configure trade duration and slices, and collect fills, average price, and slippage.
Why use it?
Splitting an order can limit its effect on the market and make execution quality easier to measure.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/khanh-vu/claude-force/order-execution-patterns
Any agent
npx skills add khanh-vu/claude-force --skill order-execution-patterns
Clone the repo
git clone --depth 1 https://github.com/khanh-vu/claude-force

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for order-execution-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/khanh-vu/claude-force/order-execution-patterns.svg)](https://agentmods.dev/skills/khanh-vu/claude-force/order-execution-patterns)
Your own site
<a href="https://agentmods.dev/skills/khanh-vu/claude-force/order-execution-patterns"><img src="https://agentmods.dev/badge/skills/khanh-vu/claude-force/order-execution-patterns.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,836 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.02836
Opus 5 $0.00000 $0.01418
Sonnet 5 $0.00000 $0.00567
Haiku 4.5 $0.00000 $0.00284

Measured 5d ago against content hash 6a9cf77bc21f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

order-execution-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/order-execution-patterns/SKILL.md · 456 lines

How it starts

The opening of the file, as written. The whole thing — 456 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Order Execution Patterns

Advanced order execution algorithms to minimize slippage and optimize fill quality.

TWAP (Time-Weighted Average Price) Execution

import asyncio
from decimal import Decimal
from datetime import datetime, timedelta
from typing import List, Dict

class TWAPExecutor:
    """
    Time-Weighted Average Price execution
    Splits large order evenly over time to minimize market impact
    """

    def __init__(self, exchange_connector):
        self.exchange = exchange_connector
        self.active_executions = {}

    async def execute_twap(
        self,
        symbol: str,
        side: str,  # 'buy' or 'sell'
        total_amount: Decimal,
        duration_minutes: int,
        num_slices: int = None
    ) -> Dict:
        """
        Execute TWAP order

        Args:
            symbol: Trading pair (e.g., 'BTC/USDT')
            side: 'buy' or 'sell'
            total_amount: Total quantity to trade
            duration_minutes: Time window for execution
            num_slices: Number of slices (default: duration_minutes)

        Returns:
            Execution report with fills, average price, slippage
        """
        if num_slices is None:
            num_slices = duration_minutes

        slice_amount = total_amount / num_slices
        interval_seconds = (duration_minutes * 60) / num_slices

        execution_id = f"twap_{symbol}_{datetime.utcnow().timestamp()}"
        self.active_executions[execution_id] = {
            'symbol': symbol,
            'side': side,
            'total_amount': total_amount,
            'fills': [],
            'start_time': datetime.utcnow(),
            'status': 'active'
        }

        logger.info(
            f"Starting TWAP execution: {total_amount} {symbol} "
            f"over {duration_minutes}m in {num_slices} slices"
        )

        try:
            for slice_num in range(num_slices):
                # Get current mid price
                ticker = await self.exchange.fetch_ticker(symbol)
                mid_price = (ticker['bid'] + ticker['ask']) / 2

                # Place limit order at mid price (passive execution)
                order = await self.exchange.create_limit_order(
                    symbol=symbol,
                    side=side,
                    amount=float(slice_amount),
                    price=float(mid_price)
                )

                # Wait for partial fill or timeout
                fill = await self._wait_for_fill(
                    order['id'],
                    timeout_seconds=interval_seconds * 0.8  # 80% of interval
                )

                self.active_executions[execution_id]['fills'].append(fill)

                # If not fully filled, cancel and use market order for remainder
                if fill['filled'] < slice_amount:
                    await self.exchange.cancel_order(order['id'])
                    remainder = slice_amount - fill['filled']

                    if remainder > 0:
                        market_fill = await self.exchange.create_market_order(
                            symbol=symbol,
                            side=side,
                            amount=float(remainder)
                        )
                        self.active_executions[execution_id]['fills'].append(market_fill)

                # Wait until next slice
                if slice_num < num_slices - 1:
                    await asyncio.sleep(interval_seconds)

            # Calculate execution statistics
            report = self._generate_execution_report(execution_id)
            self.active_executions[execution_id]['status'] = 'completed'

            return report

        except Exception as e:
            logger.error(f"TWAP execution failed: {e}")
            self.active_executions[execution_id]['status'] = 'failed'
            raise

    async def _wait_for_fill(
        self,
        order_id: str,
        timeout_seconds: float
    ) -> Dict:
        """Wait for order to fill or timeout"""
        start_time = time.time()

        while time.time() - start_time < timeout_seconds:
            order = await self.exchange.fetch_order(order_id)

            if order['status'] in ['closed', 'filled']:
                return {
                    'filled': Decimal(str(order['filled'])),
                    'price': Decimal(str(order['average'])),
                    'timestamp': order['timestamp']
                }

            await asyncio.sleep(1)

        # Timeout - return partial fill
        order = await self.exchange.fetch_order(order_id)
        return {
            'filled': Decimal(str(order.get('filled', 0))),
            'price': Decimal(str(order.get('average', 0))),
            'timestamp': order['timestamp']
        }

Read the full file on GitHub · 456 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 456 lines · 0 tokens per session scan A 6a9cf77bc21f

Subscribe to this mod's changes

order-execution-patterns is a skill published in the GitHub repository khanh-vu/claude-force (5 stars, last pushed 9mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,836 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.