new model and endpoints..

This commit is contained in:
samantha42
2026-03-28 08:33:12 +01:00
parent c2276b6e13
commit 31108a16d0
3 changed files with 61 additions and 1 deletions

View File

@@ -69,6 +69,29 @@ func InitDB(db *sql.DB) {
UNIQUE(company_id, name)
);
-- parent table
CREATE TABLE closed_positions (
id INTEGER PRIMARY KEY AUTOINCREMENT,
symbol TEXT NOT NULL,
currency_code TEXT NOT NULL,
product TEXT NOT NULL,
open_time DATETIME NOT NULL,
realized_gain REAL,
tax_amount REAL,
holding_days INTEGER
);
-- child table, one row per close lot
CREATE TABLE close_entries (
id INTEGER PRIMARY KEY AUTOINCREMENT,
closed_position_id INTEGER NOT NULL REFERENCES closed_positions(id),
shares INTEGER NOT NULL,
in_price REAL NOT NULL,
out_price REAL NOT NULL,
gain_price REAL NOT NULL,
close_time DATETIME NOT NULL
);
CREATE TABLE IF NOT EXISTS revenue_entries (
id INTEGER PRIMARY KEY AUTOINCREMENT,
company_id INTEGER NOT NULL,