first commit
This commit is contained in:
commit
bbc307f3d8
19
.gitignore
vendored
Normal file
19
.gitignore
vendored
Normal 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
15
README.md
Normal 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
12
requirements.txt
Normal 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
0
src/config.py
Normal file
35
src/db/db_connection.py
Normal file
35
src/db/db_connection.py
Normal 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
0
src/db/queries.py
Normal file
0
src/main.py
Normal file
0
src/main.py
Normal file
0
src/patterns/pattern_finder.py
Normal file
0
src/patterns/pattern_finder.py
Normal file
0
src/screener/metrics.py
Normal file
0
src/screener/metrics.py
Normal file
0
src/screener/screener.py
Normal file
0
src/screener/screener.py
Normal file
0
tests/test_screener.py
Normal file
0
tests/test_screener.py
Normal file
Loading…
Reference in New Issue
Block a user