Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Machine Learning-Based Breakout Signals Filtering Using Stop-Loss Risk Prediction in Cryptocurrency Futures Markets

Research code accompanying the manuscript “Machine Learning-Based Breakout Signals Filtering Using Stop-Loss Risk Prediction in Cryptocurrency Futures Markets.”

This study evaluates an event-level machine-learning framework that estimates the probability that a rule-generated cryptocurrency futures breakout candidate will terminate through the strategy's predefined stop-loss rule. The model is used as a pre-execution risk filter on top of a fixed breakout strategy; it does not replace the underlying strategy.

The final reported model is an XGBoost classifier with a fixed stop-loss probability threshold of 0.85. The manuscript reports a held-out AUROC of 0.7196 and LogLoss of 0.5520.

Backtesting Engine

Workflow

flowchart LR
    A[Rule-generated breakout candidates] --> B[Pre-execution event records]
    C[TradingView feature exports] --> D[Event-feature alignment]
    E[Binance funding-rate history] --> D
    F[Binance mark-price klines] --> D
    B --> D
    D --> G[Dataset screening and feature selection]
    G --> H[Expanding walk-forward training]
    H --> I[Out-of-sample stop-loss probabilities]
    I --> J[Fixed probability threshold]
    J --> K[Accepted and rejected candidates]
    K --> L[Backtesting and robustness evaluation]
Loading

Public repository structure

Only the following public materials are included in this repository:

Breakout-Signals-Filtering/
├─ Sources/
│  ├─ Experiment/Public/    # Data integration, model development, inference, and evaluation
│  └─ Figure/Public/        # Manuscript figures and result summaries
└─ README.md

Sources/Experiment/Public/ contains the releasable analysis code for data integration, preprocessing experiments, chronological validation, feature selection, model development, inference, bootstrap evaluation, and model interpretation.

Sources/Figure/Public/ contains the releasable scripts used to generate manuscript figures and summarized result visualizations.

The Data/ directory is intentionally excluded from version control because the complete local research data and preserved outputs are large and include strategy-sensitive materials. Users running the released scripts must prepare the required files locally.

The repository is not an end-to-end reconstruction package. Several required inputs are intentionally excluded because they contain proprietary or strategy-sensitive information.

Local data layout

The released scripts expect the complete local research-data tree under Data/ at the repository root. The entire Data/ directory is excluded from the public repository and must remain untracked by Git because it is large and contains strategy-sensitive datasets and preserved experimental outputs.

Breakout-Signals-Filtering/
├─ Sources/
│  ├─ Experiment/Public/
│  └─ Figure/Public/
├─ README.md
└─ Data/                    # Local-only; excluded from Git
   ├─ Dataset/              # Modeling datasets and intermediate dataset variants
   ├─ Events/               # Strategy-generated event records
   ├─ Features/             # TradingView-derived feature exports
   ├─ Funding Rates/        # Binance funding-rate history
   ├─ Mark Price Klines/    # Binance mark-price kline data
   └─ Results/              # Preserved experimental, inference, and backtest outputs

Only Sources/ and README.md are distributed through the public repository. The complete Data/ tree is retained privately and may be supplied separately to editors or reviewers for confidential verification when required.

The Binance funding-rate and mark-price inputs can be collected again from the public endpoints described below. The remaining Data/ contents are non-public because they contain strategy-specific events, TradingView-derived features, modeling datasets, and detailed experimental outputs.

Backtesting engine

Strategy simulations and trade-level backtest outputs were generated with Traderhs/Backtesting, a C++20 multi-symbol backtesting engine designed to reproduce key mechanics of the Binance Futures environment.

The engine was used for bar-driven execution, lower-timeframe path verification, funding and mark-price handling, fees, slippage, leverage, isolated-margin accounting, position sizing, and liquidation checks. The experiments used 1-hour trading bars and 1-minute lower-timeframe records for execution-path verification.

The breakout-strategy implementation, strategy-specific event-generation code, and proprietary execution rules are not included in this repository.

Public Binance data acquisition

The funding-rate and mark-price inputs can be collected from the public Binance USDⓈ-M Futures REST API. No API key is required for these market-data endpoints.

Funding-rate history

Endpoint:

GET https://fapi.binance.com/fapi/v1/fundingRate

Example request:

