first commit

This commit is contained in:
Bobby Abellana 2025-02-03 20:11:47 -08:00
commit bbc307f3d8
No known key found for this signature in database
GPG Key ID: 647714CC45F3647B
11 changed files with 81 additions and 0 deletions

19
.gitignore vendored Normal file
View File

@ -0,0 +1,19 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# Virtual environments
venv/
env/
# Data and reports
data/
reports/
# Configuration files that contain secrets
.env
# OS files
.DS_Store
Thumbs.db

15
README.md Normal file
View File

@ -0,0 +1,15 @@
# My Stock Screener
## Overview
This repository contains a Python-based stock screener that evaluates multiple metrics on a set of stocks, assigns a score, and outputs a CSV of the results.
## Project Structure
- **src/** contains the main application code.
- **data/** is where you can store raw input data; it is ignored by Git.
- **reports/** is where generated CSV output is stored.
## Setup Instructions
1. Create a virtual environment:
```bash
python3 -m venv venv
source venv/bin/activate

12
requirements.txt Normal file
View File

@ -0,0 +1,12 @@
# Basic data libraries
pandas
numpy
# Database connector
clickhouse-connect
# For scheduling or datetime manipulations (if needed)
python-dotenv
# For testing
pytest

0
src/config.py Normal file
View File

35
src/db/db_connection.py Normal file
View File

@ -0,0 +1,35 @@
### `src/db/db_connection.py` (ClickHouse example)
```python
import logging
import clickhouse_connect
import uuid
import time
def create_client(clickhouse_password):
"""
Create a ClickHouse client with a unique session and retry logic.
"""
max_retries = 3
retry_delay = 2 # seconds
for attempt in range(max_retries):
try:
client = clickhouse_connect.get_client(
host="clickhouse.abellana.work",
port=443,
username="default",
password=clickhouse_password,
secure=True,
session_id=str(uuid.uuid4()),
settings={'session_timeout': 60}
)
# Test the connection
client.query('SELECT 1')
return client
except Exception as e:
if attempt < max_retries - 1:
logging.warning(f"Connection attempt {attempt + 1} failed: {str(e)}")
time.sleep(retry_delay)
else:
raise

0
src/db/queries.py Normal file
View File

0
src/main.py Normal file
View File

View File

0
src/screener/metrics.py Normal file
View File

0
src/screener/screener.py Normal file
View File

0
tests/test_screener.py Normal file
View File