Skip to main content
Total Downloads
1.5K
1,515
Published
Aug 7, 2025
1y ago

Get Started

dotnet add package StockSharp.Strategies.0222_Cointegration_Pairs.py --version 5.0.1

No framework information available.

README

Cointegration Pairs Strategy (Python Version)

This strategy trades two assets that share a long-term cointegration relationship. By calculating the residual between the first asset and a beta-adjusted second asset, it looks for deviations that historically revert back to equilibrium.

Testing indicates an average annual return of about 103%. It performs best in the stocks market.

A long position buys the first asset and sells the second when the residual z-score drops below -EntryThreshold. A short position sells the first and buys the second when the z-score rises above the threshold. Positions are closed once the spread normalizes toward zero.

Cointegration pairs trading suits statistical arbitrageurs comfortable managing two instruments simultaneously. The built-in stop-loss protects against extreme moves if the relationship temporarily breaks down.

Details

  • Entry Criteria:
    • Long: Residual Z-Score < -EntryThreshold
    • Short: Residual Z-Score > EntryThreshold
  • Long/Short: Both sides.
  • Exit Criteria:
    • Long: Exit when |Z-Score| < 0.5
    • Short: Exit when |Z-Score| < 0.5
  • Stops: Yes, percentage stop-loss.
  • Default Values:
    • Period = 20
    • EntryThreshold = 2.0m
    • Beta = 1.0m
    • StopLossPercent = 2.0m
    • CandleType = TimeSpan.FromMinutes(5)
  • Filters:
    • Category: Arbitrage
    • Direction: Both
    • Indicators: Cointegration
    • Stops: Yes
    • Complexity: Intermediate
    • Timeframe: Intraday
    • Seasonality: No
    • Neural networks: No
    • Divergence: Yes
    • Risk Level: Medium

Downloads by Version

Similar & Alternative Packages

Hand-picked matching NuGet libraries based on tags & ecosystem

Depended On By

Find packages that declare this package as a dependency. NuGet does not provide a reverse-dependency endpoint, so candidates are checked on demand.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

No SPDX license expression is published. Review the license text and your organisation's policy before redistribution.No target framework metadata is available. Confirm compatibility in a representative project before standardising on this package.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.