https://fapi.binance.com/fapi/v1/fundingRate?symbol=BTCUSDT&startTime=<UTC_EPOCH_MS>&endTime=<UTC_EPOCH_MS>&limit=1000

Relevant parameters are symbol, startTime, endTime, and limit. The maximum limit is 1000. The response includes symbol, fundingRate, fundingTime, and the mark price associated with the funding settlement.

For a long historical range, request records chronologically and advance startTime beyond the last returned fundingTime until the target end time is reached.

When running the analysis locally, store per-symbol funding-rate files under:

Data/Funding Rates/<SYMBOL>.json

The stored JSON should preserve the Binance response fields used by the scripts, including fundingTime and fundingRate.

Official documentation: Binance — Get Funding Rate History

Mark-price klines

Endpoint:

GET https://fapi.binance.com/fapi/v1/markPriceKlines

Example request:

https://fapi.binance.com/fapi/v1/markPriceKlines?symbol=BTCUSDT&interval=1d&startTime=<UTC_EPOCH_MS>&endTime=<UTC_EPOCH_MS>&limit=1500

Relevant parameters are symbol, interval, startTime, endTime, and limit. The maximum limit is 1500. The response contains mark-price OHLC records together with opening and closing timestamps.

For a long historical range, request records chronologically and advance startTime beyond the last returned kline timestamp until the target end time is reached.

When running the analysis locally, store daily mark-price data under:

Data/Mark Price Klines/<SYMBOL>/1d.parquet

The Parquet table must contain the columns expected by the released scripts, including Open Time and Close.

Official documentation: Binance — Mark Price Kline/Candlestick Data

TradingView feature data

The model feature panel was extracted directly from TradingView and subsequently aligned to the event-level decision timestamps used in the study.

The following materials are not publicly released:

  • the TradingView feature dataset;
  • the TradingView feature-extraction or export code;
  • strategy-specific event records;
  • the complete event-level modeling datasets;
  • intermediate tables that preserve signal timing or strategy state; and
  • original experimental and backtest outputs.

These materials contain timing information and strategy-specific market-state variables that could enable reverse engineering of the underlying trading strategy.

Dataset availability

The complete event-level research dataset is not included in this public repository.

It contains actual signal timestamps, symbols, strategy-state variables, stop-loss labels, and realized trade outcomes. Releasing these fields together would make it possible to infer substantial parts of the proprietary breakout strategy and its signal-generation process. The dataset is therefore withheld to reduce the risk of strategy reverse engineering.

When required for editorial or peer-review verification, the complete dataset and preserved outputs may be provided confidentially to editors or reviewers. They are not licensed for public redistribution.

Reproducibility scope

The public repository supports inspection of the released machine-learning and statistical-analysis procedures, including:

  • integration of prepared event and feature tables;
  • missing-value and redundancy analyses;
  • expanding walk-forward validation;
  • feature selection and model comparison;
  • classifier tuning and ensemble experiments;
  • held-out and unseen-symbol inference;
  • fixed-threshold filtering;
  • trade-count-matched random-removal bootstrap tests;
  • model interpretation; and
  • manuscript figure generation.

Full end-to-end reproduction is not possible from the public repository alone because the proprietary event dataset, TradingView feature dataset, feature-extraction code, strategy implementation, and original experimental outputs are not distributed.

Environment

A recent Python 3 environment is recommended. The released scripts use packages including:

numpy
pandas
pyarrow
matplotlib
seaborn
scikit-learn
xgboost
lightgbm
catboost
torch
tqdm
Pillow

Example setup:

python -m venv .venv

# Linux or macOS
source .venv/bin/activate

# Windows PowerShell
.venv\Scripts\Activate.ps1

python -m pip install --upgrade pip
python -m pip install numpy pandas pyarrow matplotlib seaborn scikit-learn xgboost lightgbm catboost torch tqdm pillow

Because the non-public research inputs are not included, individual scripts should be executed only after the required local files have been prepared in the paths expected by that script.

Research-use disclaimer

This repository is provided for research and methodological inspection. It is not investment advice, and reported historical results do not guarantee future trading performance.

Citation

Please cite the associated manuscript when using or discussing this code. Full bibliographic information will be added after publication.

About

Research code for Machine Learning-Based Breakout Signals Filtering Using Stop-Loss Risk Prediction in Cryptocurrency Futures Markets

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages