Skip to content

okht/quant-research

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

31 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“ˆ quant-research

Keep the winners, the failures, and the assumptions visible.

Jupyter Notebook Python 3.13 Data Last Commit Stars

A-shares Crypto Machine Learning Backtest Only


๐Ÿงช ย Want to inspect the full research path, including weak factors and failed strategy ideas?
๐Ÿ’ธ ย Need transaction costs, attribution, drawdown, and validation to stay visible beside returns?
๐Ÿ—‚๏ธ ย Prefer notebooks and data snapshots you can inspect cell by cell?

โœจ quant-research is a public notebook trail for systematic strategy experiments.

Data โ†’ hypothesis โ†’ signal โ†’ backtest โ†’ validation โ†’ documented finding


๐Ÿ“ฃ Snapshot ยท ๐Ÿงช Tracks ยท ๐Ÿ† Results ยท โšก Install ยท ๐Ÿš€ Reproduce ยท ๐Ÿ“ Methodology ยท ๐Ÿ—‚ Data ยท ๐Ÿ“‚ Structure ยท ๐Ÿ“Œ Limitations

English ยท ็ฎ€ไฝ“ไธญๆ–‡ ยท Espaรฑol ยท Deutsch ยท ๆ—ฅๆœฌ่ชž ยท ะ ัƒััะบะธะน ยท Portuguรชs ยท ํ•œ๊ตญ์–ด


๐Ÿ“ฃ Research snapshot

Item Current repository state
Format Six primary Jupyter notebooks with saved outputs
Research tracks A-share factors, BTC/USDT timing, and XGBoost signals
A-share snapshot 2023-01-03 through 2026-03-27
Crypto snapshot Daily and hourly data through 2026-03-28
Execution Backtests and exploratory analysis only
Production layer No live-trading module, CLI, package, test suite, or CI workflow

This repository records how conclusions changed as more filters, costs, frequencies, and models were tested. Negative results remain part of the research history.


๐Ÿงช Research tracks

Track Core question Main artifacts
๐Ÿ‡จ๐Ÿ‡ณ A-share factors Do momentum, reversal, turnover, and ROE explain cross-sectional returns? IC tests, composite factor, risk-control backtest, return attribution
โ‚ฟ BTC timing Can trend, sentiment, funding, and stop rules improve a BTC/USDT timing strategy? Parameter search, walk-forward checks, cost estimate, failed extensions
๐Ÿค– Machine learning Can XGBoost classify future return targets or volatility regimes? Daily and hourly classification, risk filter, fee-drag experiment
flowchart LR
    A([Data snapshots])

    A --> B[A-share factors] --> E[IC tests] --> F[Attribution] --> L([Recorded findings])
    A --> C[BTC timing] --> G[Parameter search] --> H[Walk-forward] --> I[Cost check] --> L
    A --> D[XGBoost signals] --> J[Direction models] --> K[Volatility models] --> L

    style A fill:#FEF3C7,stroke:#F59E0B,stroke-width:2px,color:#000,font-size:12px
    style B fill:#DBEAFE,stroke:#3B82F6,stroke-width:2px,color:#000,font-size:12px
    style C fill:#DBEAFE,stroke:#3B82F6,stroke-width:2px,color:#000,font-size:12px
    style D fill:#DBEAFE,stroke:#3B82F6,stroke-width:2px,color:#000,font-size:12px
    style E fill:#F1F5F9,stroke:#64748B,stroke-width:1px,color:#000,font-size:12px
    style F fill:#F1F5F9,stroke:#64748B,stroke-width:1px,color:#000,font-size:12px
    style G fill:#EDE9FE,stroke:#8B5CF6,stroke-width:1px,color:#000,font-size:12px
    style H fill:#EDE9FE,stroke:#8B5CF6,stroke-width:1px,color:#000,font-size:12px
    style I fill:#FEF2F2,stroke:#EF4444,stroke-width:1px,color:#000,font-size:12px
    style J fill:#F1F5F9,stroke:#64748B,stroke-width:1px,color:#000,font-size:12px
    style K fill:#F1F5F9,stroke:#64748B,stroke-width:1px,color:#000,font-size:12px
    style L fill:#DCFCE7,stroke:#22C55E,stroke-width:2px,color:#000,font-size:12px
Loading

๐Ÿ† Recorded results

These numbers are saved notebook outputs from the repository snapshot. They describe historical experiments under the assumptions listed below.

BTC full-sample backtest snapshot

The documented reference full-sample variant combines MACD(16,35,9), a Fear & Greed filter below 80, and a simulated 3% daily stop rule. The notebook also records +1335.98% and +612.25% from tighter 1% and 2% clipping thresholds, which makes stop selection highly sensitive to this simplified model.

