Skip to main content

Standard strategies library for the Coinrule X execution platform

Project description

Coinrule X Strategies

A standard library of open-source trading strategies designed for the Coinrule X execution platform.

Strategies in this repository act as signal generators and are executed using Coinrule X's managed execution and risk engine.


Strategy Architecture

Strategies in this repository are signal generators that can operate in two modes:

Entry-Only Strategies (entry_only: true)

  • Generate entry signals only
  • Exits are fully managed by the Coinrule X risk engine
  • Mandatory managed risk management (stop-loss, take-profit, trailing, breakeven)
  • Best for: trend-following, momentum, breakout strategies

Entry & Exit Strategies (entry_only: false)

  • Generate both entry and exit signals
  • Strategy controls when to close positions
  • Optional risk management (disabled by default, can be enabled per user)
  • Best for: mean-reversion, arbitrage, custom exit logic strategies

All position execution is handled by the Coinrule X execution layer, ensuring consistent behavior and safety guarantees across all strategies.

This separation allows:

  • reproducible and auditable strategy logic
  • flexible risk control (managed or strategy-driven)
  • safe execution without exposing private keys
  • configurable preferences per user

Execution & Risk Management

Coinrule X provides a configurable risk framework that behaves differently based on strategy type:

For Entry-Only Strategies

Risk management is mandatory and enforced:

  • mandatory stop-loss on every position
  • take-profit via fixed target or trailing stop
  • optional breakeven logic with partial position closes
  • configurable position sizing per strategy

Exits are triggered exclusively by the risk engine (SL/TP/trailing/breakeven).

For Entry & Exit Strategies

Risk management is optional (disabled by default):

  • strategy controls exit timing via exit signals
  • users can opt-in to enable risk management as a safety layer
  • when enabled, risk engine acts as a backstop (e.g., emergency stop-loss)
  • position sizing remains configurable

Risk Model Options

When risk management is enabled (mandatory for entry-only, optional for entry & exit):

  • Stop-loss: mandatory, configurable distance
  • Take-profit: fixed percentage target or trailing stop
  • Trailing stop: optional activation after a defined profit threshold
  • Breakeven logic: partial position close, stop moved to entry, trailing enabled for remainder

Customization

Users can adjust risk parameters per strategy:

  • stop-loss distance
  • take-profit method and target
  • trailing activation threshold
  • breakeven behavior
  • position sizing

For entry & exit strategies, users can also toggle whether managed risk management is enabled.


Repository Structure

Strategies are organized into individual folders under coinrule_x_strategies/strategies/.

The repository uses a scalable registry system with support for sub-registries.

  • coinrule_x_strategies/registry.yaml Main entry point including all registered strategies.

  • coinrule_x_strategies/strategies/<strategy_name>/registry.yaml Strategy-specific metadata and configuration, including the entry_only flag.

  • coinrule_x_strategies/strategies/<strategy_name>/strategy.py Strategy implementation (entry signals, and optionally exit signals).

Each strategy folder also includes a dedicated README.md describing its logic, use cases, and risk profile.

Registry Configuration

Each strategy's registry.yaml must include the entry_only field:

name: my_strategy
version: 1.0.0
entry_only: true  # true = entry signals only, managed risk required
                  # false = entry & exit signals, optional risk management
category: trend
# ... other metadata

Multi-Timeframe Strategies

Strategies can operate on multiple timeframes simultaneously using the market_mode and market_aliases settings.

Registry Configuration

name: volatility_breakout
version: 1.0.0
settings:
  market_mode: "multi"           # "single" (default) or "multi"
  market_aliases: ["ltf", "htf"] # Labels for each timeframe

Indicator Binding

For multi-timeframe strategies, indicators must be bound to specific market aliases using a tuple syntax:

# Single-market strategy (default)
def indicators(self) -> Dict[str, Indicator]:
    return {
        "rsi": RSI(14),
        "ema": EMA(50),
    }

