claude-force: Skill for Claude Code

.claude/skills/crypto-trading-patterns/SKILL.md

crypto-trading-patterns is a skill for Claude Code from khanh-vu/claude-force. It costs 0 tokens per session (735 once invoked), scanned A, original, MIT.

A collection of patterns for building bots that trade cryptocurrencies. It covers risk-based position sizing and the stages an order passes through, such as submitted, partially filled, cancelled, or rejected.

In plain words
What is it for?
Use it when implementing cryptocurrency trading bots, risk controls, position-size calculations, or order lifecycle handling.
Why use it?
It helps avoid inconsistent trading logic, especially when deciding how much to trade or handling orders that change state over time. The examples make these rules explicit in code.

Skill for Claude Code

Written for Claude Code: installed under .claude/.

This is khanh-vu/claude-force's own configuration. It tells Claude Code how to work on claude-force itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything claude-force configures →

Reuse

Borrowing it

Nothing to install: this file belongs to khanh-vu/claude-force. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/khanh-vu/claude-force/main/.claude/skills/crypto-trading-patterns/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/khanh-vu/claude-force

Made for: Claude Code.

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 crypto-trading-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/khanh-vu/claude-force/crypto-trading-patterns/github.svg)](https://agentmods.dev/skills/khanh-vu/claude-force/crypto-trading-patterns)
Your own site
<a href="https://agentmods.dev/skills/khanh-vu/claude-force/crypto-trading-patterns"><img src="https://agentmods.dev/badge/skills/khanh-vu/claude-force/crypto-trading-patterns/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for crypto-trading-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/khanh-vu/claude-force/crypto-trading-patterns"><img src="https://agentmods.dev/badge/skills/khanh-vu/claude-force/crypto-trading-patterns.svg" alt="Reviewed on agentmods" width="80" 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 735 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00000 $0.00735
Opus 5 $0.00000 $0.00367
Sonnet 5 $0.00000 $0.00147
Haiku 4.5 $0.00000 $0.00073

Measured 9d ago against content hash 8e624d68ed9f, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

crypto-trading-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 9d 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/crypto-trading-patterns/SKILL.md · 113 lines

How it starts

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

Crypto Trading Patterns

Comprehensive patterns and best practices for building cryptocurrency trading bots.

Position Sizing Algorithm

from decimal import Decimal

def calculate_position_size(
    account_balance: Decimal,
    risk_per_trade: Decimal,  # e.g., 0.02 for 2%
    entry_price: Decimal,
    stop_loss_price: Decimal
) -> Decimal:
    """
    Calculate position size based on risk management
    Returns amount to trade in base currency
    """
    risk_amount = account_balance * risk_per_trade
    risk_per_unit = abs(entry_price - stop_loss_price)

    if risk_per_unit == 0:
        raise ValueError("Stop loss must differ from entry price")

    position_size = risk_amount / risk_per_unit
    return position_size

Order State Machine

from enum import Enum

class OrderStatus(Enum):
    PENDING = "pending"
    SUBMITTED = "submitted"
    PARTIAL = "partial"
    FILLED = "filled"
    CANCELLED = "cancelled"
    REJECTED = "rejected"
    EXPIRED = "expired"

class OrderStateMachine:
    """Manages order lifecycle and valid state transitions"""

    VALID_TRANSITIONS = {
        OrderStatus.PENDING: [OrderStatus.SUBMITTED, OrderStatus.REJECTED],
        OrderStatus.SUBMITTED: [OrderStatus.PARTIAL, OrderStatus.FILLED, OrderStatus.CANCELLED],
        OrderStatus.PARTIAL: [OrderStatus.FILLED, OrderStatus.CANCELLED],
        OrderStatus.FILLED: [],  # Terminal state
        OrderStatus.CANCELLED: [],  # Terminal state
        OrderStatus.REJECTED: [],  # Terminal state
    }

    def __init__(self, order_id: str):
        self.order_id = order_id
        self.status = OrderStatus.PENDING

    def transition(self, new_status: OrderStatus):
        if new_status not in self.VALID_TRANSITIONS[self.status]:
            raise ValueError(
                f"Invalid transition: {self.status} -> {new_status}"
            )
        self.status = new_status
        self._log_transition(new_status)

Circuit Breaker Pattern

import time

class CircuitBreaker:
    """Prevents trading during system failures"""

    def __init__(self, failure_threshold: int = 5, timeout: int = 60):
        self.failure_threshold = failure_threshold
        self.timeout = timeout
        self.failures = 0
        self.state = 'CLOSED'  # CLOSED, OPEN, HALF_OPEN
        self.last_failure_time = None

    def call(self, func, *args, **kwargs):
        if self.state == 'OPEN':
            if time.time() - self.last_failure_time > self.timeout:
                self.state = 'HALF_OPEN'
            else:
                raise CircuitBreakerOpenError("Trading halted")

        try:
            result = func(*args, **kwargs)
            self._on_success()
            return result
        except Exception as e:
            self._on_failure()
            raise

    def _on_failure(self):
        self.failures += 1
        self.last_failure_time = time.time()
        if self.failures >= self.failure_threshold:
            self.state = 'OPEN'
            logger.critical("Circuit breaker opened - trading halted!")

    def _on_success(self):
        self.failures = 0
        self.state = 'CLOSED'

Read the full file on GitHub · 113 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. 9d ago First seen · 113 lines · 0 tokens per session scan A 8e624d68ed9f

Subscribe to this mod's changes

crypto-trading-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 735 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.