-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
497de2c
commit d4d9611
Showing
23 changed files
with
62,155 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
name: Trading Bot Workflow | ||
|
||
on: | ||
# Trigger at 9:00 AM EST (13:00 UTC for Daylight Savings and 14:00 UTC for Standard Time) | ||
schedule: | ||
- cron: '0 13 * * 1-5' # Daylight Savings | ||
- cron: '0 14 * * 1-5' # Standard Time | ||
|
||
# Manual trigger: Allows the workflow to be triggered manually from the GitHub Actions tab | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 420 # Automatically stop the job after 6.5 hours (390 minutes) | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.12.6' # Use the appropriate Python version | ||
|
||
# Install ta-lib system dependencies | ||
- name: Install ta-lib from source | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y build-essential wget | ||
wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz | ||
tar -xzf ta-lib-0.4.0-src.tar.gz | ||
cd ta-lib | ||
./configure --prefix=/usr | ||
make | ||
sudo make install | ||
# Caching Hugging Face models | ||
- name: Cache Hugging Face models | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.cache/huggingface | ||
key: ${{ runner.os }}-huggingface-${{ hashFiles('requirements.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-huggingface- | ||
# Install Python dependencies | ||
- name: Install Python dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt # Install your Python dependencies including transformers and torch | ||
- name: Run Trading Bot Script | ||
run: | | ||
python bot.py # Replace this with the correct script filename if different | ||
# Commit and push chat_gpt_logs.json and trade_decisions.json if updated | ||
- name: Commit updated logs if they exist | ||
run: | | ||
git config --global user.name 'Abdullah Rashid' | ||
git config --global user.email '[email protected]' | ||
# Pull the latest changes from the remote repository | ||
git pull origin main --rebase # Ensure we're up to date with the remote | ||
# Check for changes and commit if any | ||
if git status --porcelain | grep -q 'chat_gpt_logs.json\|trade_decisions.json'; then | ||
git add chat_gpt_logs.json trade_decisions.json | ||
git commit -m "Update chat_gpt_logs and trade_decisions" | ||
else | ||
echo "No changes in logs to commit." | ||
continue-on-error: true # Continue even if there are no changes to commit | ||
|
||
- name: Push changes | ||
run: git push | ||
continue-on-error: true # Continue even if there's nothing to push | ||
|
||
# Post-job step to always commit logs when the job completes, even if it fails or is canceled | ||
- name: Always commit logs on job completion | ||
if: always() | ||
run: | | ||
git config --global user.name 'Abdullah Rashid' | ||
git config --global user.email '[email protected]' | ||
git add chat_gpt_logs.json trade_decisions.json | ||
git commit -m "Post-job commit of logs" || echo "No changes to commit" | ||
git push || echo "Nothing to push" | ||
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Base Python image | ||
FROM python:3.9-slim | ||
|
||
# Set working directory | ||
WORKDIR /app | ||
|
||
# Install system dependencies for TA-Lib and other required tools | ||
RUN apt-get update && apt-get install -y \ | ||
build-essential \ | ||
gcc \ | ||
wget \ | ||
make \ | ||
libtool \ | ||
automake \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Download and install TA-Lib from source | ||
RUN wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz \ | ||
&& tar -xzf ta-lib-0.4.0-src.tar.gz \ | ||
&& cd ta-lib && ./configure --prefix=/usr \ | ||
&& make && make install \ | ||
&& cd .. && rm -rf ta-lib ta-lib-0.4.0-src.tar.gz | ||
|
||
# Install Python dependencies | ||
COPY requirements.txt requirements.txt | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
# Copy project files | ||
COPY . . | ||
|
||
# Entry point to start the bot | ||
CMD ["python", "bot.py"] | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import requests | ||
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer | ||
|
||
analyzer = SentimentIntensityAnalyzer() | ||
|
||
NEWS_API_KEY = '' | ||
|
||
def get_news_sentiment(ticker): | ||
print(f"Fetching news sentiment for {ticker}") | ||
|
||
# Finnhub API URL for fetching company news | ||
url = f'https://finnhub.io/api/v1/company-news?symbol={ticker}&from=2023-01-01&to=2023-12-31&token={NEWS_API_KEY}' | ||
|
||
response = requests.get(url) | ||
news_data = response.json() | ||
|
||
if response.status_code == 200: | ||
total_score = 0 | ||
articles = news_data | ||
for article in articles: | ||
if 'headline' in article: | ||
sentiment_score = analyzer.polarity_scores(article['headline']) | ||
total_score += sentiment_score['compound'] | ||
avg_sentiment = total_score / len(articles) if articles else 0 | ||
print(f"Average sentiment for {ticker}: {avg_sentiment}") | ||
return avg_sentiment | ||
else: | ||
print(f"Error fetching news for {ticker}, Status Code: {response.status_code}") | ||
return 0 | ||
|
||
|
||
if __name__ == '__main__': | ||
get_news_sentiment('TSLA') |
Oops, something went wrong.