Metadata-Version: 2.4
Name: chart-to-code
Version: 0.1.0
Summary: A self-hosted trading assistant based on a trained vision-language-model and algorithmic trading concepts.
Project-URL: Homepage, https://github.com/Ruby-xantho/chart-to-code
Project-URL: Repository, https://github.com/Ruby-xantho/chart-to-code
Project-URL: Issues, https://github.com/Ruby-xantho/chart-to-code/issues
Project-URL: Documentation, https://github.com/Ruby-xantho/chart-to-code#readme
Author-email: Ahmad Shalaby <ahmad.t.shalaby@gmail.com>
Maintainer-email: Ahmad Shalaby <ahmad.t.shalaby@gmail.com>
License: MIT License
        
        Copyright (c) 2025, Ahmad Shalaby
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Office/Business :: Financial :: Investment
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Requires-Dist: ccxt
Requires-Dist: matplotlib
Requires-Dist: mplfinance
Requires-Dist: numpy
Requires-Dist: openai
Requires-Dist: pandas
Requires-Dist: pyarrow
Requires-Dist: streamlit
Requires-Dist: streamlit-autorefresh
Provides-Extra: dev
Requires-Dist: black; extra == 'dev'
Requires-Dist: flake8; extra == 'dev'
Requires-Dist: mypy; extra == 'dev'
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: pytest-cov; extra == 'dev'
Provides-Extra: extras
Requires-Dist: pillow; extra == 'extras'
Requires-Dist: python-dotenv; extra == 'extras'
Provides-Extra: gpu
Requires-Dist: accelerate==1.6.0; extra == 'gpu'
Requires-Dist: autoawq==0.2.9; extra == 'gpu'
Requires-Dist: build==1.2.2.post1; extra == 'gpu'
Requires-Dist: cachetools==5.5.2; extra == 'gpu'
Requires-Dist: langchain-community==0.3.24; extra == 'gpu'
Requires-Dist: langchain==0.3.25; extra == 'gpu'
Requires-Dist: openpyxl==3.1.5; extra == 'gpu'
Requires-Dist: optimum==1.25.3; extra == 'gpu'
Requires-Dist: pillow==11.2.1; extra == 'gpu'
Requires-Dist: pypdf4==1.27.0; extra == 'gpu'
Requires-Dist: qwen-vl-utils==0.0.8; extra == 'gpu'
Requires-Dist: tiktoken==0.9.0; extra == 'gpu'
Requires-Dist: torch==2.6.0; extra == 'gpu'
Requires-Dist: torchaudio==2.6.0; extra == 'gpu'
Requires-Dist: torchvision==0.21.0; extra == 'gpu'
Requires-Dist: transformers==4.51.3; extra == 'gpu'
Requires-Dist: triton==3.2.0; extra == 'gpu'
Requires-Dist: typing==3.7.4.3; extra == 'gpu'
Requires-Dist: vllm==0.8.3; extra == 'gpu'
Provides-Extra: trading
Requires-Dist: asyncio-mqtt; extra == 'trading'
Requires-Dist: ccxt; extra == 'trading'
Requires-Dist: python-dotenv; extra == 'trading'
Provides-Extra: training
Requires-Dist: datasets; extra == 'training'
Requires-Dist: evaluate; extra == 'training'
Requires-Dist: jsonlines; extra == 'training'
Requires-Dist: peft; extra == 'training'
Requires-Dist: scikit-learn; extra == 'training'
Requires-Dist: torch; extra == 'training'
Requires-Dist: transformers; extra == 'training'
Description-Content-Type: text/markdown

# Chart to Code

