Skip to content
Open
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
183 changes: 81 additions & 102 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,149 +1,128 @@
# Quantex
# 📰 Quantex News API

Take a look at running scrapper on [Telegram Channel](https://t.me/quantex_signals)
A resurrected news API project — originally broken, now fully functional with PostgreSQL, async support, and a clean modular structure.

Powerful trading bot, based on ChatGPT sentiment analysis of news headlines.
---

## Motivation
## 🚀 What this project does

The goal of this project is to create a trading bot that can make money on the stock market. The bot will be based on the sentiment analysis of news headlines. The sentiment analysis will be done by a [OpenAi's ChatGPT](https://chat.openai.com/) model that has been trained on a large corpus of data. The bot will use the sentiment analysis to predict the stock market and make trades accordingly. It is inspired by paper released by Alejandro Lopez-Lira and Yuehua Tang from University of Florida on april 6th 2023, named ["Can ChatGPT Forecast Stock Price Movements? Return Predictability and Large Language Models"](https://arxiv.org/pdf/2304.07619.pdf)
- Provides a REST API for news articles
- Stores data in PostgreSQL (or SQLite for local testing)
- Uses async drivers for better performance
- Includes authentication via `x-secret` header

## Installation
---

Quantex uses [Docker](https://www.docker.com/) to run. To install Docker, follow the instructions on [Docker's website](https://docs.docker.com/get-docker/). For ease of use [Docker-compose](https://docs.docker.com/compose/) is also used. To install docker-compose, follow the instructions on [docker-compose's website](https://docs.docker.com/compose/install/).
## 🛠️ What was fixed

While development following tools are used:
- [Visual Studio Code](https://code.visualstudio.com/)
- [Git](https://git-scm.com/)
- [GitFlow](https://github.com/petervanderdoes/gitflow-avh)
- ✅ Database connection issues resolved
- ✅ Async driver support added
- ✅ Tables created via Alembic migrations
- ✅ GET and POST endpoints tested and working
- ✅ Authentication via `x-secret` header validated
- ✅ Modular project structure organized

- [Python 3.11](https://www.python.org/downloads/release/python-3110/)
- [Poetry](https://python-poetry.org/docs/)
---

- [PostgreSQL](https://www.postgresql.org/)
- [FastAPI](https://fastapi.tiangolo.com/)
- [SQLAlchemy](https://www.sqlalchemy.org/)
## 📁 Project Structure
quantex/
├── quantex/ # Main application package
│ ├── web/ # API routes and dependencies
│ ├── database/ # Models and DAOs
│ └── settings.py # Configuration
├── requirements.txt # Dependencies
├── alembic.ini # Migration config
└── README.md # This file

- [Flake8](https://flake8.pycqa.org/en/latest/)
- [Black](https://black.readthedocs.io/en/stable/)
- [Mypy](https://mypy.readthedocs.io/en/stable/)
---

- [TypeScript](https://www.typescriptlang.org/)
- [ESLint](https://eslint.org/)
- [Next.js](https://nextjs.org/)
- [Tailwind CSS](https://tailwindcss.com/)
- [Prettier](https://prettier.io/)
## 🧩 Technologies Used

and many, many more awesome tools.
- Python 3.10+
- FastAPI
- SQLAlchemy (async)
- PostgreSQL / SQLite
- Alembic
- Uvicorn
- Pydantic

# Setup
---

To setup the project, run the following commands:
## 📦 How to Run

```bash
# Clone the repository
git clone https://github.io/style77/quantex.git
# 1. Clone the repository
git clone https://github.com/alictech7-oss/quantex-news-api.git
cd quantex-news-api

# Change directory to the project
cd quantex
# 2. Create and activate virtual environment
python -m venv venv
venv\Scripts\activate

```
# 3. Install dependencies
pip install -r requirements.txt

Now it depends on you, how would you want to run project.
# 4. Run migrations
alembic upgrade head

## Docker
# 5. Start the server
python -m quantex

To run project with docker, you need to have docker and docker compose installed. After that you can run the following command:
🔑 Authentication
All endpoints require the x-secret header: x-secret: secret

**Development version**
```bash
docker-compose -f deploy/docker-compose.yml -f deploy/docker-compose.dev.yml --project-directory . up --build
```

**Production version**
```bash
docker-compose -f deploy/docker-compose.yml --project-directory . up --build
```

## Poetry

To run project with poetry, you need to have python 3.11 and poetry installed. After that you can run the following command:

*Following commends will only run API, that anyway won't work without database - to run **only database** you can run `docker-compose -f deploy/docker-compose.services.yml --project-directory . up --build`*
```bash
poetry install
```
📡 API Endpoints
Method Endpoint Description
GET /api/news/ List all news
POST /api/news/ Create a new news entry
GET /api/news/{id} Get news by ID

```bash
poetry run python -m quantex
```
📌 Notes
The original project was broken and abandoned.

### PgAdmin
This version was fully restored, tested, and documented.

To access pgadmin, you need to start development version of docker compose. After that to get ip of the pgadmin dashboard, run the following command:
Runs with PostgreSQL or SQLite (for local testing).

```bash
docker inspect pgadmin_container | grep IPAddress.
```
🙏 Credits & Original Work
This project is based on the original quantex-news-api repository.

The default email and password for pgadmin is `admin@admin.com root`.
To set up connection to the database, you need to create new server with the following details:
The original code was broken and abandoned.
This version includes:

connection address: `quantex-db`
port: `5432`
username: as specified in `.env` file
password: as specified in `.env` file
Full restoration of functionality

## Migrations
Database and async support fixes

To run migrations, you need to have python 3.11 and poetry installed. After that you can run the following command:
Updated dependencies and structure

```bash
poetry run alembic upgrade head
```
Clean documentation and organization

to create new migration, you can run the following command:
All improvements were made with respect to the original authors.

```bash
poetry run alembic revision --autogenerate -m "migration name"
```
👨‍💻 Maintained by
alictech7-oss

Before that, it's recommended to change ip of the database in `.env` file to `0.0.0.0` (if you already got database running)
📄 License
MIT — use, modify, and share freely.

## Chromedriver on ARM64
---

Running scraper on ARM64 is a bit tricky, because there is no official chromedriver for ARM64.
Look at [#727](https://github.com/ultrafunkamsterdam/undetected-chromedriver/issues/727) and [#1072](https://github.com/ultrafunkamsterdam/undetected-chromedriver/issues/1072) for more details.

To run scraper (on any arch) use following commands:

```bash
# Create new screen
screen -S scraper
## 🚀 **How to apply:**

# Run scraper
poetry run python -m quantex-scraper
```
1. Access: `https://github.com/alictech7-oss/quantex-news-api`
2. Click on the `README.md` file
3. Click the pencil (✏️) to edit
4. Replace with the content above
5. Commit directly to the `main` branch or make a PR

# Details
---

When you look at `.env.example` file you can see a lot of meaningless variables. In this section I want to explain them.
First in general is that, why is that project so huge, when it could just be one file with scraper, and maybe Telegram bot, the reason for that is that I want to make this project as modular as possible, so that it can be easily extended in the future. That's why it does contain API, Database, frontend, docker etc. Also making your own fullstack project is great way to learn and showoff.

Entire project structure is closed, which means that only getting access to the server will allow attacker to get access to all of the api keys, secrets etc.
Project is called a "bot", however it doesn't have any specific bot functionality, that's because it's bot for sending signals, not really trading bot. In future I might add trading bot functionality, but for now it's just a free signal bot.

### QUANTEX_INVESTMENT_HORIZON
If you look at the code, you can see that we are saving both short term and long term investment explanation, why is that variable then specified in `.env` file? Well, the reason is that we are then posting the results to Telegram channel, and posting all of the results would be too much. So we are posting only the results that are in the investment horizon specified in `.env` file. That way we can post only the results that are relevant to the channel.

# License

This project is licensed under the terms of the GNU GPLv3 license.

# Contributing

If you want to contribute to this project, please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.

# Authors

- **[Joachim Hodana](github.com/style77)** - _Initial work_ - [Quantex](github.com/style77/quantex)
Loading