initial commit

This commit is contained in:
coddard
2026-05-18 00:31:08 +03:00
commit 0096c8819b
26 changed files with 2851 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
import logging
import sqlite3
import threading
logger = logging.getLogger(__name__)
def ensure_database(db_path="trades.db"):
logger.info(f"Ensuring database exists at: {db_path}")
conn = sqlite3.connect(db_path, check_same_thread=False)
cursor = conn.cursor()
cursor.execute("""
CREATE TABLE IF NOT EXISTS trades (
id INTEGER PRIMARY KEY AUTOINCREMENT,
timestamp INTEGER NOT NULL,
symbol TEXT NOT NULL,
action TEXT NOT NULL,
quantity INTEGER NOT NULL,
price REAL NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
)
""")
conn.commit()
logger.info("Database is ready.")
db_write_lock = threading.Lock()
return conn, cursor, db_write_lock