bbstrader 0.2.99__tar.gz → 0.2.991__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.

Potentially problematic release.


This version of bbstrader might be problematic. Click here for more details.

Files changed (54) hide show
  1. {bbstrader-0.2.99/bbstrader.egg-info → bbstrader-0.2.991}/PKG-INFO +1 -3
  2. {bbstrader-0.2.99 → bbstrader-0.2.991}/README.md +0 -2
  3. bbstrader-0.2.991/bbstrader/__init__.py +19 -0
  4. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/btengine/event.py +15 -14
  5. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/core/data.py +98 -2
  6. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/metatrader/trade.py +1 -1
  7. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/models/nlp.py +9 -2
  8. {bbstrader-0.2.99 → bbstrader-0.2.991/bbstrader.egg-info}/PKG-INFO +1 -3
  9. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader.egg-info/SOURCES.txt +1 -0
  10. {bbstrader-0.2.99 → bbstrader-0.2.991}/setup.py +1 -1
  11. {bbstrader-0.2.99 → bbstrader-0.2.991}/LICENSE +0 -0
  12. {bbstrader-0.2.99 → bbstrader-0.2.991}/MANIFEST.in +0 -0
  13. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/__ini__.py +0 -0
  14. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/__main__.py +0 -0
  15. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/btengine/__init__.py +0 -0
  16. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/btengine/backtest.py +0 -0
  17. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/btengine/data.py +0 -0
  18. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/btengine/execution.py +0 -0
  19. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/btengine/performance.py +0 -0
  20. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/btengine/portfolio.py +0 -0
  21. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/btengine/scripts.py +0 -0
  22. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/btengine/strategy.py +0 -0
  23. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/compat.py +0 -0
  24. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/config.py +0 -0
  25. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/core/__init__.py +0 -0
  26. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/core/utils.py +0 -0
  27. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/ibkr/__init__.py +0 -0
  28. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/ibkr/utils.py +0 -0
  29. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/metatrader/__init__.py +0 -0
  30. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/metatrader/account.py +0 -0
  31. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/metatrader/analysis.py +0 -0
  32. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/metatrader/copier.py +0 -0
  33. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/metatrader/rates.py +0 -0
  34. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/metatrader/risk.py +0 -0
  35. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/metatrader/scripts.py +0 -0
  36. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/metatrader/utils.py +0 -0
  37. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/models/__init__.py +0 -0
  38. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/models/factors.py +0 -0
  39. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/models/ml.py +0 -0
  40. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/models/optimization.py +0 -0
  41. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/models/portfolio.py +0 -0
  42. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/models/risk.py +0 -0
  43. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/trading/__init__.py +0 -0
  44. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/trading/execution.py +0 -0
  45. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/trading/scripts.py +0 -0
  46. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/trading/strategies.py +0 -0
  47. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/trading/utils.py +0 -0
  48. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader/tseries.py +0 -0
  49. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader.egg-info/dependency_links.txt +0 -0
  50. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader.egg-info/entry_points.txt +0 -0
  51. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader.egg-info/requires.txt +0 -0
  52. {bbstrader-0.2.99 → bbstrader-0.2.991}/bbstrader.egg-info/top_level.txt +0 -0
  53. {bbstrader-0.2.99 → bbstrader-0.2.991}/requirements.txt +0 -0
  54. {bbstrader-0.2.99 → bbstrader-0.2.991}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bbstrader
3
- Version: 0.2.99
3
+ Version: 0.2.991
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/
@@ -81,8 +81,6 @@ Dynamic: requires-dist
81
81
  Dynamic: summary
82
82
 
83
83
  # Simplified Investment & Trading Toolkit
