bbstrader 2.0.1__tar.gz → 2.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. bbstrader-2.0.1/.github/workflows/cpp_linux.yml → bbstrader-2.0.3/.github/workflows/build.yml +26 -4
  2. {bbstrader-2.0.1 → bbstrader-2.0.3}/.github/workflows/python.yml +56 -0
  3. {bbstrader-2.0.1 → bbstrader-2.0.3}/.gitignore +0 -1
  4. {bbstrader-2.0.1 → bbstrader-2.0.3}/PKG-INFO +78 -53
  5. {bbstrader-2.0.1 → bbstrader-2.0.3}/README.md +74 -50
  6. bbstrader-2.0.3/VERSION.txt +1 -0
  7. bbstrader-2.0.3/bbstrader/assets/bbstrader.ico +0 -0
  8. bbstrader-2.0.3/bbstrader/assets/bbstrader.png +0 -0
  9. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/btengine/backtest.py +5 -5
  10. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/btengine/data.py +2 -5
  11. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/btengine/execution.py +2 -9
  12. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/btengine/portfolio.py +5 -1
  13. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/btengine/strategy.py +5 -1
  14. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/core/strategy.py +6 -7
  15. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/trading/execution.py +6 -6
  16. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/trading/strategy.py +4 -0
  17. {bbstrader-2.0.1 → bbstrader-2.0.3}/cmake/Helpers.cmake +1 -1
  18. {bbstrader-2.0.1 → bbstrader-2.0.3}/pyproject.toml +3 -2
  19. {bbstrader-2.0.1 → bbstrader-2.0.3}/src/metatrader.cpp +4 -2
  20. bbstrader-2.0.3/tcopier.iss +25 -0
  21. bbstrader-2.0.3/tcopier.spec +56 -0
  22. {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/api/test_metatrader_client.py +1 -1
  23. {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/btengine/test_execution.py +4 -0
  24. {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/btengine/test_portfolio.py +0 -2
  25. bbstrader-2.0.1/.github/workflows/cpp_macos.yml +0 -66
  26. bbstrader-2.0.1/.github/workflows/cpp_win.yml +0 -62
  27. bbstrader-2.0.1/VERSION.txt +0 -1
  28. {bbstrader-2.0.1 → bbstrader-2.0.3}/.clang-format +0 -0
  29. {bbstrader-2.0.1 → bbstrader-2.0.3}/.clang-tidy +0 -0
  30. {bbstrader-2.0.1 → bbstrader-2.0.3}/.readthedocs.yaml +0 -0
  31. {bbstrader-2.0.1 → bbstrader-2.0.3}/CMakeLists.txt +0 -0
  32. {bbstrader-2.0.1 → bbstrader-2.0.3}/LICENSE +0 -0
  33. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/__init__.py +0 -0
  34. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/__main__.py +0 -0
  35. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/api/__init__.py +0 -0
  36. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/api/handlers.py +0 -0
  37. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/api/metatrader_client.pyi +0 -0
  38. {bbstrader-2.0.1 → bbstrader-2.0.3/bbstrader}/assets/bbs_.png +0 -0
  39. {bbstrader-2.0.1 → bbstrader-2.0.3/bbstrader}/assets/qs_metrics_1.png +0 -0
  40. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/btengine/__init__.py +0 -0
  41. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/btengine/event.py +0 -0
  42. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/btengine/performance.py +0 -0
  43. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/compat.py +0 -0
  44. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/config.py +0 -0
  45. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/core/__init__.py +0 -0
  46. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/core/data.py +0 -0
  47. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/metatrader/__init__.py +0 -0
  48. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/metatrader/_copier.py +0 -0
  49. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/metatrader/account.py +0 -0
  50. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/metatrader/broker.py +0 -0
  51. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/metatrader/copier.py +0 -0
  52. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/metatrader/rates.py +0 -0
  53. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/metatrader/risk.py +0 -0
  54. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/metatrader/trade.py +0 -0
  55. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/metatrader/utils.py +0 -0
  56. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/models/__init__.py +0 -0
  57. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/models/nlp.py +0 -0
  58. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/models/optimization.py +0 -0
  59. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/scripts.py +0 -0
  60. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/trading/__init__.py +0 -0
  61. {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/trading/utils.py +0 -0
  62. {bbstrader-2.0.1 → bbstrader-2.0.3}/cmake/Versions.cmake +0 -0
  63. {bbstrader-2.0.1 → bbstrader-2.0.3}/docs/Doxyfile.in +0 -0
  64. {bbstrader-2.0.1 → bbstrader-2.0.3}/docs/Makefile +0 -0
  65. {bbstrader-2.0.1 → bbstrader-2.0.3}/docs/bbstrader.api.rst +0 -0
  66. {bbstrader-2.0.1 → bbstrader-2.0.3}/docs/bbstrader.btengine.rst +0 -0
  67. {bbstrader-2.0.1 → bbstrader-2.0.3}/docs/bbstrader.core.rst +0 -0
  68. {bbstrader-2.0.1 → bbstrader-2.0.3}/docs/bbstrader.metatrader.rst +0 -0
  69. {bbstrader-2.0.1 → bbstrader-2.0.3}/docs/bbstrader.models.rst +0 -0
  70. {bbstrader-2.0.1 → bbstrader-2.0.3}/docs/bbstrader.rst +0 -0
  71. {bbstrader-2.0.1 → bbstrader-2.0.3}/docs/bbstrader.trading.rst +0 -0
  72. {bbstrader-2.0.1 → bbstrader-2.0.3}/docs/conf.py +0 -0
  73. {bbstrader-2.0.1 → bbstrader-2.0.3}/docs/index.rst +0 -0
  74. {bbstrader-2.0.1 → bbstrader-2.0.3}/docs/make.bat +0 -0
  75. {bbstrader-2.0.1 → bbstrader-2.0.3}/docs/modules.rst +0 -0
  76. {bbstrader-2.0.1 → bbstrader-2.0.3}/docs/requirements.txt +0 -0
  77. {bbstrader-2.0.1 → bbstrader-2.0.3}/examples/strategies.py +0 -0
  78. {bbstrader-2.0.1 → bbstrader-2.0.3}/include/bbstrader/metatrader.hpp +0 -0
  79. {bbstrader-2.0.1 → bbstrader-2.0.3}/include/bbstrader/objects.hpp +0 -0
  80. {bbstrader-2.0.1 → bbstrader-2.0.3}/src/CMakeLists.txt +0 -0
  81. {bbstrader-2.0.1 → bbstrader-2.0.3}/src/bbstrader.cpp +0 -0
  82. {bbstrader-2.0.1 → bbstrader-2.0.3}/src/cmake/BbstraderConfig.cmake.in +0 -0
  83. {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/CMakeLists.txt +0 -0
  84. {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/__init__.py +0 -0
  85. {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/api/__init__.py +0 -0
  86. {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/btengine/__init__.py +0 -0
  87. {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/btengine/test_backtest.py +0 -0
  88. {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/btengine/test_data.py +0 -0
  89. {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/btengine/test_events.py +0 -0
  90. {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/cpp/test_metatrader_client.cpp +0 -0
  91. {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/metatrader/__init__.py +0 -0
  92. {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/metatrader/test_account.py +0 -0
  93. {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/metatrader/test_rates.py +0 -0
  94. {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/metatrader/test_risk_management.py +0 -0
  95. {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/metatrader/test_trade.py +0 -0
  96. {bbstrader-2.0.1 → bbstrader-2.0.3}/vcpkg.json +0 -0
@@ -1,4 +1,4 @@
1
- name: Linux
1
+ name: build
2
2
 
3
3
  on:
4
4
  pull_request:
@@ -7,12 +7,13 @@ on:
7
7
 
8
8
  jobs:
9
9
  build-and-test:
10
- runs-on: ubuntu-latest
11
10
  strategy:
12
11
  fail-fast: false
13
12
  matrix:
13
+ os: [ubuntu-latest, windows-latest, macos-latest]
14
14
  build_type: [Release, Debug]
15
15
  cpp_standard: [20, 23]
16
+ runs-on: ${{ matrix.os }}
16
17
  env:
17
18
  VCPKG_ROOT: ${{ github.workspace }}/vcpkg
18
19
  BUILD_DIR: ${{ github.workspace }}/build
@@ -43,10 +44,31 @@ jobs:
43
44
  restore-keys: |
44
45
  ${{ runner.os }}-${{ matrix.build_type }}-cmake-
45
46
 
46
- - name: Install system package
47
+ - name: Install system packages (Linux)
48
+ if: runner.os == 'Linux'
47
49
  shell: bash
48
50
  run: sudo apt install autoconf autoconf-archive automake libtool
49
51
 
52
+ - name: Install system packages (macOS)
53
+ if: runner.os == 'macOS'
54
+ shell: bash
55
+ run: brew install autoconf autoconf-archive automake libtool
56
+
57
+ - name: Set VCPKG Triplet
58
+ shell: bash
59
+ run: |
60
+ if [ "$RUNNER_OS" == "Windows" ]; then
61
+ echo "VCPKG_TARGET_TRIPLET=x64-windows" >> $GITHUB_ENV
62
+ elif [ "$RUNNER_OS" == "Linux" ]; then
63
+ echo "VCPKG_TARGET_TRIPLET=x64-linux" >> $GITHUB_ENV
64
+ else
65
+ if [ "$(uname -m)" == "arm64" ]; then
66
+ echo "VCPKG_TARGET_TRIPLET=arm64-osx" >> $GITHUB_ENV
67
+ else
68
+ echo "VCPKG_TARGET_TRIPLET=x64-osx" >> $GITHUB_ENV
69
+ fi
70
+ fi
71
+
50
72
  - name: Configure CMake
51
73
  shell: bash
52
74
  run: |
@@ -55,7 +77,7 @@ jobs:
55
77
  -DBBSTRADER_CXX_STANDARD=${{ matrix.cpp_standard }} \
56
78
  -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
57
79
  -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake \
58
- -DVCPKG_TARGET_TRIPLET=x64-linux
80
+ -DVCPKG_TARGET_TRIPLET=$VCPKG_TARGET_TRIPLET
59
81
 
60
82
  - name: Build
61
83
  shell: bash
@@ -68,6 +68,44 @@ jobs:
68
68
  name: cibw-sdist
69
69
  path: dist/*.tar.gz
70
70
 
71
+ build_installer:
72
+ name: Build Windows Installer
73
+ runs-on: windows-latest
74
+ steps:
75
+ - uses: actions/checkout@v4
76
+ - name: Set up Python
77
+ uses: actions/setup-python@v4
78
+ with:
79
+ python-version: '3.12'
80
+
81
+ - name: Install dependencies
82
+ run: |
83
+ pip install pyinstaller
84
+ pip install .[MT5]
85
+
86
+ - name: Build executable
87
+ run: pyinstaller tcopier.spec
88
+
89
+ - name: Replace version in Inno Setup script
90
+ run: |
91
+ $version = "${{ github.ref_name }}".Substring(1)
92
+ (Get-Content tcopier.iss) -replace '__VERSION__', $version | Set-Content tcopier.iss
93
+
94
+ - name: Install Inno Setup (via Chocolatey)
95
+ run: |
96
+ choco install innosetup --no-progress
97
+ echo "C:\Program Files (x86)\Inno Setup 6" >> $env:GITHUB_PATH
98
+
99
+ - name: Compile installer
100
+ run: iscc tcopier.iss
101
+
102
+ - name: Upload installer artifact
103
+ uses: actions/upload-artifact@v4
104
+ with:
105
+ name: installer
106
+ path: "**/TradeCopier.exe"
107
+
108
+
71
109
  publish:
72
110
  needs: [build_wheels, build_sdist]
73
111
  runs-on: ubuntu-latest
@@ -84,3 +122,21 @@ jobs:
84
122
  with:
85
123
  user: __token__
86
124
  password: ${{ secrets.BBSTRADER_PYPI_API_TOKEN }}
125
+
126
+ release:
127
+ name: Create GitHub Release
128
+ needs: [build_installer, publish]
129
+ runs-on: ubuntu-latest
130
+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
131
+
132
+ steps:
133
+ - name: Download artifacts
134
+ uses: actions/download-artifact@v4
135
+ with:
136
+ path: dist
137
+ merge-multiple: true
138
+
139
+ - name: Create GitHub Release
140
+ uses: softprops/action-gh-release@v2
141
+ with:
142
+ files: dist/*
@@ -16,7 +16,6 @@ notes.txt
16
16
  *.h5
17
17
  *ipynb_checkpoints/
18
18
  *.exe
19
- *.iss
20
19
  cmd.ps1
21
20
  .vscode
22
21
  CMakePresets.json
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bbstrader
3
- Version: 2.0.1
4
- Summary: Simplified Investment & Trading Toolkit
3
+ Version: 2.0.3
4
+ Summary: Simplified Investment & Trading Toolkit with Python & C++
5
5
  Keywords: Finance,Toolkit,Financial,Analysis,Fundamental,Quantitative,Database,Equities,Currencies,Economics,ETFs,Funds,Indices,Moneymarkets,Commodities,Futures,CFDs,Derivatives,Trading,Investing,Portfolio,Optimization,Performance
6
6
  Author-Email: Bertin Balouki SIMYELI <bertin@bbs-trading.com>
7
7
  Maintainer-Email: Bertin Balouki SIMYELI <bertin@bbs-trading.com>
@@ -10,6 +10,7 @@ Classifier: Development Status :: 5 - Production/Stable
10
10
  Classifier: Intended Audience :: Developers
11
11
  Classifier: Topic :: Office/Business :: Financial :: Investment
12
12
  Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: C++
13
14
  Classifier: Operating System :: Microsoft :: Windows
14
15
  Classifier: Operating System :: POSIX :: Linux
15
16
  Classifier: Operating System :: MacOS
@@ -37,7 +38,7 @@ Requires-Dist: python-telegram-bot>=22.3
37
38
  Requires-Dist: PyYAML>=6.0.2
38
39
  Requires-Dist: QuantStats>=0.0.77
39
40
  Requires-Dist: seaborn>=0.13.2
40
- Requires-Dist: spacy>=3.8.7
41
+ Requires-Dist: spacy>=3.8.11
41
42
  Requires-Dist: sumy>=0.11.0
42
43
  Requires-Dist: tabulate>=0.9.0
43
44
  Requires-Dist: textblob>=0.19.0
@@ -54,9 +55,10 @@ Description-Content-Type: text/markdown
54
55
  [![PYPI Version](https://img.shields.io/pypi/v/bbstrader)](https://pypi.org/project/bbstrader/)
55
56
  [![PyPi status](https://img.shields.io/pypi/status/bbstrader.svg?maxAge=60)](https://pypi.python.org/pypi/bbstrader)
56
57
  [![Supported Python Versions](https://img.shields.io/pypi/pyversions/bbstrader)](https://pypi.org/project/bbstrader/)
57
- [![Linux](https://github.com/bbalouki/bbstrader/actions/workflows/cpp_linux.yml/badge.svg)](https://github.com/bbalouki/bbstrader/actions/workflows/cpp_linux.yml)
58
- [![macOS](https://github.com/bbalouki/bbstrader/actions/workflows/cpp_macos.yml/badge.svg)](https://github.com/bbalouki/bbstrader/actions/workflows/cpp_macos.yml)
59
- [![Windows](https://github.com/bbalouki/bbstrader/actions/workflows/cpp_win.yml/badge.svg)](https://github.com/bbalouki/bbstrader/actions/workflows/cpp_win.yml)
58
+ [![Build](https://github.com/bbalouki/bbstrader/actions/workflows/build.yml/badge.svg)](https://github.com/bbalouki/bbstrader/actions/workflows/build.yml)
59
+ ![Linux](https://img.shields.io/badge/Linux-FCC624?logo=linux&logoColor=black)
60
+ ![macOS](https://img.shields.io/badge/macOS-000000?logo=apple&logoColor=white)
61
+ ![Windows](https://img.shields.io/badge/Windows-0078D6?logo=windows&logoColor=white)
60
62
  [![C++20](https://img.shields.io/badge/C++-20-blue.svg)](https://isocpp.org/std/the-standard)
61
63
  [![CMake](https://img.shields.io/badge/CMake-3.20+-blue.svg)](https://cmake.org/)
62
64
  [![PyPI Downloads](https://static.pepy.tech/badge/bbstrader)](https://pepy.tech/projects/bbstrader)
@@ -64,7 +66,9 @@ Description-Content-Type: text/markdown
64
66
  [![LinkedIn](https://img.shields.io/badge/LinkedIn-grey?logo=Linkedin&logoColor=white)](https://www.linkedin.com/in/bertin-balouki-s-15b17a1a6)
65
67
 
66
68
  ## Welcome to `bbstrader` – The Ultimate C++ & Python Trading Powerhouse!
69
+
67
70
  ## Table of Contents
71
+
68
72
  - [Overview](#overview)
69
73
  - [Why `bbstrader` Stands Out](#why-bbstrader-stands-out)
70
74
  - [Trusted by Traders Worldwide](#trusted-by-traders-worldwide)
@@ -74,7 +78,7 @@ Description-Content-Type: text/markdown
74
78
  - [1. `btengine`: Event-Driven Backtesting Beast](#1-btengine-event-driven-backtesting-beast)
75
79
  - [2. `metatrader`: The C++/Python Bridge to MT5](#2-metatrader-the-cpython-bridge-to-mt5)
76
80
  - [Pattern 1: C++ Core, Python Orchestrator (Maximum Performance)](#pattern-1-c-core-python-orchestrator-maximum-performance)
77
- - [Pattern 2: Python-Driven with C++ Acceleration](#pattern-2-python-driven-with-c-acceleration)
81
+ - [Pattern 2: Python-Driven with C++ Acceleration](#pattern-2-python-driven-with-c-acceleration)
78
82
  - [3. `trading`: Live Execution & Strategy Orchestrator](#3-trading-live-execution--strategy-orchestrator)
79
83
  - [4. `models`: Quant Toolkit for Signals & Risk](#4-models-quant-toolkit-for-signals--risk)
80
84
  - [Getting Started](#getting-started)
@@ -88,54 +92,59 @@ Description-Content-Type: text/markdown
88
92
 
89
93
  ### Overview
90
94
 
91
- Imagine having the raw, blistering speed of C++ for your high-frequency trades, combined with Python's ecosystem for lightning-fast prototyping, advanced AI models, and seamless data analysis. That's ``bbstrader`` – not just a library, but a game-changing toolkit designed for quants, algo traders, and institutional pros who demand an edge in volatile markets. Whether you're scalping forex pairs, backtesting complex strategies, or copying trades across accounts in real-time, ``bbstrader`` empowers you to build, test, and deploy with unmatched efficiency.
95
+ Imagine having the raw, blistering speed of C++ for your high-frequency trades, combined with Python's ecosystem for lightning-fast prototyping, advanced AI models, and seamless data analysis. That's `bbstrader` – not just a library, but a game-changing toolkit designed for quants, algo traders, and institutional pros who demand an edge in volatile markets. Whether you're scalping forex pairs, backtesting complex strategies, or copying trades across accounts in real-time, `bbstrader` empowers you to build, test, and deploy with unmatched efficiency.
92
96
 
93
- Forget the frustrations of slow Python bottlenecks or MQL5's rigid sandbox. ``bbstrader`` bridges worlds: C++ for mission-critical performance and Python for intelligent orchestration. It's open-source, battle-tested across platforms, and ready to supercharge your trading arsenal.
97
+ Forget the frustrations of slow Python bottlenecks or MQL5's rigid sandbox. `bbstrader` bridges worlds: C++ for mission-critical performance and Python for intelligent orchestration. It's open-source, battle-tested across platforms, and ready to supercharge your trading arsenal.
94
98
 
95
99
  ## **Why `bbstrader` Stands Out**
96
100
 
97
101
  In a crowded field of trading libraries, `bbstrader` is architected to solve the most challenging problems in algorithmic trading: performance, flexibility, and platform limitations.
98
102
 
99
- * **Blazing Speed with C++ Core**: Compile your strategy logic in native C++ for deterministic, low-latency execution. Perfect for HFT, arbitrage, or compute-heavy models that Python alone can't handle.
100
- * **Python's Powerhouse Ecosystem**: Leverage ``NumPy``, ``pandas``, ``scikit-learn``, ``TensorFlow``, and more for research, ML-driven signals, and backtesting – all seamlessly integrated with your C++ core.
101
- * **Institutional-Grade Architecture:** From its event-driven backtester to its modular design, `bbstrader` is built with the principles of professional trading systems in mind, providing a robust foundation for serious strategy development.
102
- In today's hyper-fast financial landscape, every microsecond counts. ``bbstrader`` isn't another lightweight wrapper – it's an institutional-grade powerhouse engineered to tackle real-world trading challenges head-on.
103
- * **Break Free from MQL5 Limits**: Ditch interpreted code and ecosystem constraints. Build multi-threaded, AI-infused strategies that execute orders in microseconds via MetaTrader 5 (MT5) integration.
104
- **Flexible Interface**: CLI & GUI
105
- ``bbstrader`` adapts to your workflow.
103
+ - **Blazing Speed with C++ Core**: Compile your strategy logic in native C++ for deterministic, low-latency execution. Perfect for HFT, arbitrage, or compute-heavy models that Python alone can't handle.
104
+ - **Python's Powerhouse Ecosystem**: Leverage `NumPy`, `pandas`, `scikit-learn`, `TensorFlow`, and more for research, ML-driven signals, and backtesting – all seamlessly integrated with your C++ core.
105
+ - **Institutional-Grade Architecture:** From its event-driven backtester to its modular design, `bbstrader` is built with the principles of professional trading systems in mind, providing a robust foundation for serious strategy development.
106
+ In today's hyper-fast financial landscape, every microsecond counts. `bbstrader` isn't another lightweight wrapper – it's an institutional-grade powerhouse engineered to tackle real-world trading challenges head-on.
107
+ - **Break Free from MQL5 Limits**: Ditch interpreted code and ecosystem constraints. Build multi-threaded, AI-infused strategies that execute orders in microseconds via MetaTrader 5 (MT5) integration.
108
+ **Flexible Interface**: CLI & GUI
109
+ `bbstrader` adapts to your workflow.
106
110
  - **Automation Fanatics**: Use the CLI for headless scripts, cron jobs, and server deployments.
107
111
  - **Visual Traders**: Launch the Desktop GUI (currently for Copy Trading) to monitor your master and slave accounts, check replication status, and manage connections visually.
108
112
  - **Cross-Platform & Future-Proof**: Works on Windows, macOS, Linux. (IBKR integration in development).
109
113
 
110
114
  ## **Trusted by Traders Worldwide**
111
- With thousands of downloads, ``bbstrader`` is trusted by traders worldwide. It's not just code – it's your ticket to profitable, scalable strategies.
115
+
116
+ With thousands of downloads, `bbstrader` is trusted by traders worldwide. It's not just code – it's your ticket to profitable, scalable strategies.
112
117
 
113
118
  ## **The `bbstrader` Edge: Uniting C++ Speed with Python Flexibility**
114
119
 
115
- bbstrader's hybrid design is its secret weapon. At the heart is a bidirectional C++/Python bridge via ``metatrader_client`` module:
120
+ bbstrader's hybrid design is its secret weapon. At the heart is a bidirectional C++/Python bridge via `metatrader_client` module:
116
121
 
117
- 1. **C++ for Speed**: Core classes like ``MetaTraderClient`` handle high-performance tasks. Inject Python handlers for MT5 interactions, enabling native-speed signal generation and risk checks.
118
- 2. **Python for Smarts**: Orchestrate everything with modules like ``trading`` and ``btengine``.
119
- 3. **The Data Flow:** The result is a clean, efficient, and powerful execution loop:
120
- `Python (Orchestration & Analysis) -> C++ (High-Speed Signal Generation) -> Python (MT5 Communication) -> C++ (Receives Market Data)`
122
+ 1. **C++ for Speed**: Core classes like `MetaTraderClient` handle high-performance tasks. Inject Python handlers for MT5 interactions, enabling native-speed signal generation and risk checks.
123
+ 2. **Python for Smarts**: Orchestrate everything with modules like `trading` and `btengine`.
124
+ 3. **The Data Flow:** The result is a clean, efficient, and powerful execution loop:
125
+ `Python (Orchestration & Analysis) -> C++ (High-Speed Signal Generation) -> Python (MT5 Communication) -> C++ (Receives Market Data)`
121
126
 
122
127
  This setup crushes performance ceilings: Run ML models in Python, execute trades in C++, and backtest millions of bars in minutes.
123
128
 
124
129
  ### **Overcoming the MQL5 Bottleneck**
130
+
125
131
  MetaTrader 5 is a world-class trading platform, but its native MQL5 language presents significant limitations for complex, high-frequency strategies:
126
- - **Performance Ceilings:** As an interpreted language, MQL5 struggles with the computationally intensive logic required for advanced statistical models, machine learning, and rapid-fire order execution.
127
- - **Ecosystem Constraints:** MQL5 lacks access to the vast, mature ecosystems of libraries for numerical computation, data science, and AI that C++ and Python offer.
128
- - **Architectural Rigidity:** Implementing sophisticated, multi-threaded, or event-driven architectures in MQL5 is often a complex and error-prone endeavor.
132
+
133
+ - **Performance Ceilings:** As an interpreted language, MQL5 struggles with the computationally intensive logic required for advanced statistical models, machine learning, and rapid-fire order execution.
134
+ - **Ecosystem Constraints:** MQL5 lacks access to the vast, mature ecosystems of libraries for numerical computation, data science, and AI that C++ and Python offer.
135
+ - **Architectural Rigidity:** Implementing sophisticated, multi-threaded, or event-driven architectures in MQL5 is often a complex and error-prone endeavor.
129
136
 
130
137
  `bbstrader` eradicates these barriers. By moving your core strategy logic to C++, you can unlock the full potential of your trading ideas, executing them with the microsecond-level precision demanded by institutional trading.
131
138
 
132
139
  ## **Key Modules**
140
+
133
141
  bbstrader is modular, with each component laser-focused.
134
142
 
135
143
  ### 1. **btengine**: Event-Driven Backtesting Beast
136
- - **Purpose**: Simulate strategies with historical data, including slippage, commissions, and multi-asset portfolios. Optimizes parameters and computes metrics like Sharpe Ratio, Drawdown, and CAGR.
137
- - **Features**: Event queue for ticks/orders, vectorized operations for speed, integration with models for signal generation.
138
- - **Example**: Backtest a StockIndexSTBOTrading from the example strategies.
144
+
145
+ - **Purpose**: Simulate strategies with historical data, including slippage, commissions, and multi-asset portfolios. Optimizes parameters and computes metrics like Sharpe Ratio, Drawdown, and CAGR.
146
+ - **Features**: Event queue for ticks/orders, vectorized operations for speed, integration with models for signal generation.
147
+ - **Example**: Backtest a StockIndexSTBOTrading from the example strategies.
139
148
 
140
149
  ```Python
141
150
  # Inside the examples/
@@ -146,25 +155,28 @@ if __name__ == '__main__':
146
155
  ```
147
156
 
148
157
  ### Backtesting Results
149
- ![Backtesting Results1]( https://github.com/bbalouki/bbstrader/blob/main/assets/bbs_.png?raw=true)
150
- ![Backtesting Results2](https://github.com/bbalouki/bbstrader/blob/main/assets/qs_metrics_1.png?raw=true)
151
158
 
159
+ ![Backtesting Results1](https://github.com/bbalouki/bbstrader/blob/main/bbstrader/assets/bbs_.png?raw=true)
160
+ ![Backtesting Results2](https://github.com/bbalouki/bbstrader/blob/main/bbstrader/assets/qs_metrics_1.png?raw=true)
152
161
 
153
162
  ### 2. **metatrader**: The C++/Python Bridge to MT5
154
163
 
155
- - **Purpose**: High-speed MT5 integration. C++ MetaTraderClient mirrors MT5 API for orders, rates, and account management.
156
- - **Features**: Bidirectional callbacks, error handling, real-time tick processing.
157
- - **Strategy Patterns**: Two main patterns to build strategies:
164
+ - **Purpose**: High-speed MT5 integration. C++ MetaTraderClient mirrors MT5 API for orders, rates, and account management.
165
+ - **Features**: Bidirectional callbacks, error handling, real-time tick processing.
166
+ - **Strategy Patterns**: Two main patterns to build strategies:
158
167
 
159
168
  #### Pattern 1: C++ Core, Python Orchestrator (Maximum Performance)
169
+
160
170
  This is the recommended pattern for latency-sensitive strategies, such as statistical arbitrage, market making, or any strategy where execution speed is a critical component of your edge. By compiling your core logic, you minimize interpretation overhead and gain direct control over memory and execution.
161
171
 
162
172
  **Use this pattern when:**
173
+
163
174
  - Your strategy involves complex mathematical calculations that are slow in Python.
164
175
  - You need to react to market data in the shortest possible time.
165
176
  - Your production environment demands deterministic, low-latency performance.
166
177
 
167
178
  **C++ Side (`MovingAverageStrategy.cpp`):**
179
+
168
180
  ```cpp
169
181
  #include "bbstrader/metatrader.hpp"
170
182
  #include <numeric>
@@ -176,12 +188,12 @@ public:
176
188
 
177
189
  void on_tick(const std::string& symbol) {
178
190
  auto rates_opt = copy_rates_from_pos(symbol, 1, 0, 20);
179
-
191
+
180
192
  if (!rates_opt || rates_opt->size() < 20) return;
181
193
 
182
194
  const auto& rates = *rates_opt;
183
-
184
- double sum = std::accumulate(rates.begin(), rates.end(), 0.0,
195
+
196
+ double sum = std::accumulate(rates.begin(), rates.end(), 0.0,
185
197
  [](double a, const MT5::RateInfo& b) { return a + b.close; });
186
198
  double sma = sum / rates.size();
187
199
  double current_price = rates.back().close;
@@ -200,7 +212,9 @@ public:
200
212
  }
201
213
  };
202
214
  ```
203
- *This C++ class would then be exposed to Python using `pybind11`.*
215
+
216
+ _This C++ class would then be exposed to Python using `pybind11`._
217
+
204
218
  ```cpp
205
219
  // Inside bindings.cpp
206
220
  #include <pybind11/pybind11.h>
@@ -216,6 +230,7 @@ py::class_<MovingAverageStrategy, MT5::MetaTraderClient>(m, "MovingAverageStrate
216
230
  ```
217
231
 
218
232
  **Python Side (`main.py`):**
233
+
219
234
  ```python
220
235
  from bbstrader.api import Mt5Handlers
221
236
  import MetaTrader5 as mt5
@@ -233,9 +248,11 @@ if strategy.initialize():
233
248
  ```
234
249
 
235
250
  #### Pattern 2: Python-Driven with C++ Acceleration
251
+
236
252
  This pattern is ideal for strategies that benefit from Python's rich ecosystem for data analysis, machine learning, or complex event orchestration, but still require high-performance access to market data and the trading API.
237
253
 
238
254
  **Use this pattern when:**
255
+
239
256
  - Your strategy relies heavily on Python libraries like `pandas`, `scikit-learn`, or `tensorflow`.
240
257
  - Rapid prototyping and iteration are more important than absolute minimum latency.
241
258
  - Your core logic is more about decision-making based on pre-processed data than it is about raw computation speed.
@@ -259,16 +276,17 @@ if strategy.initialize():
259
276
  print(f"Retrieved {len(rates)} rates via the C++ bridge.")
260
277
  ```
261
278
 
262
- ### 3. **``trading``: Live Execution & Strategy Orchestrator**
279
+ ### 3. **`trading`: Live Execution & Strategy Orchestrator**
263
280
 
264
281
  - **Purpose**: Manages live sessions, coordinates signals from strategies, risk from models, and execution via metatrader.
265
282
  - **Features**: Multi-account support, position hedging, trailing stops.
266
283
 
267
- ### 4. ``models``: Quant Toolkit for Signals & Risk
284
+ ### 4. `models`: Quant Toolkit for Signals & Risk
268
285
 
269
286
  - **Purpose**: Build/test models like NLP sentiment, VaR/CVaR risk, optimization.
270
287
  - **Features**: Currently Sentiment analysis, and Topic Modeling.
271
288
  - **Example**: Sentiment-Based Entry:
289
+
272
290
  ```python
273
291
  from bbstrader.models import SentimenSentimentAnalyzer
274
292
 
@@ -280,9 +298,9 @@ if score > 0.7: # Bullish? Buy!
280
298
 
281
299
  ### **Other Modules:**
282
300
 
283
- ``core``: Utilities (data structs, logging).
284
- ``config``: Manages JSON configs in ~/.bbstrader/.
285
- ``api``: Handler injections for bridges.
301
+ `core`: Utilities (data structs, logging).
302
+ `config`: Manages JSON configs in ~/.bbstrader/.
303
+ `api`: Handler injections for bridges.
286
304
 
287
305
  ## Getting Started
288
306
 
@@ -293,10 +311,13 @@ if score > 0.7: # Bullish? Buy!
293
311
  - **MT5 Broker**: [Admirals](https://one.justmarkets.link/a/tufvj0xugm/registration/trader), [JustMarkets](https://one.justmarkets.link/a/tufvj0xugm/registration/trader), [FTMO](https://trader.ftmo.com/?affiliates=JGmeuQqepAZLMcdOEQRp).
294
312
 
295
313
  ## Installation
314
+
296
315
  `bbstrader` is designed for both Python and C++ developers. Follow the instructions that best suit your needs.
297
316
 
298
317
  ### For the Python Quant
318
+
299
319
  Get started in minutes using `pip`. We strongly recommend using a virtual environment.
320
+
300
321
  ```bash
301
322
  # Create and activate a virtual environment
302
323
  python -m venv venv
@@ -309,7 +330,9 @@ pip install bbstrader # Linux/macOS
309
330
  ```
310
331
 
311
332
  ### For the C++ Developer
333
+
312
334
  To develop your own C++ strategies, you can use `vcpkg` to install the `bbstrader` library and its dependencies.
335
+
313
336
  ```bash
314
337
  # If you don't have vcpkg, clone and bootstrap it
315
338
  git clone https://github.com/microsoft/vcpkg
@@ -318,17 +341,20 @@ git clone https://github.com/microsoft/vcpkg
318
341
  # Install bbstrader
319
342
  ./vcpkg/vcpkg install bbstrader
320
343
  ```
344
+
321
345
  ## CLI workflow
346
+
322
347
  `bbstrader` shines via CLI – launch everything from one command!
323
348
 
324
- | Action | Command |
325
- | :--- | :--- |
326
- | **Run Backtest** | `python -m bbstrader --run backtest --strategy SMAStrategy --account MY_ACCOUNT --config backtest.json` |
349
+ | Action | Command |
350
+ | :----------------- | :-------------------------------------------------------------------------------------------------------------------- |
351
+ | **Run Backtest** | `python -m bbstrader --run backtest --strategy SMAStrategy --account MY_ACCOUNT --config backtest.json` |
327
352
  | **Live Execution** | `python -m bbstrader --run execution --strategy KalmanFilter --account MY_ACCOUNT --config execution.json --parallel` |
328
- | **Copy Trades** | `python -m bbstrader --run copier --source 123456 --targets 789012 --risk_multiplier 2.0` |
329
- | **Get Help** | `python -m bbstrader --help` |
353
+ | **Copy Trades** | `python -m bbstrader --run copier --source 123456 --targets 789012 --risk_multiplier 2.0` |
354
+ | **Get Help** | `python -m bbstrader --help` |
355
+
356
+ **Config Example** (`~/.bbstrader/execution/execution.json`):
330
357
 
331
- **Config Example** (``~/.bbstrader/execution/execution.json``):
332
358
  ```json
333
359
  {
334
360
  "SMAStrategy": {
@@ -344,9 +370,9 @@ git clone https://github.com/microsoft/vcpkg
344
370
 
345
371
  ## 🌍 Community & Support
346
372
 
347
- * **[Read the Docs](https://bbstrader.readthedocs.io/en/latest/)**: Full API reference and tutorials.
348
- * **[GitHub Issues](https://github.com/bbalouki/bbstrader/issues)**: Report bugs or request features.
349
- * **[LinkedIn](https://www.linkedin.com/in/bertin-balouki-s-15b17a1a6)**: Connect with the creator.
373
+ - **[Read the Docs](https://bbstrader.readthedocs.io/en/latest/)**: Full API reference and tutorials.
374
+ - **[GitHub Issues](https://github.com/bbalouki/bbstrader/issues)**: Report bugs or request features.
375
+ - **[LinkedIn](https://www.linkedin.com/in/bertin-balouki-s-15b17a1a6)**: Connect with the creator.
350
376
 
351
377
  ---
352
378
 
@@ -365,7 +391,6 @@ If you find this project useful and would like to support its continued developm
365
391
 
366
392
  ☕ [Support the Developer](https://paypal.me/bertinbalouki?country.x=SN&locale.x=en_US)
367
393
 
368
-
369
394
  ---
370
395
 
371
- *Disclaimer: Trading involves significant risk. `bbstrader` provides the tools, but you provide the strategy. Test thoroughly on demo accounts before deploying real capital.*
396
+ _Disclaimer: Trading involves significant risk. `bbstrader` provides the tools, but you provide the strategy. Test thoroughly on demo accounts before deploying real capital._