bbstrader 0.0.1__py3-none-any.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.
Potentially problematic release.
This version of bbstrader might be problematic. Click here for more details.
- bbstrader/__ini__.py +17 -0
- bbstrader/btengine/__init__.py +50 -0
- bbstrader/btengine/backtest.py +900 -0
- bbstrader/btengine/data.py +374 -0
- bbstrader/btengine/event.py +201 -0
- bbstrader/btengine/execution.py +83 -0
- bbstrader/btengine/performance.py +309 -0
- bbstrader/btengine/portfolio.py +326 -0
- bbstrader/btengine/strategy.py +31 -0
- bbstrader/metatrader/__init__.py +6 -0
- bbstrader/metatrader/account.py +1038 -0
- bbstrader/metatrader/rates.py +226 -0
- bbstrader/metatrader/risk.py +626 -0
- bbstrader/metatrader/trade.py +1296 -0
- bbstrader/metatrader/utils.py +669 -0
- bbstrader/models/__init__.py +6 -0
- bbstrader/models/risk.py +349 -0
- bbstrader/strategies.py +681 -0
- bbstrader/trading/__init__.py +4 -0
- bbstrader/trading/execution.py +965 -0
- bbstrader/trading/run.py +131 -0
- bbstrader/trading/utils.py +153 -0
- bbstrader/tseries.py +592 -0
- bbstrader-0.0.1.dist-info/LICENSE +21 -0
- bbstrader-0.0.1.dist-info/METADATA +132 -0
- bbstrader-0.0.1.dist-info/RECORD +28 -0
- bbstrader-0.0.1.dist-info/WHEEL +5 -0
- bbstrader-0.0.1.dist-info/top_level.txt +1 -0
bbstrader/__ini__.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Simplified Investment & Trading Toolkit
|
|
3
|
+
=======================================
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
__author__ = "Bertin Balouki SIMYELI"
|
|
7
|
+
__copyright__ = "2023-2024 Bertin Balouki SIMYELI"
|
|
8
|
+
__email__ = "bbalouki@outlook.com"
|
|
9
|
+
__license__ = "MIT"
|
|
10
|
+
__version__ = "1.0.0"
|
|
11
|
+
|
|
12
|
+
from bbstrader import btengine
|
|
13
|
+
from bbstrader import metatrader
|
|
14
|
+
from bbstrader import models
|
|
15
|
+
from bbstrader import trading
|
|
16
|
+
from bbstrader import strategies
|
|
17
|
+
from bbstrader import tseries
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Overview
|
|
3
|
+
========
|
|
4
|
+
|
|
5
|
+
This Backtesting Module provides a comprehensive suite of tools to test trading strategies in an event-driven system.
|
|
6
|
+
It simulates the execution of trades in historical market conditions to evaluate the performance of trading strategies
|
|
7
|
+
before applying them in live trading environments. Designed with modularity and extensibility in mind, it caters to
|
|
8
|
+
both novices and experts in algorithmic trading.
|
|
9
|
+
|
|
10
|
+
Features
|
|
11
|
+
========
|
|
12
|
+
|
|
13
|
+
- **Event-Driven Architecture**: Processes market data, generates signals, executes orders, and manages portfolio updates in response to events, closely mimicking live trading environments.
|
|
14
|
+
- **Historical Market Data Support**: Utilizes historical OHLCV data from CSV files, Yahoo finance and MT5 terminal allowing for the testing of strategies over various market conditions and time frames.
|
|
15
|
+
- **Strategy Implementation Flexibility**: Abstract base classes for strategies and other components enable users to define custom trading logic and data handling processes.
|
|
16
|
+
- **Performance Metrics Calculation**: Includes tools for calculating key performance indicators, such as `Sharpe Ratio`, `Sortino Ratio`, and `drawdowns`, to evaluate the effectiveness of trading strategies.
|
|
17
|
+
- **Visualization**: Generates plots of the `equity curve`, `returns`, `drawdowns`, and other metrics for comprehensive strategy `performance analysis`.
|
|
18
|
+
|
|
19
|
+
Components
|
|
20
|
+
==========
|
|
21
|
+
|
|
22
|
+
- **Backtest**: Orchestrates the backtesting process, managing events and invoking components.
|
|
23
|
+
- **Event**: Abstract class for events, with implementations for market data, signals, fill and order events.
|
|
24
|
+
- **DataHandler**: Abstract class for market data handling, with an implementation for `HistoricalCSVHandler`, `MT5HistoricDataHandler`, `YFHistoricDataHandler`. We will add another data handling in the future such as MacroEconomic Data, Fundamental Data, TICK Data and Real-time Data.
|
|
25
|
+
- **Strategy**: Abstract class for trading strategies, allowing for custom signal generation logic.
|
|
26
|
+
- **Portfolio**: Manages positions and calculates performance metrics, responding to market data and signals.
|
|
27
|
+
- **ExecutionHandler**: Abstract class for order execution, with a simulated execution handler provided with an implementation for `SimulatedExecutionHandler`.
|
|
28
|
+
- **Performance**: Utility functions for calculating performance metrics and visualizing strategy performance.
|
|
29
|
+
|
|
30
|
+
Examples:
|
|
31
|
+
>>> from bbstrader.btengine import run_backtest
|
|
32
|
+
>>> run_backtest(test_mode=True, test_strategy='ou', test_quantity=2000)
|
|
33
|
+
|
|
34
|
+
>>> run_backtest(
|
|
35
|
+
... symbol_list=['AAPL', 'GOOG'],
|
|
36
|
+
... start_date=datetime(2020, 1, 1),
|
|
37
|
+
... data_handler=CustomDataHandler(),
|
|
38
|
+
... strategy=MovingAverageStrategy(),
|
|
39
|
+
... exc_handler=CustomExecutionHandler(),
|
|
40
|
+
... initial_capital=500000.0,
|
|
41
|
+
... heartbeat=1.0
|
|
42
|
+
... )
|
|
43
|
+
"""
|
|
44
|
+
from bbstrader.btengine.data import *
|
|
45
|
+
from bbstrader.btengine.event import *
|
|
46
|
+
from bbstrader.btengine.execution import *
|
|
47
|
+
from bbstrader.btengine.performance import *
|
|
48
|
+
from bbstrader.btengine.backtest import *
|
|
49
|
+
from bbstrader.btengine.portfolio import Portfolio
|
|
50
|
+
from bbstrader.btengine.strategy import Strategy
|