Metric Recorded value Interpretation
Sample 2023-01-01 โ†’ 2026-03-28 BTC/USDT daily snapshot
Gross cumulative return +423.22% Before the final transaction-cost estimate
Estimated after-cost return +383.97% Uses 0.1% per signal change
Buy-and-hold return +301.59% Same daily backtest window
Estimated after-cost max drawdown -16.25% Final cost-estimate cell with the clipped daily stop model
Reported Sharpe 1.7001 Computed from signal returns before stop and fee adjustments
Average signal changes About 21 per year The notebook estimates roughly 2.13% annual fee drag

The reported Sharpe and after-cost return use different return series. An after-cost Sharpe still needs a clean recomputation.

Walk-forward check

Check Recorded result Reading
Final BTC workflow, average validation Sharpe 0.6224 Lower than the full-sample result; parameter stability is limited
Earlier MACD-only walk-forward, average validation Sharpe 0.4348 Positive average with meaningful fold variation

What held up and what failed

Experiment Recorded result Status
BTC MACD + sentiment + 3% stop Reference full-sample daily result Research reference only; stop-threshold sensitivity is high
A-share timing-only attribution +65.28%, Sharpe 1.1479 Stronger than the stock-selection leg
A-share three-factor selection +8.56%, Sharpe 0.2423 Weak
BTC multi-timeframe confluence +199.01%, Sharpe 1.4897 Lower than the simpler full-position strategy
BTC long-short variants Sharpe 0.9833 to 1.1150 Lower than long-only timing
Daily return-target XGBoost Accuracy near 51% Near random
Hourly volatility classifier Accuracy near 67% Exploratory; label construction leaks full-sample information
Hourly MACD + ML after costs +48.42%, Sharpe 1.1212 Fee drag materially reduces the pre-fee result

๐Ÿ‡จ๐Ÿ‡ณ A-share factor research

Factor IC snapshot

Factor IC mean ICIR Reading
20-day momentum -0.0023 -0.0112 No useful signal in this sample
5-day reversal 0.0062 0.0323 No useful signal in this sample
Turnover 0.0290 0.1089 Weak
Three-factor composite 0.0328 0.2237 Weak
ROE โ€” 0.0097 Weak and data-limited

Return attribution

Strategy leg Cumulative return Sharpe Max drawdown
Three-factor selection +8.56% 0.2423 -22.73%
Timing and risk control +65.28% 1.1479 -11.97%
Selection + risk control at 20% position +16.75% 0.4341 -15.06%

The attribution points toward timing as the main source of historical performance in this experiment. The constituent construction uses the current CSI 300 list, so the A-share study may contain survivorship bias.


โ‚ฟ BTC timing research

Stage Cumulative return Sharpe Max drawdown
Default MACD 12,26,9 +135.44% 0.9987 -32.10%
Optimized MACD 16,35,9 +338.95% 1.6079 -21.65%
MACD + Fear & Greed + 3% stop +423.22% gross 1.7001 pre-cost series -15.66% simulated
Final cost estimate +383.97% net Pending recomputation -16.25%

Additional experiments cover funding-rate filters, on-chain active addresses, volume, multi-timeframe confirmation, short selling, and dynamic position sizing. The notebook keeps these branches even when they reduce performance.


๐Ÿค– Machine learning signals

Target Frequency Samples Accuracy Reading
5-day return above 1% Daily 1,123 51% Near random
Positive 10-day return Daily 1,123 45% Below random
24-hour price direction Hourly 28,217 47% Near random
24-hour volatility level Hourly 28,217 67% Exploratory; threshold uses the full sample

The volatility classifier was also tested as a risk filter. Its stronger classification score did not remove the fee problem from the higher-frequency strategy.


โšก Install

The saved notebooks were last executed with Python 3.13.5 kernels.

git clone https://github.com/okht/quant-research.git
cd quant-research

python -m venv .venv
source .venv/bin/activate
python -m pip install jupyterlab pandas numpy matplotlib akshare ccxt requests xgboost scikit-learn

jupyter lab

On Windows PowerShell, activate the environment with:

.\.venv\Scripts\Activate.ps1

The repository has no lockfile or automated environment check. Package behavior may differ across versions.


๐Ÿš€ Reproduce the research

Suggested reading and execution order:

Order Notebook Purpose
1 01_data/01_data_cleaning.ipynb A-share acquisition, cleaning, and first factor checks
2 02_factors/02_factor_ictest.ipynb Momentum, reversal, turnover, and composite IC tests
3 03_backtest/03_backtest.ipynb A-share backtest, risk control, position sizing, and attribution
4 03_backtest/03_roe_factor.ipynb ROE data experiment
5 04_crypto/01_crypto_data.ipynb Crypto data, timing strategies, validation, and cost checks
6 02_factors/04_ml_factor.ipynb XGBoost experiments using the crypto data snapshots

