bbstrader 2.0.3__cp312-cp312-macosx_11_0_arm64.whl
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/__init__.py +27 -0
- bbstrader/__main__.py +92 -0
- bbstrader/api/__init__.py +96 -0
- bbstrader/api/handlers.py +245 -0
- bbstrader/api/metatrader_client.cpython-312-darwin.so +0 -0
- bbstrader/api/metatrader_client.pyi +624 -0
- bbstrader/assets/bbs_.png +0 -0
- bbstrader/assets/bbstrader.ico +0 -0
- bbstrader/assets/bbstrader.png +0 -0
- bbstrader/assets/qs_metrics_1.png +0 -0
- bbstrader/btengine/__init__.py +54 -0
- bbstrader/btengine/backtest.py +358 -0
- bbstrader/btengine/data.py +737 -0
- bbstrader/btengine/event.py +229 -0
- bbstrader/btengine/execution.py +287 -0
- bbstrader/btengine/performance.py +408 -0
- bbstrader/btengine/portfolio.py +393 -0
- bbstrader/btengine/strategy.py +588 -0
- bbstrader/compat.py +28 -0
- bbstrader/config.py +100 -0
- bbstrader/core/__init__.py +27 -0
- bbstrader/core/data.py +628 -0
- bbstrader/core/strategy.py +466 -0
- bbstrader/metatrader/__init__.py +48 -0
- bbstrader/metatrader/_copier.py +720 -0
- bbstrader/metatrader/account.py +865 -0
- bbstrader/metatrader/broker.py +418 -0
- bbstrader/metatrader/copier.py +1487 -0
- bbstrader/metatrader/rates.py +495 -0
- bbstrader/metatrader/risk.py +667 -0
- bbstrader/metatrader/trade.py +1692 -0
- bbstrader/metatrader/utils.py +402 -0
- bbstrader/models/__init__.py +39 -0
- bbstrader/models/nlp.py +932 -0
- bbstrader/models/optimization.py +182 -0
- bbstrader/scripts.py +665 -0
- bbstrader/trading/__init__.py +33 -0
- bbstrader/trading/execution.py +1159 -0
- bbstrader/trading/strategy.py +362 -0
- bbstrader/trading/utils.py +69 -0
- bbstrader-2.0.3.dist-info/METADATA +396 -0
- bbstrader-2.0.3.dist-info/RECORD +45 -0
- bbstrader-2.0.3.dist-info/WHEEL +5 -0
- bbstrader-2.0.3.dist-info/entry_points.txt +3 -0
- bbstrader-2.0.3.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bbstrader
|
|
3
|
+
Version: 2.0.3
|
|
4
|
+
Summary: Simplified Investment & Trading Toolkit with Python & C++
|
|
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
|
+
Author-Email: Bertin Balouki SIMYELI <bertin@bbs-trading.com>
|
|
7
|
+
Maintainer-Email: Bertin Balouki SIMYELI <bertin@bbs-trading.com>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: C++
|
|
14
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Operating System :: MacOS
|
|
17
|
+
Project-URL: Homepage, https://github.com/bbalouki/bbstrader
|
|
18
|
+
Project-URL: Download, https://pypi.org/project/bbstrader/
|
|
19
|
+
Project-URL: Documentation, https://bbstrader.readthedocs.io/en/latest/
|
|
20
|
+
Project-URL: Source Code, https://github.com/bbalouki/bbstrader
|
|
21
|
+
Requires-Python: >=3.12
|
|
22
|
+
Requires-Dist: beautifulsoup4>=4.13.5
|
|
23
|
+
Requires-Dist: colorama>=0.4.6
|
|
24
|
+
Requires-Dist: dash>=3.2.0
|
|
25
|
+
Requires-Dist: eodhd>=1.0.32
|
|
26
|
+
Requires-Dist: exchange_calendars>=4.11.1
|
|
27
|
+
Requires-Dist: financetoolkit>=2.0.4
|
|
28
|
+
Requires-Dist: ipython>=9.5.0
|
|
29
|
+
Requires-Dist: nltk>=3.9.1
|
|
30
|
+
Requires-Dist: notify_py>=0.3.43
|
|
31
|
+
Requires-Dist: numpy>=2.2.6
|
|
32
|
+
Requires-Dist: praw>=7.8.1
|
|
33
|
+
Requires-Dist: pybind11>=3.0.1
|
|
34
|
+
Requires-Dist: pyfiglet>=1.0.4
|
|
35
|
+
Requires-Dist: pyportfolioopt>=1.5.6
|
|
36
|
+
Requires-Dist: python-dotenv>=1.1.1
|
|
37
|
+
Requires-Dist: python-telegram-bot>=22.3
|
|
38
|
+
Requires-Dist: PyYAML>=6.0.2
|
|
39
|
+
Requires-Dist: QuantStats>=0.0.77
|
|
40
|
+
Requires-Dist: seaborn>=0.13.2
|
|
41
|
+
Requires-Dist: spacy>=3.8.11
|
|
42
|
+
Requires-Dist: sumy>=0.11.0
|
|
43
|
+
Requires-Dist: tabulate>=0.9.0
|
|
44
|
+
Requires-Dist: textblob>=0.19.0
|
|
45
|
+
Requires-Dist: tweepy>=4.16.0
|
|
46
|
+
Requires-Dist: vaderSentiment>=3.3.2
|
|
47
|
+
Requires-Dist: yfinance>=0.2.65
|
|
48
|
+
Provides-Extra: mt5
|
|
49
|
+
Requires-Dist: MetaTrader5; extra == "mt5"
|
|
50
|
+
Description-Content-Type: text/markdown
|
|
51
|
+
|
|
52
|
+
# Simplified Investment & Trading Toolkit with Python & C++
|
|
53
|
+
|
|
54
|
+
[](https://bbstrader.readthedocs.io/en/latest/?badge=latest)
|
|
55
|
+
[](https://pypi.org/project/bbstrader/)
|
|
56
|
+
[](https://pypi.python.org/pypi/bbstrader)
|
|
57
|
+
[](https://pypi.org/project/bbstrader/)
|
|
58
|
+
[](https://github.com/bbalouki/bbstrader/actions/workflows/build.yml)
|
|
59
|
+

|
|
60
|
+

|
|
61
|
+

|
|
62
|
+
[](https://isocpp.org/std/the-standard)
|
|
63
|
+
[](https://cmake.org/)
|
|
64
|
+
[](https://pepy.tech/projects/bbstrader)
|
|
65
|
+
[](https://www.codefactor.io/repository/github/bbalouki/bbstrader)
|
|
66
|
+
[](https://www.linkedin.com/in/bertin-balouki-s-15b17a1a6)
|
|
67
|
+
|
|
68
|
+
## Welcome to `bbstrader` – The Ultimate C++ & Python Trading Powerhouse!
|
|
69
|
+
|
|
70
|
+
## Table of Contents
|
|
71
|
+
|
|
72
|
+
- [Overview](#overview)
|
|
73
|
+
- [Why `bbstrader` Stands Out](#why-bbstrader-stands-out)
|
|
74
|
+
- [Trusted by Traders Worldwide](#trusted-by-traders-worldwide)
|
|
75
|
+
- [The `bbstrader` Edge: Uniting C++ Speed with Python Flexibility](#the-bbstrader-edge-uniting-c-speed-with-python-flexibility)
|
|
76
|
+
- [Overcoming the MQL5 Bottleneck](#overcoming-the-mql5-bottleneck)
|
|
77
|
+
- [Key Modules](#key-modules)
|
|
78
|
+
- [1. `btengine`: Event-Driven Backtesting Beast](#1-btengine-event-driven-backtesting-beast)
|
|
79
|
+
- [2. `metatrader`: The C++/Python Bridge to MT5](#2-metatrader-the-cpython-bridge-to-mt5)
|
|
80
|
+
- [Pattern 1: C++ Core, Python Orchestrator (Maximum Performance)](#pattern-1-c-core-python-orchestrator-maximum-performance)
|
|
81
|
+
- [Pattern 2: Python-Driven with C++ Acceleration](#pattern-2-python-driven-with-c-acceleration)
|
|
82
|
+
- [3. `trading`: Live Execution & Strategy Orchestrator](#3-trading-live-execution--strategy-orchestrator)
|
|
83
|
+
- [4. `models`: Quant Toolkit for Signals & Risk](#4-models-quant-toolkit-for-signals--risk)
|
|
84
|
+
- [Getting Started](#getting-started)
|
|
85
|
+
- [Prerequisites](#prerequisites)
|
|
86
|
+
- [Installation](#installation)
|
|
87
|
+
- [For the Python Quant](#for-the-python-quant)
|
|
88
|
+
- [For the C++ Developer](#for-the-c-developer)
|
|
89
|
+
- [CLI workflow](#cli-workflow)
|
|
90
|
+
- [Community & Support](#-community--support)
|
|
91
|
+
- [Professional Services](#professional-services)
|
|
92
|
+
|
|
93
|
+
### Overview
|
|
94
|
+
|
|
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.
|
|
96
|
+
|
|
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.
|
|
98
|
+
|
|
99
|
+
## **Why `bbstrader` Stands Out**
|
|
100
|
+
|
|
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.
|
|
102
|
+
|
|
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.
|
|
110
|
+
- **Automation Fanatics**: Use the CLI for headless scripts, cron jobs, and server deployments.
|
|
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.
|
|
112
|
+
- **Cross-Platform & Future-Proof**: Works on Windows, macOS, Linux. (IBKR integration in development).
|
|
113
|
+
|
|
114
|
+
## **Trusted by Traders Worldwide**
|
|
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.
|
|
117
|
+
|
|
118
|
+
## **The `bbstrader` Edge: Uniting C++ Speed with Python Flexibility**
|
|
119
|
+
|
|
120
|
+
bbstrader's hybrid design is its secret weapon. At the heart is a bidirectional C++/Python bridge via `metatrader_client` module:
|
|
121
|
+
|
|
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)`
|
|
126
|
+
|
|
127
|
+
This setup crushes performance ceilings: Run ML models in Python, execute trades in C++, and backtest millions of bars in minutes.
|
|
128
|
+
|
|
129
|
+
### **Overcoming the MQL5 Bottleneck**
|
|
130
|
+
|
|
131
|
+
MetaTrader 5 is a world-class trading platform, but its native MQL5 language presents significant limitations for complex, high-frequency strategies:
|
|
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.
|
|
136
|
+
|
|
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.
|
|
138
|
+
|
|
139
|
+
## **Key Modules**
|
|
140
|
+
|
|
141
|
+
bbstrader is modular, with each component laser-focused.
|
|
142
|
+
|
|
143
|
+
### 1. **btengine**: Event-Driven Backtesting Beast
|
|
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.
|
|
148
|
+
|
|
149
|
+
```Python
|
|
150
|
+
# Inside the examples/
|
|
151
|
+
from strategies import test_strategy
|
|
152
|
+
if __name__ == '__main__':
|
|
153
|
+
# Run backtesting for Stock Index Short Term Buy Only Strategy
|
|
154
|
+
test_strategy(strategy='sistbo')
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Backtesting Results
|
|
158
|
+
|
|
159
|
+

|
|
160
|
+

|
|
161
|
+
|
|
162
|
+
### 2. **metatrader**: The C++/Python Bridge to MT5
|
|
163
|
+
|
|
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:
|
|
167
|
+
|
|
168
|
+
#### Pattern 1: C++ Core, Python Orchestrator (Maximum Performance)
|
|
169
|
+
|
|
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.
|
|
171
|
+
|
|
172
|
+
**Use this pattern when:**
|
|
173
|
+
|
|
174
|
+
- Your strategy involves complex mathematical calculations that are slow in Python.
|
|
175
|
+
- You need to react to market data in the shortest possible time.
|
|
176
|
+
- Your production environment demands deterministic, low-latency performance.
|
|
177
|
+
|
|
178
|
+
**C++ Side (`MovingAverageStrategy.cpp`):**
|
|
179
|
+
|
|
180
|
+
```cpp
|
|
181
|
+
#include "bbstrader/metatrader.hpp"
|
|
182
|
+
#include <numeric>
|
|
183
|
+
#include <iostream>
|
|
184
|
+
|
|
185
|
+
class MovingAverageStrategy : public MT5::MetaTraderClient {
|
|
186
|
+
public:
|
|
187
|
+
using MetaTraderClient::MetaTraderClient;
|
|
188
|
+
|
|
189
|
+
void on_tick(const std::string& symbol) {
|
|
190
|
+
auto rates_opt = copy_rates_from_pos(symbol, 1, 0, 20);
|
|
191
|
+
|
|
192
|
+
if (!rates_opt || rates_opt->size() < 20) return;
|
|
193
|
+
|
|
194
|
+
const auto& rates = *rates_opt;
|
|
195
|
+
|
|
196
|
+
double sum = std::accumulate(rates.begin(), rates.end(), 0.0,
|
|
197
|
+
[](double a, const MT5::RateInfo& b) { return a + b.close; });
|
|
198
|
+
double sma = sum / rates.size();
|
|
199
|
+
double current_price = rates.back().close;
|
|
200
|
+
|
|
201
|
+
if (current_price > sma) {
|
|
202
|
+
std::cout << "Price is above SMA. Sending Buy Order for " << symbol << '\n';
|
|
203
|
+
MT5::TradeRequest request;
|
|
204
|
+
request.action = MT5::TradeAction::DEAL;
|
|
205
|
+
request.symbol = symbol;
|
|
206
|
+
request.volume = 0.1;
|
|
207
|
+
request.type = MT5::OrderType::BUY;
|
|
208
|
+
request.type_filling = MT5::OrderFilling::FOK;
|
|
209
|
+
request.type_time = MT5::OrderTime::GTC;
|
|
210
|
+
send_order(request);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
_This C++ class would then be exposed to Python using `pybind11`._
|
|
217
|
+
|
|
218
|
+
```cpp
|
|
219
|
+
// Inside bindings.cpp
|
|
220
|
+
#include <pybind11/pybind11.h>
|
|
221
|
+
#include "MovingAverageStrategy.hpp"
|
|
222
|
+
|
|
223
|
+
namespace py = pybind11;
|
|
224
|
+
|
|
225
|
+
PYBIND11_MODULE(my_strategies, m){
|
|
226
|
+
py::class_<MovingAverageStrategy, MT5::MetaTraderClient>(m, "MovingAverageStrategy")
|
|
227
|
+
.def(py::init<MT5::MetaTraderClient::Handlers>())
|
|
228
|
+
.def("on_tick", &MovingAverageStrategy::on_tick);
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
**Python Side (`main.py`):**
|
|
233
|
+
|
|
234
|
+
```python
|
|
235
|
+
from bbstrader.api import Mt5Handlers
|
|
236
|
+
import MetaTrader5 as mt5
|
|
237
|
+
import time
|
|
238
|
+
from my_strategies import MovingAverageStrategy
|
|
239
|
+
|
|
240
|
+
# 1. Instantiate the C++ strategy, injecting the Python MT5 handlers
|
|
241
|
+
strategy = MovingAverageStrategy(Mt5Handlers)
|
|
242
|
+
|
|
243
|
+
# 2. Main execution loop
|
|
244
|
+
if strategy.initialize():
|
|
245
|
+
while True:
|
|
246
|
+
strategy.on_tick("EURUSD")
|
|
247
|
+
time.sleep(1)
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
#### Pattern 2: Python-Driven with C++ Acceleration
|
|
251
|
+
|
|
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.
|
|
253
|
+
|
|
254
|
+
**Use this pattern when:**
|
|
255
|
+
|
|
256
|
+
- Your strategy relies heavily on Python libraries like `pandas`, `scikit-learn`, or `tensorflow`.
|
|
257
|
+
- Rapid prototyping and iteration are more important than absolute minimum latency.
|
|
258
|
+
- Your core logic is more about decision-making based on pre-processed data than it is about raw computation speed.
|
|
259
|
+
|
|
260
|
+
```python
|
|
261
|
+
import MetaTrader5 as mt5
|
|
262
|
+
from bbstrader.api import Mt5Handlers
|
|
263
|
+
from bbstrader.api.metatrader_client import MetaTraderClient
|
|
264
|
+
|
|
265
|
+
# 1. Inherit from the C++ MetaTraderClient in Python
|
|
266
|
+
class MyStrategyClient(MetaTraderClient):
|
|
267
|
+
def __init__(self, handlers):
|
|
268
|
+
super().__init__(handlers)
|
|
269
|
+
|
|
270
|
+
# 2. Instantiate your client
|
|
271
|
+
strategy = MyStrategyClient(Mt5Handlers)
|
|
272
|
+
|
|
273
|
+
# 3. Interact with the MT5 terminal via the C++ bridge
|
|
274
|
+
if strategy.initialize():
|
|
275
|
+
rates = strategy.copy_rates_from_pos("EURUSD", mt5.TIMEFRAME_M1, 0, 100)
|
|
276
|
+
print(f"Retrieved {len(rates)} rates via the C++ bridge.")
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### 3. **`trading`: Live Execution & Strategy Orchestrator**
|
|
280
|
+
|
|
281
|
+
- **Purpose**: Manages live sessions, coordinates signals from strategies, risk from models, and execution via metatrader.
|
|
282
|
+
- **Features**: Multi-account support, position hedging, trailing stops.
|
|
283
|
+
|
|
284
|
+
### 4. `models`: Quant Toolkit for Signals & Risk
|
|
285
|
+
|
|
286
|
+
- **Purpose**: Build/test models like NLP sentiment, VaR/CVaR risk, optimization.
|
|
287
|
+
- **Features**: Currently Sentiment analysis, and Topic Modeling.
|
|
288
|
+
- **Example**: Sentiment-Based Entry:
|
|
289
|
+
|
|
290
|
+
```python
|
|
291
|
+
from bbstrader.models import SentimenSentimentAnalyzer
|
|
292
|
+
|
|
293
|
+
model = SentimenSentimentAnalyzer() # Loads pre-trained NLP
|
|
294
|
+
score = model.analyze_sentiment("Fed hikes rates – markets soar!")
|
|
295
|
+
if score > 0.7: # Bullish? Buy!
|
|
296
|
+
print("Go long!")
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### **Other Modules:**
|
|
300
|
+
|
|
301
|
+
`core`: Utilities (data structs, logging).
|
|
302
|
+
`config`: Manages JSON configs in ~/.bbstrader/.
|
|
303
|
+
`api`: Handler injections for bridges.
|
|
304
|
+
|
|
305
|
+
## Getting Started
|
|
306
|
+
|
|
307
|
+
### Prerequisites
|
|
308
|
+
|
|
309
|
+
- **Python**: Python 3.12+ is required.
|
|
310
|
+
- **MetaTrader 5 (MT5)**: Required for live execution (Windows).
|
|
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).
|
|
312
|
+
|
|
313
|
+
## Installation
|
|
314
|
+
|
|
315
|
+
`bbstrader` is designed for both Python and C++ developers. Follow the instructions that best suit your needs.
|
|
316
|
+
|
|
317
|
+
### For the Python Quant
|
|
318
|
+
|
|
319
|
+
Get started in minutes using `pip`. We strongly recommend using a virtual environment.
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
# Create and activate a virtual environment
|
|
323
|
+
python -m venv venv
|
|
324
|
+
source venv/bin/activate # on Linux/macOS
|
|
325
|
+
venv\Scripts\activate # on Windows
|
|
326
|
+
|
|
327
|
+
# Install bbstrader
|
|
328
|
+
pip install bbstrader[MT5] # Windows
|
|
329
|
+
pip install bbstrader # Linux/macOS
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### For the C++ Developer
|
|
333
|
+
|
|
334
|
+
To develop your own C++ strategies, you can use `vcpkg` to install the `bbstrader` library and its dependencies.
|
|
335
|
+
|
|
336
|
+
```bash
|
|
337
|
+
# If you don't have vcpkg, clone and bootstrap it
|
|
338
|
+
git clone https://github.com/microsoft/vcpkg
|
|
339
|
+
./vcpkg/bootstrap-vcpkg.sh or ./vcpkg/bootstrap-vcpkg.bat
|
|
340
|
+
|
|
341
|
+
# Install bbstrader
|
|
342
|
+
./vcpkg/vcpkg install bbstrader
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
## CLI workflow
|
|
346
|
+
|
|
347
|
+
`bbstrader` shines via CLI – launch everything from one command!
|
|
348
|
+
|
|
349
|
+
| Action | Command |
|
|
350
|
+
| :----------------- | :-------------------------------------------------------------------------------------------------------------------- |
|
|
351
|
+
| **Run Backtest** | `python -m bbstrader --run backtest --strategy SMAStrategy --account MY_ACCOUNT --config backtest.json` |
|
|
352
|
+
| **Live Execution** | `python -m bbstrader --run execution --strategy KalmanFilter --account MY_ACCOUNT --config execution.json --parallel` |
|
|
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`):
|
|
357
|
+
|
|
358
|
+
```json
|
|
359
|
+
{
|
|
360
|
+
"SMAStrategy": {
|
|
361
|
+
"MY_MT5_ACCOUNT_1": {
|
|
362
|
+
"symbol_list": ["EURUSD", "GBPUSD"],
|
|
363
|
+
"trades_kwargs": { "magic": 12345, "comment": "SMA_Live" },
|
|
364
|
+
"short_window": 20,
|
|
365
|
+
"long_window": 50
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
## 🌍 Community & Support
|
|
372
|
+
|
|
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.
|
|
376
|
+
|
|
377
|
+
---
|
|
378
|
+
|
|
379
|
+
### Professional Services
|
|
380
|
+
|
|
381
|
+
If you need a custom trading strategy, a proprietary risk model, advanced data pipelines, or a dedicated copy trading server setup, professional services are available.
|
|
382
|
+
|
|
383
|
+
**Contact the Developer:**
|
|
384
|
+
📧 [bertin@bbs-trading.com](mailto:bertin@bbs-trading.com)
|
|
385
|
+
|
|
386
|
+
---
|
|
387
|
+
|
|
388
|
+
### Support the Project
|
|
389
|
+
|
|
390
|
+
If you find this project useful and would like to support its continued development, you can contribute here:
|
|
391
|
+
|
|
392
|
+
☕ [Support the Developer](https://paypal.me/bertinbalouki?country.x=SN&locale.x=en_US)
|
|
393
|
+
|
|
394
|
+
---
|
|
395
|
+
|
|
396
|
+
_Disclaimer: Trading involves significant risk. `bbstrader` provides the tools, but you provide the strategy. Test thoroughly on demo accounts before deploying real capital._
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
bbstrader/config.py,sha256=L4iGPAzplhMCqZ_4YAaSHZL-fCqko0O-9e4AgiooDHM,2797
|
|
2
|
+
bbstrader/compat.py,sha256=5gj2Yycv3W50BfaPDqC3sKZOwTP2AbD_MFfiL8DJYqg,682
|
|
3
|
+
bbstrader/__init__.py,sha256=PX1ZqHReY87_c5jztWTKXvyQ0JVWY0dNffVoMLe0vUs,723
|
|
4
|
+
bbstrader/scripts.py,sha256=KoSTBPWiPsliw_-YJSKBrDfUmffW_5kAgi6gbBrORPo,22390
|
|
5
|
+
bbstrader/__main__.py,sha256=izwSSzZN3WlTeFv7nazQYLIJzBDKSOkqMsZXxLDN2pQ,2864
|
|
6
|
+
bbstrader/core/__init__.py,sha256=XelwvPNQkc7pTtNTyUF-UU0htZdF9bpeMPj7PvlpR4Q,1339
|
|
7
|
+
bbstrader/core/strategy.py,sha256=az2wwxVFEbJBaPEkWTfI4ybgEXNYiZB7po0caU0ycxg,16304
|
|
8
|
+
bbstrader/core/data.py,sha256=9RK4voCng39xHM12G3xh1-y3LvdJmGoQ9dCFBtV9src,26157
|
|
9
|
+
bbstrader/metatrader/_copier.py,sha256=qn5JdKNjsWVrlEIp95IJj8AGMZmXk-nE5jJr2Z6ePFw,27791
|
|
10
|
+
bbstrader/metatrader/trade.py,sha256=BXpLoaKJ-p4xCdCrcMU6VyPNlaNWhTBhhBbZOEqIAgM,70519
|
|
11
|
+
bbstrader/metatrader/__init__.py,sha256=GvEfeWD1UrihVbUBdk_JFgrrphUc0C5-_drizdnR268,2009
|
|
12
|
+
bbstrader/metatrader/utils.py,sha256=h94t7fi8I-9WCl1wDkn9vQBROa-6s80CLixmAvwuLAs,12838
|
|
13
|
+
bbstrader/metatrader/risk.py,sha256=efcpeFHpp1v2x8vuEoA-W9-GA0NKbQYVbqurtdXRFSs,26014
|
|
14
|
+
bbstrader/metatrader/broker.py,sha256=p_l1dxTg2COEA19FfdHBUFkLq0X_-XhDnIB5Q1Ym_IY,14799
|
|
15
|
+
bbstrader/metatrader/copier.py,sha256=6xE3dE-XdCusjJWF3VXrGKc5zCsarPzq900-TvmRYVA,58970
|
|
16
|
+
bbstrader/metatrader/account.py,sha256=kh43hxCuxn8ATcZAvdQv5Hvw7nYVL44QMlIQc8WFCqs,31876
|
|
17
|
+
bbstrader/metatrader/rates.py,sha256=Ot8008ctj7ivYo52OeMjR4wvXP8v6yMSqYM_FR4BXjs,17138
|
|
18
|
+
bbstrader/models/optimization.py,sha256=Fa4tdhynMmvKt5KHV9cH1TXmmJVJwU4QWpYkbeVq4aI,6395
|
|
19
|
+
bbstrader/models/__init__.py,sha256=Tpu8nihNUrV4SeQSgLongPMRvT43yf1Y55wtZBJn7Qk,1500
|
|
20
|
+
bbstrader/models/nlp.py,sha256=e90owLQgsl9iLIYiQ1LWB7Kdz8wh9LL0POU_na2CILk,32666
|
|
21
|
+
bbstrader/api/handlers.py,sha256=KsWL_JeBpRIVnrwoPZgkWDUNjvqJ6LVvOJHplv3cI9s,7892
|
|
22
|
+
bbstrader/api/__init__.py,sha256=RxrqBTndEhsSoAVqv_Q-3iKB3IygCZ1EBu3_32BX05A,2947
|
|
23
|
+
bbstrader/api/metatrader_client.cpython-312-darwin.so,sha256=vkZPz1wypPvyfpkw5WTlzVpRgcrQiQXno1WRdn2SqDc,819736
|
|
24
|
+
bbstrader/api/metatrader_client.pyi,sha256=WXfnoFmjNjJDFYTZDI_KXZ0-jDIwYQj1amadGvmY6NQ,18478
|
|
25
|
+
bbstrader/btengine/event.py,sha256=E_OvwAO23xl0FqH-oe5Dh83fDmSjuF_KS8kOi8SEhTc,8880
|
|
26
|
+
bbstrader/btengine/execution.py,sha256=x3f5Fnb_BA1Yl5XgrO9jEo6a1NfSPzRuF3EE0ViTDB0,11694
|
|
27
|
+
bbstrader/btengine/__init__.py,sha256=y1btjaEfhWsH8vuE7mBRpP9Tu-Azt9REhuVYsPCAfBU,2955
|
|
28
|
+
bbstrader/btengine/strategy.py,sha256=wxPoJ4JgLFVeUYEcNOUg39nMhoEeH11dJlpydZ6IHro,19731
|
|
29
|
+
bbstrader/btengine/performance.py,sha256=-QqkjH8N6okD4OmGHDHs-zvNPSJI67aqHBfDVVU0VNg,12835
|
|
30
|
+
bbstrader/btengine/backtest.py,sha256=5VnrdVWXObdXPzw90z-fuDiEMwQmY2l1qdf_bAmaVlk,14903
|
|
31
|
+
bbstrader/btengine/portfolio.py,sha256=jaNvSy4v4pRq93Z4oQhsHlfP9R7UkiqiSuTmmTsW-_o,16345
|
|
32
|
+
bbstrader/btengine/data.py,sha256=StpszSEYowBYqzBQ1nBAhfHesPc8SoxYV1lACmdlgLQ,28593
|
|
33
|
+
bbstrader/assets/bbs_.png,sha256=Fd_2usuCm6I_zMbcAhXtCHFDjNwIaqfQaQ9o-Aa82O8,432522
|
|
34
|
+
bbstrader/assets/bbstrader.png,sha256=du-IMYt_wc-vbVyRU_JlmooTUPfsYPCHGa59uu-h-ro,28002
|
|
35
|
+
bbstrader/assets/qs_metrics_1.png,sha256=mRqnwtB1etC2wzXY7jT4LcMYXcEI07F5pVSi1aPY1CY,240063
|
|
36
|
+
bbstrader/assets/bbstrader.ico,sha256=39xzcY0iXaDn2ZURvCGkSluUDfmhdYT1d8jkrawqbdc,179759
|
|
37
|
+
bbstrader/trading/execution.py,sha256=1ON50jDP9Stce2Q5X9CE74su8a3T7vX95tRzc1qeP6M,43377
|
|
38
|
+
bbstrader/trading/__init__.py,sha256=8N8Wohaw-ZCURBlBKG0uj6uYjRuvlyhN2KKbbFlWopw,1368
|
|
39
|
+
bbstrader/trading/strategy.py,sha256=QXDI59osWK4l78GXZrFpHgpHTf08JPNLqqSy82grez0,12431
|
|
40
|
+
bbstrader/trading/utils.py,sha256=57dKF9dcRu04oU2VRqydRrzW39dCW2wlDWhVt-sZdRw,1857
|
|
41
|
+
bbstrader-2.0.3.dist-info/RECORD,,
|
|
42
|
+
bbstrader-2.0.3.dist-info/WHEEL,sha256=a5hFNLnG478el62xhySpcm13yln7Jlz1BenyGRdoSlE,114
|
|
43
|
+
bbstrader-2.0.3.dist-info/entry_points.txt,sha256=8w4QE4Jd0nxWQ2vUcJywiCKyHVHesHezffr-ZQ4lNEw,55
|
|
44
|
+
bbstrader-2.0.3.dist-info/METADATA,sha256=1qn9cJQiDlIixllD56nfrsFGs6HNoW4GynMGjWwSs34,19277
|
|
45
|
+
bbstrader-2.0.3.dist-info/licenses/LICENSE,sha256=f718jaFjTXD6SAI9F2RrLuGfg2EtwPwnw-nBiKkbifI,1094
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-2026 Bertin Balouki SIMYELI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|