removed old files to recode
This commit is contained in:
64
storage.py
64
storage.py
@@ -1,64 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import sqlite3
|
||||
import time
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
|
||||
class Storage:
|
||||
def __init__(self, path: str = "storage.sqlite"):
|
||||
self.conn = sqlite3.connect(path)
|
||||
self.conn.execute("PRAGMA journal_mode=WAL;")
|
||||
self._init()
|
||||
|
||||
def _init(self) -> None:
|
||||
self.conn.execute(
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS decisions (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
ts REAL NOT NULL,
|
||||
symbol TEXT NOT NULL,
|
||||
series_ticker TEXT NOT NULL,
|
||||
market_ticker TEXT NOT NULL,
|
||||
close_time TEXT NOT NULL,
|
||||
strike REAL NOT NULL,
|
||||
side TEXT NOT NULL,
|
||||
market_prob REAL NOT NULL,
|
||||
fair_prob REAL NOT NULL,
|
||||
edge REAL NOT NULL,
|
||||
spread REAL NOT NULL,
|
||||
jump REAL NOT NULL,
|
||||
reason TEXT NOT NULL
|
||||
)
|
||||
"""
|
||||
)
|
||||
self.conn.execute(
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS orders (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
ts REAL NOT NULL,
|
||||
market_ticker TEXT NOT NULL,
|
||||
order_id TEXT,
|
||||
mode TEXT NOT NULL,
|
||||
status TEXT NOT NULL,
|
||||
details TEXT
|
||||
)
|
||||
"""
|
||||
)
|
||||
self.conn.commit()
|
||||
|
||||
def log_decision(self, **row: Any) -> None:
|
||||
cols = ",".join(row.keys())
|
||||
qs = ",".join(["?"] * len(row))
|
||||
self.conn.execute(f"INSERT INTO decisions ({cols}) VALUES ({qs})", list(row.values()))
|
||||
self.conn.commit()
|
||||
|
||||
def log_order(self, market_ticker: str, order_id: Optional[str], mode: str, status: str, details: str = "") -> None:
|
||||
self.conn.execute(
|
||||
"INSERT INTO orders (ts, market_ticker, order_id, mode, status, details) VALUES (?, ?, ?, ?, ?, ?)",
|
||||
(time.time(), market_ticker, order_id, mode, status, details),
|
||||
)
|
||||
self.conn.commit()
|
||||
|
||||
def close(self) -> None:
|
||||
self.conn.close()
|
||||
Reference in New Issue
Block a user