An open API service indexing awesome lists of open source software.

https://github.com/mxplesticks/snpi-stock-ticker

A simple and modern Python script that displays real-time stock market data on a Raspberry Pi screen. (via finnhub api) :)
https://github.com/mxplesticks/snpi-stock-ticker

python raspberry-pi stock-market ticker

Last synced: about 2 months ago
JSON representation

A simple and modern Python script that displays real-time stock market data on a Raspberry Pi screen. (via finnhub api) :)

Awesome Lists containing this project

README

          

# snPi Stock Ticker

A real-time stock monitoring application designed for tracking the S&P 500 ETF (VOO). Built with Tkinter and Matplotlib, utilizing the Finnhub API for live market data. The application provides live stock prices, percentage changes, market status indicators, and historical price visualizations.

**Note:** The application is currently hardcoded to track VOO, but the ticker symbol can be easily modified in the source code to monitor other stocks.

---

## Features

- Real-time stock data with 3-second update intervals
- Dynamic price history graphs with color-coded trend indicators
- Animated price and percentage change displays
- Market status monitoring (Open/Closed)
- Modern dark-themed user interface

---

## System Requirements

- Python 3.7 or higher
- Compatible with Raspberry Pi and Windows systems

---

## Installation

### Virtual Environment Setup

Using a virtual environment is strongly recommended to maintain isolated dependencies. For detailed information on Python virtual environments, refer to the [Real Python Virtual Environments Guide](https://realpython.com/python-virtual-environments-a-primer/).

#### Raspberry Pi / Linux

```bash
sudo apt update
sudo apt install python3-venv python3-pip -y
python3 -m venv stock-env
source stock-env/bin/activate
```

#### Windows

```bash
python -m venv stock-env
stock-env\Scripts\activate
```

---

### Dependency Installation

With your virtual environment activated, install the required packages:

#### Core Dependencies (All Platforms)

```bash
pip install matplotlib finnhub-python
```

Note: Tkinter is included with most Python installations. If needed, install separately using your system's package manager.

#### Platform-Specific Dependencies

**Raspberry Pi Additional Requirements:**

For Tkinter support:
```bash
sudo apt-get install python3-tk
```

For Matplotlib dependencies:
```bash
sudo apt install libatlas3-base libatlas-base-dev
```

---

## Usage

1. Clone or download the project repository
2. Activate your virtual environment
3. Execute the application:
```bash
python stock_tracker.py
```

The application window will display live updates for VOO (Vanguard S&P 500 ETF).

### Changing the Tracked Stock

To monitor a different stock, locate and modify the ticker symbol in the source code:
```python
self.symbol = "VOO" # Change to your desired ticker symbol
```

---

## API Configuration

### Obtaining a Finnhub API Key

1. Register for a free account at [https://finnhub.io/](https://finnhub.io/)
2. Retrieve your API key from the dashboard
3. Update the API key in the script:
```python
self.finnhub_client = finnhub.Client("YOUR_API_KEY_HERE")
```

---

## Troubleshooting

### Matplotlib Installation Issues

If you encounter errors related to Matplotlib on Raspberry Pi:
```bash
sudo apt-get install libatlas-base-dev
sudo apt install libatlas3-base
```

### Performance Optimization

For systems with limited resources (such as Raspberry Pi), consider reducing the update frequency by modifying the refresh interval:
```python
self.root.after(5000, self.update_data) # Changed from 3000ms to 5000ms
```

### Time Zone Considerations

The application uses Eastern Standard Time (EST) for market status calculations. Adjust the timezone logic if operating in a different region.

---

## Hardware Components

The following components are recommended for a complete Raspberry Pi-based deployment:

1. **[Mini Aluminum Heat Sink (Adafruit #3084)](https://www.adafruit.com/product/3084)**
Provides thermal management for improved Raspberry Pi performance

2. **[90-Degree Ribbon Micro USB Cable](https://www.amazon.com/dp/B077M5NW1M)**
Space-saving flexible USB cable with right-angle connector

3. **[Raspberry Pi Protective Case (Adafruit #2258)](https://www.adafruit.com/product/2258)**
Durable enclosure for secure Raspberry Pi housing

4. **[3.5" TFT LCD Touch Screen Display](https://www.microcenter.com/product/632693/35_Inch_TFT_LCD_Touch_Screen_Monitor)**
Compact touchscreen monitor ideal for embedded monitoring applications

---

## License

This project is released as open-source software. Users are free to modify and distribute the code according to their needs.

---

## Contributing

Contributions, bug reports, and feature requests are welcome. Please submit issues or pull requests through the project repository.