Merge branch 'master' of cloud21.cvtt.vpn:/opt/store/git/cvtt2/research/pairs_trading

This commit is contained in:
Oleg Sheynin 2025-06-25 21:41:25 +00:00
commit e74c25bb8d
3 changed files with 72 additions and 984 deletions

View File

@ -4,18 +4,24 @@ This document provides a guide to understanding, configuring, and running the pa
## Overview
The system is designed to backtest pairs trading strategies on historical market data. It allows users to select different strategies, configure parameters, and analyze the performance of these strategies.
The system is designed to backtest pairs trading strategies on historical market data.
It allows users to select different strategies, configure parameters, and analyze the
performance of these strategies.
## Core Concepts
### Trading Pair
A trading pair consists of two financial instruments (e.g., stocks or cryptocurrencies) whose prices are believed to have a long-term statistical relationship (cointegration). The strategy aims to profit from temporary deviations from this relationship.
A trading pair consists of two financial instruments (e.g., stocks or cryptocurrencies)
whose prices are believed to have a long-term statistical relationship (cointegration).
The strategy aims to profit from temporary deviations from this relationship.
### Strategy
The system supports different strategies for identifying and exploiting trading opportunities. Each strategy has its own set of configurable parameters.
### Trading Signals
Trading signals indicate when to open or close a position based on the configured strategy and parameters. These signals are typically generated when the "dis-equilibrium" (the deviation from the long-term relationship) crosses certain thresholds.
Trading signals indicate when to open or close a position based on the configured strategy
and parameters. These signals are typically generated when the "dis-equilibrium" (the
deviation from the long-term relationship) crosses certain thresholds.
## Running a Backtest
@ -54,7 +60,11 @@ The system currently offers two main strategies: `StaticFitStrategy` and `Slidin
STRATEGY = SlidingFitStrategy()
```
- **`StaticFitStrategy`**: This strategy fits the cointegration model once at the beginning of each trading day (or for the entire dataset if run on a single file without a rolling window logic in the strategy itself). The parameters (mean, standard deviation of dis-equilibrium) derived from this initial fit are used for generating trading signals throughout the day.
- **`StaticFitStrategy`**: This strategy fits the cointegration model once at the beginning
of each trading day (or for the entire dataset if run on a single file without a rolling
window logic in the strategy itself). The parameters (mean, standard deviation of
dis-equilibrium) derived from this initial fit are used for generating trading signals
throughout the day.
- **Pros**: Simpler, computationally less intensive.
- **Cons**: May not adapt well to changing market conditions during the day.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long