![PyPI version](https://img.shields.io/pypi/v/chart-to-code.svg)
[![Documentation Status](https://readthedocs.org/projects/chart-to-code/badge/?version=latest)](https://chart-to-code.readthedocs.io/en/latest/?version=latest)
[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

A self-hosted trading assistant powered by a trained vision-language model (VLM) for trend analysis and algorithmic trading decisions.

* PyPI package: https://pypi.org/project/chart-to-code/
* Repository: https://github.com/Ruby-xantho/chart-to-code
* Free software: MIT License
* Documentation: https://github.com/Ruby-xantho/chart-to-code#readme

## About

**Chart-to-Code** is a vision-language model trained specifically for financial chart analysis and trend trading. The system analyzes live market data, generates technical analysis charts, and provides trading signals through a trained VLM that understands price action, momentum indicators, and market trends.

## Key Features

- **Custom-Trained VLM**: Fine-tuned vision-language model specialized for financial chart analysis
- **Real-Time Market Analysis**: Live data fetching from cryptocurrency exchanges via CCXT
- **Multi-Panel Chart Generation**:
  - Price charts with moving averages (EMA13, EMA21, SMMA14)
  - Awesome Oscillator momentum analysis
  - Stochastic RSI indicators
- **Automated Trading Signals**: AI-generated buy/sell/hold recommendations
- **Rule-Based Validation**: Hybrid approach combining ML predictions with algorithmic rules
- **Interactive Web Interface**: Streamlit-based dashboard for real-time analysis
- **Exchange Integration Ready**: Framework prepared for future live trading connections

## Technical Architecture

The system combines several components:
- **VLM Core**: Custom-trained Qwen2.5-VL model for chart interpretation
- **Data Pipeline**: Real-time market data via CCXT (Binance, others)
- **Chart Generation**: Multi-panel technical analysis visualization
- **Signal Processing**: Rule engine for trade signal validation
- **Web Interface**: Streamlit app for user interaction

## Installation

### Basic Installation
```bash
git clone https://github.com/Ruby-xantho/chart-to-code.git
cd chart-to-code
pip install -e .
```

### If you have access to a NVIDIA GPU like an A40, you can try this
```bash
pip install -e ".[gpu]"
```

### Requirements
- **Python**: 3.10+
- **For local hosting the model and running it with VLM inference**: NVIDIA GPU with ≥32 GB VRAM (A40, A100, etc.)
- **Memory**: ≥4 GB RAM for basic usage, ≥32 GB for model training and self hosting the model

## Usage

### Run the Trading Assistant
```bash
streamlit run app/streamlit_app.py
```

The web interface allows you to:
1. Select cryptocurrency pairs for analysis
2. View real-time technical analysis charts
3. Get AI-powered trading signals
4. Monitor multiple assets simultaneously

### Supported Markets
Currently supports cryptocurrency markets via CCXT:
- Bitcoin (BTC/USDT)
- Ethereum (ETH/USDT)
- Major altcoins (SOL, ADA, LINK, etc.)

## Model Training

The VLM was trained on a custom dataset of:
- 1000+ labeled chart examples
- Multiple timeframes (1h, 4h, 1d)
- Five signal categories: Sell Signal, Possible Buy Entry, Bullish, Bearish, Inconclusive
- Rule-based ground truth labels for supervised learning

## Project Structure

```
chart-to-code/
├── src/chart_to_code/     # Core package
├── app/                   # Streamlit web application
├── model_training/        # VLM training pipeline
├── exchange_bots/         # Trading bot implementations
├── validate_model/        # Model validation tools
└── tests/                 # Test suite
```

## Future Development

- **Live Trading Integration**: Connect to exchange APIs for automated execution
- **Additional Markets**: Expand beyond crypto to forex, stocks, commodities  
- **Advanced Strategies**: Multi-timeframe analysis and complex trading logic
- **Portfolio Management**: Risk management and position sizing
- **Backtesting Engine**: Historical strategy performance analysis

## Contributing

Contributions are welcome! Please read [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and guidelines.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Disclaimer

This software is for educational and research purposes. Trading involves significant risk of loss. Always do your own research and never invest more than you can afford to lose.

---

*This package was created with [Cookiecutter](https://github.com/audreyfeldroy/cookiecutter) and the [audreyfeldroy/cookiecutter-pypackage](https://github.com/audreyfeldroy/cookiecutter-pypackage) project template.*