Some cells load committed CSV snapshots; others call public market-data endpoints. Refreshing the Binance funding-rate section currently assumes a local proxy at 127.0.0.1:7897. Remove or adapt that proxy configuration before rerunning it elsewhere.

The notebooks contain sequential exploratory cells. Restart the kernel and run carefully, checking which variables and data ranges each later cell inherits.


๐Ÿ“ Methodology and assumptions

Topic Current implementation
Signal timing Strategy signals are generally shifted by one period before return application
BTC transaction cost Final estimate subtracts 0.1% when the signal changes
Slippage and spread Omitted
Stop loss Simulated by clipping a daily strategy return at the chosen threshold
Parameter search Multiple MACD grids are tested; full-sample and walk-forward results are both retained
A-share universe Built from a current CSI 300 constituent pull, with possible survivorship bias
ML volatility label Uses a full-sample median threshold, which leaks test-period information
Reproducibility Data snapshots and outputs are committed; dependency versions are not pinned

These assumptions materially affect the results. A production-quality evaluation would need point-in-time universes, clean train/validation/test boundaries, slippage, execution constraints, after-cost risk metrics, and independent reruns.


๐Ÿ—‚ Data snapshots

File Rows Coverage or role
03_backtest/close_data.csv 781 ร— 296 assets A-share close-price panel
03_backtest/volume_data.csv 781 ร— 296 assets A-share turnover panel
03_backtest/roe_data.csv 781 ร— 46 assets Partial ROE panel
04_crypto/btc_daily.csv 1,183 BTC/USDT daily, 2023-01-01 โ†’ 2026-03-28
04_crypto/btc_1h.csv 28,385 BTC/USDT hourly, 2023-01-01 โ†’ 2026-03-28
04_crypto/btc_funding_full.csv 7,174 BTC perpetual funding rate
04_crypto/btc_fng.csv 2,000 Fear & Greed Index
04_crypto/btc_active_addr.csv 2,000 On-chain active-address snapshot
04_crypto/crypto_close.csv 1,183 ร— 10 assets Multi-crypto close-price panel

Committed market data can have licensing, redistribution, revision, and timestamp considerations. Check the source terms before reusing it elsewhere.


๐Ÿ“‚ Project structure

quant-research/
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ README_CN.md
โ”œโ”€โ”€ 01_data/
โ”‚   โ””โ”€โ”€ 01_data_cleaning.ipynb
โ”œโ”€โ”€ 02_factors/
โ”‚   โ”œโ”€โ”€ 02_factor_ictest.ipynb
โ”‚   โ””โ”€โ”€ 04_ml_factor.ipynb
โ”œโ”€โ”€ 03_backtest/
โ”‚   โ”œโ”€โ”€ 03_backtest.ipynb
โ”‚   โ”œโ”€โ”€ 03_roe_factor.ipynb
โ”‚   โ”œโ”€โ”€ close_data.csv
โ”‚   โ”œโ”€โ”€ volume_data.csv
โ”‚   โ””โ”€โ”€ roe_data.csv
โ””โ”€โ”€ 04_crypto/
    โ”œโ”€โ”€ 01_crypto_data.ipynb
    โ”œโ”€โ”€ btc_daily.csv
    โ”œโ”€โ”€ btc_1h.csv
    โ”œโ”€โ”€ btc_funding_full.csv
    โ”œโ”€โ”€ btc_fng.csv
    โ”œโ”€โ”€ btc_active_addr.csv
    โ””โ”€โ”€ crypto_close.csv

There is currently no 02_live_trading.ipynb or live execution module in the repository.


๐Ÿ“Œ Limitations

  • This repository is a research archive built from historical data and exploratory notebooks.
  • Full-sample results include model and parameter-selection risk.
  • The final after-cost BTC return and the reported Sharpe come from different return series.
  • The daily stop model omits intraday path, gaps, order-book depth, spread, and slippage.
  • Tight daily-return clipping can mechanically inflate simulated returns and does not represent executable stop-loss behavior.
  • The A-share universe may contain survivorship bias.
  • The ML volatility label uses information from the full dataset.
  • Saved outputs may differ when data providers revise history or dependencies change.
  • No broker integration, order management, risk service, monitoring, or live-trading safeguards are included.

For research and education only. No investment advice or production trading system is provided.


A research result is useful when its assumptions and failures remain inspectable.


Maintained by okht

About

Reproducible A-share, BTC, and ML research notebooks with explicit assumptions, failures, and backtest limits.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages