Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ git clone https://github.com/microsoft/vcpkg
| :----------------- | :-------------------------------------------------------------------------------------------------------------------- |
| **Run Backtest** | `python -m bbstrader --run backtest --strategy SMAStrategy --account MY_ACCOUNT --config backtest.json` |
| **Live Execution** | `python -m bbstrader --run execution --strategy KalmanFilter --account MY_ACCOUNT --config execution.json --parallel` |
| **Copy Trades** | `python -m bbstrader --run copier --source 123456 --targets 789012 --risk_multiplier 2.0` |
| **Copy Trades** | `python -m bbstrader --run copier --source "S1" --destination "D1"` |
| **Get Help** | `python -m bbstrader --help` |

**Config Example** (`~/.bbstrader/execution/execution.json`):
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ dependencies = [
"tweepy>=4.16.0",
"vaderSentiment>=3.3.2",
"yfinance>=0.2.65",
"en_core_web_sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.8.0/en_core_web_sm-3.8.0-py3-none-any.whl",
]
authors = [
{ name = "Bertin Balouki SIMYELI", email = "bertin@bbs-trading.com" },
Expand Down
30 changes: 15 additions & 15 deletions src/bbstrader/models/nlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,21 @@
from typing import Dict, List, Tuple

import dash
import en_core_web_sm
import matplotlib.pyplot as plt
import nltk
import pandas as pd
import plotly.express as px
from bbstrader.core.data import FinancialNews
import spacy
from dash import dcc, html
from dash.dependencies import Input, Output
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
from spacy.cli import download
from textblob import TextBlob
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer

from bbstrader.core.data import FinancialNews

__all__ = [
"TopicModeler",
"SentimentAnalyzer",
Expand Down Expand Up @@ -349,13 +351,11 @@ def __init__(self):
nltk.download("stopwords", quiet=True)

try:
self.nlp = en_core_web_sm.load()
self.nlp.disable_pipes("ner")
self.nlp = spacy.load("en_core_web_sm", disable=["ner"])
except OSError:
raise OSError(
"SpaCy model 'en_core_web_sm' not found. "
"Please install it using 'python -m spacy download en_core_web_sm'."
)
print("Downloading 'en_core_web_sm' model for spaCy...")
download("en_core_web_sm")
self.nlp = spacy.load("en_core_web_sm", disable=["ner"])

def preprocess_texts(self, texts: list[str]):
def clean_doc(Doc):
Expand Down Expand Up @@ -403,20 +403,19 @@ def __init__(self):

"""
nltk.download("punkt", quiet=True)
nltk.download('punkt_tab', quiet=True)
nltk.download("punkt_tab", quiet=True)
nltk.download("stopwords", quiet=True)

self.analyzer = SentimentIntensityAnalyzer()
self._stopwords = set(stopwords.words("english"))

try:
self.nlp = en_core_web_sm.load()
self.nlp.disable_pipes("ner")
self.nlp = spacy.load("en_core_web_sm", disable=["ner"])
except OSError:
raise OSError(
"SpaCy model 'en_core_web_sm' not found. "
"Please install it using 'python -m spacy download en_core_web_sm'."
)
print("Downloading 'en_core_web_sm' model for spaCy...")
download("en_core_web_sm")
self.nlp = spacy.load("en_core_web_sm", disable=["ner"])

self.news = FinancialNews()

def preprocess_text(self, text: str):
Expand Down Expand Up @@ -930,3 +929,4 @@ def update_dashboard(n):
return bar_chart, scatter_chart

app.run()
app.run()
Loading