bbstrader 0.2.97__py3-none-any.whl → 0.2.99__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.

@@ -7,7 +7,7 @@ import sys
7
7
  from bbstrader.btengine import MT5Strategy, Strategy
8
8
  from bbstrader.core.utils import load_class, load_module
9
9
  from bbstrader.metatrader.trade import create_trade_instance
10
- from bbstrader.trading.execution import mt5_engine
10
+ from bbstrader.trading.execution import RunMt5Engine
11
11
 
12
12
  EXECUTION_PATH = os.path.expanduser("~/.bbstrader/execution/execution.py")
13
13
  CONFIG_PATH = os.path.expanduser("~/.bbstrader/execution/execution.json")
@@ -52,10 +52,10 @@ def worker_function(account, args):
52
52
  "account": account,
53
53
  **config,
54
54
  }
55
- mt5_engine(account, **kwargs)
55
+ RunMt5Engine(account, **kwargs)
56
56
 
57
57
 
58
- def mt5_terminal(args):
58
+ def RunMt5Terminal(args):
59
59
  if args.parallel:
60
60
  if len(args.account) == 0:
61
61
  raise ValueError(
@@ -82,12 +82,11 @@ def mt5_terminal(args):
82
82
  p.join()
83
83
  print("Execution terminated")
84
84
  else:
85
- worker_function(None, args)
85
+ worker_function(args.account[0], args)
86
86
 
87
87
 
88
- def tws_terminal(args):
89
- raise NotImplementedError("TWS terminal is not implemented yet")
90
-
88
+ def RunTWSTerminal(args):
89
+ raise NotImplementedError("RunTWSTerminal is not implemented yet")
91
90
 
92
91
  def execute_strategy(unknown):
93
92
  HELP_MSG = """
@@ -128,11 +127,11 @@ def execute_strategy(unknown):
128
127
  }
129
128
  }
130
129
  See bbstrader.metatrader.trade.create_trade_instance for more details on the trades_kwargs.
131
- See bbstrader.trading.execution.MT5ExecutionEngine for more details on the other parameters.
130
+ See bbstrader.trading.execution.Mt5ExecutionEngine for more details on the other parameters.
132
131
 
133
132
  All other paramaters must be python built-in types.
134
133
  If you have custom type you must set them in your strategy class
135
- or run the MT5ExecutionEngine directly, don't run on CLI.
134
+ or run the Mt5ExecutionEngine directly, don't run on CLI.
136
135
  """
137
136
  if "-h" in unknown or "--help" in unknown:
138
137
  print(HELP_MSG)
@@ -150,6 +149,6 @@ def execute_strategy(unknown):
150
149
  args = parser.parse_args(unknown)
151
150
 
152
151
  if args.terminal == "MT5":
153
- mt5_terminal(args)
152
+ RunMt5Terminal(args)
154
153
  elif args.terminal == "TWS":
155
- tws_terminal(args)
154
+ RunTWSTerminal(args)
@@ -1,6 +1,14 @@
1
1
  """
2
2
  Strategies module for trading strategies backtesting and execution.
3
3
 
4
+ # NOTE
5
+ These strategies inherit from the Strategy class, not from MT5Strategy, because we chose to demonstrate the modular approach to building and backtesting strategies using the bbstrader framework.
6
+
7
+ If these strategies need to be sent to the Mt5ExecutionEngine,
8
+ they must return signals as a list of bbstrader.metatrader.trade.TradingSignal objects.
9
+
10
+ Later, we will implement the Execution Engine for the Interactive Brokers TWS platform.
11
+
4
12
  DISCLAIMER:
5
13
  This module is for educational purposes only and should not be
6
14
  considered as financial advice. Always consult with a qualified financial advisor before making any investment decisions.
@@ -18,7 +26,7 @@ import yfinance as yf
18
26
 
19
27
  from bbstrader.btengine.backtest import BacktestEngine
20
28
  from bbstrader.btengine.data import DataHandler, MT5DataHandler, YFDataHandler
21
- from bbstrader.btengine.event import SignalEvent
29
+ from bbstrader.btengine.event import Events, SignalEvent
22
30
  from bbstrader.btengine.execution import MT5ExecutionHandler, SimExecutionHandler
23
31
  from bbstrader.btengine.strategy import Strategy
24
32
  from bbstrader.metatrader.account import Account
@@ -189,7 +197,7 @@ class SMAStrategy(Strategy):
189
197
 
190
198
  def calculate_signals(self, event=None):
191
199
  if self.mode == "backtest" and event is not None:
192
- if event.type == "MARKET":
200
+ if event.type == Events.MARKET:
193
201
  signals = self.create_backtest_signals()
194
202
  for signal in signals.values():
195
203
  if signal is not None:
@@ -377,7 +385,7 @@ class ArimaGarchStrategy(Strategy):
377
385
 
378
386
  def calculate_signals(self, event=None):
379
387
  if self.mode == "backtest" and event is not None:
380
- if event.type == "MARKET":
388
+ if event.type == Events.MARKET:
381
389
  signals = self.create_backtest_signal()
382
390
  for signal in signals.values():
383
391
  if signal is not None:
@@ -560,7 +568,7 @@ class KalmanFilterStrategy(Strategy):
560
568
  Calculate the Kalman Filter strategy.
561
569
  """
562
570
  if self.mode == "backtest" and event is not None:
563
- if event.type == "MARKET":
571
+ if event.type == Events.MARKET:
564
572
  self.calculate_backtest_signals()
565
573
  elif self.mode == "live":
566
574
  return self.calculate_live_signals()
@@ -744,7 +752,7 @@ class StockIndexSTBOTrading(Strategy):
744
752
 
745
753
  def calculate_signals(self, event=None) -> Dict[str, Union[str, None]]:
746
754
  if self.mode == "backtest" and event is not None:
747
- if event.type == "MARKET":
755
+ if event.type == Events.MARKET:
748
756
  self.calculate_backtest_signals()
749
757
  elif self.mode == "live":
750
758
  return self.calculate_live_signals()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bbstrader
3
- Version: 0.2.97
3
+ Version: 0.2.99
4
4
  Summary: Simplified Investment & Trading Toolkit
5
5
  Home-page: https://github.com/bbalouki/bbstrader
6
6
  Download-URL: https://pypi.org/project/bbstrader/
@@ -24,21 +24,24 @@ Classifier: Operating System :: MacOS
24
24
  Classifier: License :: OSI Approved :: MIT License
25
25
  Description-Content-Type: text/markdown
26
26
  License-File: LICENSE
27
- Requires-Dist: pandas
27
+ Requires-Dist: numpy<2.0.0,>=1.26.0
28
+ Requires-Dist: scikit-learn
29
+ Requires-Dist: statsmodels
30
+ Requires-Dist: seaborn
31
+ Requires-Dist: lightgbm
32
+ Requires-Dist: dash
33
+ Requires-Dist: nltk
34
+ Requires-Dist: spacy
35
+ Requires-Dist: pmdarima
36
+ Requires-Dist: pyportfolioopt
37
+ Requires-Dist: alphalens-reloaded
28
38
  Requires-Dist: pandas_ta
29
- Requires-Dist: numpy<2.0.0
30
39
  Requires-Dist: yfinance
31
- Requires-Dist: scipy
32
40
  Requires-Dist: hmmlearn
33
- Requires-Dist: pmdarima
34
41
  Requires-Dist: arch
35
42
  Requires-Dist: hurst
36
- Requires-Dist: seaborn
37
- Requires-Dist: statsmodels
38
- Requires-Dist: matplotlib
39
43
  Requires-Dist: filterpy
40
44
  Requires-Dist: pykalman
41
- Requires-Dist: pytest
42
45
  Requires-Dist: CurrencyConverter
43
46
  Requires-Dist: tabulate
44
47
  Requires-Dist: python-dotenv
@@ -46,24 +49,17 @@ Requires-Dist: ipython
46
49
  Requires-Dist: QuantStats
47
50
  Requires-Dist: exchange-calendars
48
51
  Requires-Dist: tqdm
49
- Requires-Dist: scikit-learn
50
52
  Requires-Dist: notify-py
51
53
  Requires-Dist: python-telegram-bot
52
- Requires-Dist: pyportfolioopt
53
54
  Requires-Dist: eodhd
54
55
  Requires-Dist: financetoolkit
55
56
  Requires-Dist: PyYAML
56
57
  Requires-Dist: tables
57
- Requires-Dist: lightgbm
58
- Requires-Dist: alphalens-reloaded
59
58
  Requires-Dist: pyfiglet
60
59
  Requires-Dist: colorama
61
60
  Requires-Dist: praw
62
61
  Requires-Dist: tweepy
63
62
  Requires-Dist: beautifulsoup4
64
- Requires-Dist: dash
65
- Requires-Dist: nltk
66
- Requires-Dist: spacy
67
63
  Requires-Dist: textblob
68
64
  Requires-Dist: vaderSentiment
69
65
  Provides-Extra: mt5
@@ -1,45 +1,46 @@
1
1
  bbstrader/__ini__.py,sha256=v6zyJHj5FMRL-_P7AwnTGbCF-riMqhqlTvDgfulj7go,621
2
- bbstrader/__main__.py,sha256=EtfD-TrAphboYxwfe7-WeD-1d4bJceeBputFrV-W-qQ,1525
2
+ bbstrader/__main__.py,sha256=sDdjoiaHSPrVqdjU_zOLajX3rD_3Ha6dHwIivYc_vp4,1525
3
3
  bbstrader/compat.py,sha256=djbHMvTvy0HYm1zyZ6Ttp_LMwP2PqTSVw1r7pqbz7So,487
4
4
  bbstrader/config.py,sha256=c2nCUw-bYWf5kkyFls5Nqld8HdMczexSilTni7rYUBw,3973
5
5
  bbstrader/tseries.py,sha256=H4D_A966HdN8YjBfuCcF8QBQdhjOrTcidR98wP2KN_I,68339
6
6
  bbstrader/btengine/__init__.py,sha256=y1btjaEfhWsH8vuE7mBRpP9Tu-Azt9REhuVYsPCAfBU,2955
7
- bbstrader/btengine/backtest.py,sha256=ZzGhoN-_g0cF-OCyk173imze2OXEhykHTUiJ9MowDO8,14582
7
+ bbstrader/btengine/backtest.py,sha256=UiOmtqYSh72KZz0DCXz8iKrqTCOkx9Er3XjqK6H9Do8,14765
8
8
  bbstrader/btengine/data.py,sha256=Tuc6M8itbGpPjsfRpZBB8v0FJpPt7-hUkP6I5meP0Sg,26927
9
- bbstrader/btengine/event.py,sha256=38mhZH9d53C4x7bZER2B0O6M18txzS4u7zveKyxeP5Y,8603
10
- bbstrader/btengine/execution.py,sha256=mXY0tyFv6G1XF48R5Kx2-pDnwu1mUyOc0ZeeysQG62A,10587
9
+ bbstrader/btengine/event.py,sha256=gC2nqWU_t1pRzg4DYYey-mbaBo8T_JOPzzAzRF53U7o,8757
10
+ bbstrader/btengine/execution.py,sha256=tN7QIx0PHiQmJcn3MdSQiwwAYCDxFDn3C4i5tlM5xoY,10605
11
11
  bbstrader/btengine/performance.py,sha256=1ecWrTzHBQbk4ORvbTEKxwCzlL1brcXOEUwgbnjAwx4,12470
12
- bbstrader/btengine/portfolio.py,sha256=mh2_zNJDmKzb0lo55PXhbXYxXMmXRA4YLkgzwxRMuZE,16110
12
+ bbstrader/btengine/portfolio.py,sha256=z98M65HQeCyma8gMZkAxspxBA9jtIhzxMyJUHPPj34c,16128
13
13
  bbstrader/btengine/scripts.py,sha256=8o66dq4Ex4DsH4s8xvJqUOFjLzZJSnbBvvNBzohtzoE,4837
14
- bbstrader/btengine/strategy.py,sha256=PFIb9gUWahaXpzCFL-RchpBumlEJsz5Elbz_A2qZ8Jc,31285
14
+ bbstrader/btengine/strategy.py,sha256=FrYoB8ogHODTfRDZf2gW-CGdTxdVoIYwxko1cYgwcgg,31631
15
15
  bbstrader/core/__init__.py,sha256=GIFzFSStPfE0XM2j7mDeZZQeMTh_AwPsDOQXwMVJLgw,97
16
16
  bbstrader/core/data.py,sha256=VPuynoT0uFYduh7la8gZSnEv_Gq8Xu2vJZJ7TfQMll8,18797
17
17
  bbstrader/core/utils.py,sha256=WjuabzBjhY65ku2KL-f7CMalE2x-wrX-6mCA_qhhFPE,2728
18
18
  bbstrader/ibkr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  bbstrader/ibkr/utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  bbstrader/metatrader/__init__.py,sha256=A5Ye9tpc2sp9Xk5qjKw-EfYsoRcZtAt8nqvC3tCtZs8,333
21
- bbstrader/metatrader/account.py,sha256=qAFqCPmoUjiqjY5M9sjbSvh-STjQUGdFCHOEcB7uoDI,56493
22
- bbstrader/metatrader/copier.py,sha256=-cFroX4M1q9rlupU4xLP0N6lR8ZbP_izUOQ2sBe_lFc,31797
21
+ bbstrader/metatrader/account.py,sha256=kSEJChls4o2smMWa-FeHoxS5gd6yyOPfzoU_6jmzxTg,57374
22
+ bbstrader/metatrader/analysis.py,sha256=pnZWdvEnf9wkPT0vhEIbZipnN5EUf6TaQftplYP9jRs,3564
23
+ bbstrader/metatrader/copier.py,sha256=pCZkRfkUWxufnmiO0cc1Kz6UF59HTUUGs-c60LYNUbE,32307
23
24
  bbstrader/metatrader/rates.py,sha256=0bKyjGnafZ19DwC0-IxXUBJzOdAo-cNmhabwhKLxcos,20585
24
25
  bbstrader/metatrader/risk.py,sha256=pwG4q1_uPGgPlokDGVNtd04O6p28yIbgT-evvHuo-Qc,27029
25
26
  bbstrader/metatrader/scripts.py,sha256=Yjp7Un-wDTInptHS_rPFpXNKWbVM871VEkaHxsO2MPQ,2115
26
- bbstrader/metatrader/trade.py,sha256=Q1cArcpMnovRTED0kwMybcpwPB28rQKXLcJV4jldF0w,81202
27
- bbstrader/metatrader/utils.py,sha256=lYIvAeiL_ceACmkVNo4-QRopias08KyBUI7THfdj3c0,17103
27
+ bbstrader/metatrader/trade.py,sha256=2vkoe972OUi5m5rVkWa2DuyXSo04JCSsF5tyahDbL3s,79926
28
+ bbstrader/metatrader/utils.py,sha256=szORxKJW9OG-H6nof_ovOhToSx_n8EtVwe0mkLt3eFg,17424
28
29
  bbstrader/models/__init__.py,sha256=s2mJrtKePXQaw_PvcrtPCD2mPCdVXP4Myzg0MlLVipo,547
29
- bbstrader/models/factors.py,sha256=5kSAOS1MHvTZ-Ti03TtjOxl_EvC-V_9e389xeR_82ak,13020
30
+ bbstrader/models/factors.py,sha256=-ODeD2GK4nmxFQAIh5MF3SFM9ofppi2pW6Q728LzLv8,12701
30
31
  bbstrader/models/ml.py,sha256=tCr7YyODl0CDoOUpYqJ1q12ls86Sc-_Fu3b2Y0Z7TJ8,47551
31
32
  bbstrader/models/nlp.py,sha256=P7SYaTIqEBldjwYfS6IrO66Y6-ioDXUrCSf3bZxQrDE,28073
32
33
  bbstrader/models/optimization.py,sha256=vnks6uxFZdqXgxaZJNxq8z0IH45KZ8yaXo38JhIVKGc,6399
33
34
  bbstrader/models/portfolio.py,sha256=r-47Zrn2r7iKCHm5YVtwkbBJXAZGM3QYy-rXCWY9-Bg,8079
34
35
  bbstrader/models/risk.py,sha256=JQOXPshMOru6Eb0AMU6oKCNzg6mlGfL6_tN90lWcVBE,14878
35
36
  bbstrader/trading/__init__.py,sha256=ycLyuuxN5SujqtzR9X0Q74UQfK93q2va-GGAXdr-KS8,457
36
- bbstrader/trading/execution.py,sha256=4-XyRll1x8gfF68cTZXjtRF79csDx_oKNI0F71cv1Bw,35028
37
- bbstrader/trading/scripts.py,sha256=wR5TUrHn-Cd2kzfURXn14VTCEZ-QA8ydwYHayMPK0oI,5720
38
- bbstrader/trading/strategies.py,sha256=D_M91UwRiFwZKvKFKmz427TPd-dNyWWbhehaP8RI17c,36539
37
+ bbstrader/trading/execution.py,sha256=ukOiv1O-a_SdKp35QlU_3_Wt_7CTgh4pLPN9s7qPEdw,37117
38
+ bbstrader/trading/scripts.py,sha256=Tf5q33WqqygjpIv43_8nA82VZ3GM0qgb4Ggo3fHJ_wg,5744
39
+ bbstrader/trading/strategies.py,sha256=rRNPZM1Z9twzO5UWd5qI3FgkZmOhF3Dd2h7XRn7EoDs,37011
39
40
  bbstrader/trading/utils.py,sha256=57dKF9dcRu04oU2VRqydRrzW39dCW2wlDWhVt-sZdRw,1857
40
- bbstrader-0.2.97.dist-info/licenses/LICENSE,sha256=ZwC_RqqGmOPBUiMDKqLyJZ5HBeHq53LpL7TMRzrJY8c,1094
41
- bbstrader-0.2.97.dist-info/METADATA,sha256=mBnvqbUXVjE-dl5A5tkdYRuGd_fh2oKU55K-Ryfm9po,11590
42
- bbstrader-0.2.97.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
43
- bbstrader-0.2.97.dist-info/entry_points.txt,sha256=0yDCbhbgHswOzJnY5wRSM_FjjyMHGvY7lJpSSVh0xtI,54
44
- bbstrader-0.2.97.dist-info/top_level.txt,sha256=Wwj322jZmxGZ6gD_TdaPiPLjED5ReObm5omerwlmZIg,10
45
- bbstrader-0.2.97.dist-info/RECORD,,
41
+ bbstrader-0.2.99.dist-info/licenses/LICENSE,sha256=ZwC_RqqGmOPBUiMDKqLyJZ5HBeHq53LpL7TMRzrJY8c,1094
42
+ bbstrader-0.2.99.dist-info/METADATA,sha256=8JnFfL70KEiiqXvBhDEoqafZ4-KMTNtbheytb3-5HZ4,11508
43
+ bbstrader-0.2.99.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
44
+ bbstrader-0.2.99.dist-info/entry_points.txt,sha256=0yDCbhbgHswOzJnY5wRSM_FjjyMHGvY7lJpSSVh0xtI,54
45
+ bbstrader-0.2.99.dist-info/top_level.txt,sha256=Wwj322jZmxGZ6gD_TdaPiPLjED5ReObm5omerwlmZIg,10
46
+ bbstrader-0.2.99.dist-info/RECORD,,