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.
- bbstrader-2.0.1/.github/workflows/cpp_linux.yml → bbstrader-2.0.3/.github/workflows/build.yml +26 -4
- {bbstrader-2.0.1 → bbstrader-2.0.3}/.github/workflows/python.yml +56 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/.gitignore +0 -1
- {bbstrader-2.0.1 → bbstrader-2.0.3}/PKG-INFO +78 -53
- {bbstrader-2.0.1 → bbstrader-2.0.3}/README.md +74 -50
- bbstrader-2.0.3/VERSION.txt +1 -0
- bbstrader-2.0.3/bbstrader/assets/bbstrader.ico +0 -0
- bbstrader-2.0.3/bbstrader/assets/bbstrader.png +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/btengine/backtest.py +5 -5
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/btengine/data.py +2 -5
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/btengine/execution.py +2 -9
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/btengine/portfolio.py +5 -1
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/btengine/strategy.py +5 -1
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/core/strategy.py +6 -7
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/trading/execution.py +6 -6
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/trading/strategy.py +4 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/cmake/Helpers.cmake +1 -1
- {bbstrader-2.0.1 → bbstrader-2.0.3}/pyproject.toml +3 -2
- {bbstrader-2.0.1 → bbstrader-2.0.3}/src/metatrader.cpp +4 -2
- bbstrader-2.0.3/tcopier.iss +25 -0
- bbstrader-2.0.3/tcopier.spec +56 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/api/test_metatrader_client.py +1 -1
- {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/btengine/test_execution.py +4 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/btengine/test_portfolio.py +0 -2
- bbstrader-2.0.1/.github/workflows/cpp_macos.yml +0 -66
- bbstrader-2.0.1/.github/workflows/cpp_win.yml +0 -62
- bbstrader-2.0.1/VERSION.txt +0 -1
- {bbstrader-2.0.1 → bbstrader-2.0.3}/.clang-format +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/.clang-tidy +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/.readthedocs.yaml +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/CMakeLists.txt +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/LICENSE +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/__init__.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/__main__.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/api/__init__.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/api/handlers.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/api/metatrader_client.pyi +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3/bbstrader}/assets/bbs_.png +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3/bbstrader}/assets/qs_metrics_1.png +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/btengine/__init__.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/btengine/event.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/btengine/performance.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/compat.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/config.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/core/__init__.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/core/data.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/metatrader/__init__.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/metatrader/_copier.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/metatrader/account.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/metatrader/broker.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/metatrader/copier.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/metatrader/rates.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/metatrader/risk.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/metatrader/trade.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/metatrader/utils.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/models/__init__.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/models/nlp.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/models/optimization.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/scripts.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/trading/__init__.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/bbstrader/trading/utils.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/cmake/Versions.cmake +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/docs/Doxyfile.in +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/docs/Makefile +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/docs/bbstrader.api.rst +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/docs/bbstrader.btengine.rst +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/docs/bbstrader.core.rst +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/docs/bbstrader.metatrader.rst +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/docs/bbstrader.models.rst +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/docs/bbstrader.rst +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/docs/bbstrader.trading.rst +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/docs/conf.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/docs/index.rst +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/docs/make.bat +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/docs/modules.rst +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/docs/requirements.txt +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/examples/strategies.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/include/bbstrader/metatrader.hpp +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/include/bbstrader/objects.hpp +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/src/CMakeLists.txt +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/src/bbstrader.cpp +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/src/cmake/BbstraderConfig.cmake.in +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/CMakeLists.txt +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/__init__.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/api/__init__.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/btengine/__init__.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/btengine/test_backtest.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/btengine/test_data.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/btengine/test_events.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/cpp/test_metatrader_client.cpp +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/metatrader/__init__.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/metatrader/test_account.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/metatrader/test_rates.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/metatrader/test_risk_management.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/tests/metatrader/test_trade.py +0 -0
- {bbstrader-2.0.1 → bbstrader-2.0.3}/vcpkg.json +0 -0
bbstrader-2.0.1/.github/workflows/cpp_linux.yml → bbstrader-2.0.3/.github/workflows/build.yml
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
name:
|
|
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
|
|
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
|
|
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/*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bbstrader
|
|
3
|
-
Version: 2.0.
|
|
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.
|
|
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
|
[](https://pypi.org/project/bbstrader/)
|
|
55
56
|
[](https://pypi.python.org/pypi/bbstrader)
|
|
56
57
|
[](https://pypi.org/project/bbstrader/)
|
|
57
|
-
[](https://github.com/bbalouki/bbstrader/actions/workflows/build.yml)
|
|
59
|
+

|
|
60
|
+

|
|
61
|
+

|
|
60
62
|
[](https://isocpp.org/std/the-standard)
|
|
61
63
|
[](https://cmake.org/)
|
|
62
64
|
[](https://pepy.tech/projects/bbstrader)
|
|
@@ -64,7 +66,9 @@ Description-Content-Type: text/markdown
|
|
|
64
66
|
[](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
|
|
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.
|
|
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
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
In today's hyper-fast financial landscape, every microsecond counts.
|
|
103
|
-
|
|
104
|
-
**Flexible Interface**: CLI & GUI
|
|
105
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
-

|
|
150
|
-

|
|
151
158
|
|
|
159
|
+

|
|
160
|
+

|
|
152
161
|
|
|
153
162
|
### 2. **metatrader**: The C++/Python Bridge to MT5
|
|
154
163
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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
|
-
|
|
284
|
-
|
|
285
|
-
|
|
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
|
|
325
|
-
|
|
|
326
|
-
| **Run Backtest**
|
|
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**
|
|
329
|
-
| **Get 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
|
-
|
|
348
|
-
|
|
349
|
-
|
|
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
|
-
|
|
396
|
+
_Disclaimer: Trading involves significant risk. `bbstrader` provides the tools, but you provide the strategy. Test thoroughly on demo accounts before deploying real capital._
|