84
- ![bbstrader](https://github.com/bbalouki/bbstrader/blob/main/assets/bbstrader_logo.png?raw=true)
85
-
86
84
  [![Documentation Status](https://readthedocs.org/projects/bbstrader/badge/?version=latest)](https://bbstrader.readthedocs.io/en/latest/?badge=latest)
87
85
  [![PYPI Version](https://img.shields.io/pypi/v/bbstrader)](https://pypi.org/project/bbstrader/)
88
86
  [![PyPi status](https://img.shields.io/pypi/status/bbstrader.svg?maxAge=60)](https://pypi.python.org/pypi/bbstrader)
@@ -1,6 +1,4 @@
1
1
  # Simplified Investment & Trading Toolkit
2
- ![bbstrader](https://github.com/bbalouki/bbstrader/blob/main/assets/bbstrader_logo.png?raw=true)
3
-
4
2
  [![Documentation Status](https://readthedocs.org/projects/bbstrader/badge/?version=latest)](https://bbstrader.readthedocs.io/en/latest/?badge=latest)
5
3
  [![PYPI Version](https://img.shields.io/pypi/v/bbstrader)](https://pypi.org/project/bbstrader/)
6
4
  [![PyPi status](https://img.shields.io/pypi/status/bbstrader.svg?maxAge=60)](https://pypi.python.org/pypi/bbstrader)
@@ -0,0 +1,19 @@
1
+ """
2
+ Simplified Investment & Trading Toolkit
3
+
4
+ """
5
+
6
+ __author__ = "Bertin Balouki SIMYELI"
7
+ __copyright__ = "2023-2025 Bertin Balouki SIMYELI"
8
+ __email__ = "bertin@bbstrader.com"
9
+ __license__ = "MIT"
10
+ __version__ = "0.2.0"
11
+
12
+ from bbstrader import compat # noqa: F401
13
+ from bbstrader import core # noqa: F401
14
+ from bbstrader import btengine # noqa: F401
15
+ from bbstrader import metatrader # noqa: F401
16
+ from bbstrader import models # noqa: F401
17
+ from bbstrader import trading # noqa: F401
18
+ from bbstrader import tseries # noqa: F401
19
+ from bbstrader.config import config_logger # noqa: F401
@@ -2,7 +2,7 @@ from datetime import datetime
2
2
  from enum import Enum
3
3
  from typing import Literal
4
4
 
5
- __all__ = ["Event", "MarketEvent", "SignalEvent", "OrderEvent", "FillEvent"]
5
+ __all__ = ["Event", "Events", "MarketEvent", "SignalEvent", "OrderEvent", "FillEvent"]
6
6
 
7
7
 
8
8
  class Event(object):
@@ -134,20 +134,21 @@ class OrderEvent(Event):
134
134
  self.price = price
135
135
  self.signal = signal
136
136
 
137
- def print_order(self):
138
- """
139
- Outputs the values within the Order.
140
- """
141
- print(
142
- "Order: Symbol=%s, Type=%s, Quantity=%s, Direction=%s, Price=%s"
143
- % (
144
- self.symbol,
145
- self.order_type,
146
- self.quantity,
147
- self.direction,
148
- self.price,
149
- )
137
+ def print_order(self):
138
+ """
139
+ Outputs the values within the Order.
140
+ """
141
+ print(
142
+ "Order: Symbol=%s, Type=%s, Quantity=%s, Direction=%s, Price=%s"
143
+ % (
144
+ self.symbol,
145
+ self.order_type,
146
+ self.quantity,
147
+ self.direction,
148
+ self.price,
150
149
  )
150
+ )
151
+
151
152
 
152
153
 
153
154
  class FillEvent(Event):
@@ -2,7 +2,7 @@ import json
2
2
  import re
3
3
  import ssl
4
4
  from datetime import datetime
5
- from typing import List
5
+ from typing import List, Literal
6
6
  from urllib.request import urlopen
7
7
 
8
8
  import certifi
@@ -18,7 +18,7 @@ __all__ = ["FmpData", "FmpNews", "FinancialNews"]
18
18
 
19
19
 
20
20
  def _get_search_query(query: str) -> str:
21
- if " " in query:
21
+ if " " in query or query == "":
22
22
  return query
23
23
  try:
24
24
  name = yf.Ticker(query).info["shortName"]
@@ -422,6 +422,102 @@ class FinancialNews(object):
422
422
  def get_fmp_news(self, api=None) -> FmpNews:
423
423
  return FmpNews(api=api)
424
424
 
425
+ def get_coindesk_news(
426
+ self,
427
+ query="",
428
+ lang: Literal["EN", "ES", "TR", "FR", "JP", "PT"] = "EN",
429
+ limit=50,
430
+ list_of_str=False,
431
+ ) -> List[str] | List[dict]:
432
+ """
433
+ Fetches and filters recent news articles from CoinDesk's News API.
434
+
435
+ Args:
436
+ query : str, optional
437
+ A search term to filter articles by title, body, or keywords.
438
+ If empty, all articles are returned without filtering (default is "").
439
+
440
+ lang : Literal["EN", "ES", "TR", "FR", "JP", "PT"], optional
441
+ Language in which to fetch news articles. Supported languages:
442
+ English (EN), Spanish (ES), Turkish (TR), French (FR), Japanese (JP), and Portuguese (PT).
443
+ Default is "EN".
444
+
445
+ limit : int, optional
446
+ Maximum number of articles to retrieve. Default is 50.
447
+
448
+ list_of_str : bool, optional
449
+ If True, returns a list of strings (concatenated article content).
450
+ If False, returns a list of filtered article dictionaries.
451
+ Default is False.
452
+
453
+ Returns:
454
+ List[str] | List[dict]
455
+ - If `query` is empty: returns a list of filtered article dictionaries.
456
+ - If `query` is provided:
457
+ - Returns a list of strings if `list_of_str=True`.
458
+ - Returns a list of filtered article dictionaries otherwise.
459
+
460
+ Each article dictionary contains the following fields:
461
+ - 'published_on': datetime of publication
462
+ - 'title': article headline
463
+ - 'subtitle': secondary headline
464
+ - 'url': direct link to the article
465
+ - 'body': article content
466
+ - 'keywords': associated tags
467
+ - 'sentiment': sentiment label
468
+ - 'status': publication status
469
+
470
+ Notes:
471
+ - Articles marked as sponsored are automatically excluded.
472
+ """
473
+ maximum = 100
474
+ if limit > maximum:
475
+ raise ValueError(f"Number of total news articles allowed is {maximum}")
476
+
477
+ response = requests.get(
478
+ "https://data-api.coindesk.com/news/v1/article/list",
479
+ params={"lang": lang, "limit": limit},
480
+ headers={"Content-type": "application/json; charset=UTF-8"},
481
+ )
482
+ json_response = response.json()
483
+ articles = json_response["Data"]
484
+ if len(articles) == 0:
485
+ return []
486
+ to_keep = [
487
+ "PUBLISHED_ON",
488
+ "TITLE",
489
+ "SUBTITLE",
490
+ "URL",
491
+ "BODY",
492
+ "KEYWORDS",
493
+ "SENTIMENT",
494
+ "STATUS",
495
+ ]
496
+ filtered_articles = []
497
+ for article in articles:
498
+ filtered_articles.append(
499
+ {
500
+ k.lower(): article[k]
501
+ if k in article and k != "PUBLISHED_ON"
502
+ else datetime.fromtimestamp(article[k])
503
+ for k in to_keep
504
+ if article[k] is not None and "sponsored" not in str(article[k])
505
+ }
506
+ )
507
+ if query == "" or len(filtered_articles) == 0:
508
+ return filtered_articles
509
+ to_return = []
510
+ query = _get_search_query(query)
511
+ for article in filtered_articles:
512
+ if not all(k in article for k in ("title", "body", "keywords")):
513
+ continue
514
+ text = article["title"] + " " + article["body"] + " " + article["keywords"]
515
+ if list_of_str and _find_news(query, text=text):
516
+ to_return.append(text)
517
+ if not list_of_str and _find_news(query, text=text):
518
+ to_return.append(article)
519
+ return to_return
520
+
425
521
 
426
522
  class FmpData(Toolkit):
427
523
  """
@@ -531,6 +531,7 @@ class Trade(RiskManagement):
531
531
  mm (bool): Weither to put stop loss and tp or not
532
532
  trail (bool): Weither to trail the stop loss or not
533
533
  comment (str): The comment for the opening position
534
+ volume (float): The volume (lot) to trade
534
535
  sl (float): The stop loss price
535
536
  tp (float): The take profit price
536
537
  """
@@ -621,7 +622,6 @@ class Trade(RiskManagement):
621
622
  mm (bool): Weither to put stop loss and tp or not
622
623
  trail (bool): Weither to trail the stop loss or not
623
624
  comment (str): The comment for the closing position
624
- symbol (str): The symbol to trade
625
625
  volume (float): The volume (lot) to trade
626
626
  sl (float): The stop loss price
627
627
  tp (float): The take profit price
@@ -506,6 +506,7 @@ class SentimentAnalyzer(object):
506
506
  reddit_posts = news.get_reddit_posts(
507
507
  ticker, n_posts=top_news, **{k: kwargs.get(k) for k in rd_params}
508
508
  )
509
+ coindesk_news = news.get_coindesk_news(query=ticker, list_of_str=True)
509
510
  fmp_source_news = []
510
511
  fmp_news = news.get_fmp_news(kwargs.get("fmp_api"))
511
512
  for source in ["articles"]: # , "releases", asset_type]:
@@ -518,7 +519,7 @@ class SentimentAnalyzer(object):
518
519
  source_news = []
519
520
  if any([len(s) > 0 for s in [yahoo_news, google_news]]):
520
521
  sources += 1
521
- for source in [reddit_posts, fmp_source_news]:
522
+ for source in [reddit_posts, fmp_source_news, coindesk_news]:
522
523
  if len(source) > 0:
523
524
  sources += 1
524
525
  # Compute sentiment
@@ -531,11 +532,17 @@ class SentimentAnalyzer(object):
531
532
  fmp_sentiment = self.analyze_sentiment(
532
533
  fmp_source_news, lexicon=lexicon, textblob=True
533
534
  )
535
+ coindesk_sentiment = self.analyze_sentiment(
536
+ coindesk_news, lexicon=lexicon, textblob=True
537
+ )
534
538
 
535
539
  # Weighted average sentiment score
536
540
  if sources != 0:
537
541
  overall_sentiment = (
538
- news_sentiment + reddit_sentiment + fmp_sentiment
542
+ news_sentiment
543
+ + reddit_sentiment
544
+ + fmp_sentiment
545
+ + coindesk_sentiment
539
546
  ) / sources
540
547
  else:
541
548
  overall_sentiment = 0.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bbstrader
3
- Version: 0.2.99
3
+ Version: 0.2.991
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/
@@ -81,8 +81,6 @@ Dynamic: requires-dist
81
81
  Dynamic: summary
82
82
 
83
83
  # Simplified Investment & Trading Toolkit
84
- ![bbstrader](https://github.com/bbalouki/bbstrader/blob/main/assets/bbstrader_logo.png?raw=true)
85
-
86
84
  [![Documentation Status](https://readthedocs.org/projects/bbstrader/badge/?version=latest)](https://bbstrader.readthedocs.io/en/latest/?badge=latest)
87
85
  [![PYPI Version](https://img.shields.io/pypi/v/bbstrader)](https://pypi.org/project/bbstrader/)
88
86
  [![PyPi status](https://img.shields.io/pypi/status/bbstrader.svg?maxAge=60)](https://pypi.python.org/pypi/bbstrader)
@@ -4,6 +4,7 @@ README.md
4
4
  requirements.txt
5
5
  setup.py
6
6
  bbstrader/__ini__.py
7
+ bbstrader/__init__.py
7
8
  bbstrader/__main__.py
8
9
  bbstrader/compat.py
9
10
  bbstrader/config.py
@@ -16,7 +16,7 @@ with io.open(path.join(here, "README.md"), encoding="utf-8") as f:
16
16
  with io.open(path.join(here, "requirements.txt"), encoding="utf-8") as f:
17
17
  REQUIREMENTS = [line.rstrip() for line in f]
18
18
 
19
- VERSION = "0.2.099"
19
+ VERSION = "0.2.991"
20
20
  DESCRIPTION = "Simplified Investment & Trading Toolkit"
21
21
 
22
22
  KEYWORDS = [
File without changes
File without changes
File without changes
File without changes