# Multi-market strategy
def indicators(self) -> Dict[str, Tuple[Indicator, str]]:
    return {
        # Indicators bound to lower timeframe
        "rsi_ltf": (RSI(14), "ltf"),
        "ema_ltf": (EMA(50), "ltf"),
        "candle": (Candle(), "ltf"),
        # Indicators bound to higher timeframe
        "rsi_htf": (RSI(14), "htf"),
        "ema_htf": (EMA(50), "htf"),
    }

The runner will:

  1. Subscribe to candle streams for each market alias (e.g., 5m for ltf, 1h for htf)
  2. Feed candles to indicators based on their market binding
  3. Provide indicator history to evaluate() with values from the correct timeframe

Installation

pip install crx-strategies

Available Strategies

  • Trend Rider: A trend-following strategy designed to capitalize on strong directional markets. It enters positions only when multiple trend and momentum indicators align, aiming to stay in trades during sustained moves while avoiding choppy conditions.
  • Bounce Recovery: A mean-reversion strategy designed to capture controlled pullbacks and oversold conditions. Aim to profit from short-term price rebounds while applying strict risk controls to avoid prolonged drawdowns.
  • Volatility Breakout: A strategy designed to trade sudden expansions in volatility after periods of compression. Aim to capture fast, directional moves triggered by volatility regime shifts.

Contributing

Contributions are welcome.

To add a new strategy:

  1. Create a new folder under coinrule_x_strategies/strategies/.

  2. Implement your strategy class by inheriting from Strategy base class.

  3. Add a registry.yaml file with strategy metadata.

  4. Validate your registry file using the included script:

    # Using installed CLI
    coinrule_x-validate-strategies coinrule_x_strategies/strategies/<your_strategy>/registry.yaml
    
    # Or using poetry during development
    poetry run python coinrule_x_strategies/validation.py coinrule_x_strategies/strategies/<your_strategy>/registry.yaml
    
  5. Register your strategy by adding its sub-registry path to coinrule_x_strategies/registry.yaml.

All strategies should:

  • generate entry signals (and optionally exit signals)
  • specify entry_only: true or entry_only: false in registry
  • remain stateless
  • avoid embedding execution or position management logic

Submission Process

  1. Fork the Repository: Create a fork of the repository to your own GitHub account.
  2. Create a Feature Branch: Create a new branch for your changes (e.g., feat/add-abc-strategy).
  3. Implement & Test: Apply your changes and ensure all tests pass.
  4. Create Pull Request: Submit a pull request to the main repository.

Note: Version numbers and the official CHANGELOG will be updated by maintainers upon release.

Development Guidelines

  • Type Hinting: All methods must be fully type-hinted.
  • Pandas/Numpy: Use vectorized operations where possible for performance.
  • Zero Dependencies: Do not add new external dependencies without prior discussion.

Disclaimer

Strategies provided in this repository are open-source and intended for systematic trading experimentation. They do not constitute financial or investment advice. Trading involves risk, and users are fully responsible for their configuration and capital allocation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crx_strategies-1.1.0.tar.gz (24.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

crx_strategies-1.1.0-py3-none-any.whl (34.1 kB view details)

Uploaded Python 3

File details

Details for the file crx_strategies-1.1.0.tar.gz.

File metadata

  • Download URL: crx_strategies-1.1.0.tar.gz
  • Upload date:
  • Size: 24.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.10.20 Linux/6.17.0-1008-azure

File hashes

Hashes for crx_strategies-1.1.0.tar.gz
Algorithm Hash digest
SHA256 f4917ea1b984e7b3fd7fdd6fc7b88a8ec4da9fb8be826e5cf0837372a6170101
MD5 3bb6e23c186bdb363bf9a0dd35ff29a3
BLAKE2b-256 1f6fb68b02b245dd9b8db021b7f9786bbf1d9694faf40da2391ebec966df0a1b

See more details on using hashes here.

File details

Details for the file crx_strategies-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: crx_strategies-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 34.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.10.20 Linux/6.17.0-1008-azure

File hashes

Hashes for crx_strategies-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 118051f8284646911ba3a1b7b951634c7f546319a8f048d6a644a35b83d483a2
MD5 613b51c709a0839368c474a67928e9c1
BLAKE2b-256 300f6d3e1a6847bf12bff3ffcafe89c3a054a0b7292ac26d9e77c2d6dd137a64

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page