summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kraken.py3
-rw-r--r--ledger_action.py8
-rw-r--r--test_kraken.py16
3 files changed, 15 insertions, 12 deletions
diff --git a/kraken.py b/kraken.py
index 9048a7d..db1e9a7 100644
--- a/kraken.py
+++ b/kraken.py
@@ -5,14 +5,13 @@ from ledger_action import LedgerAction
def parse_row(row: dict[str, str]) -> LedgerAction:
- date = row["time"].split(" ")[0]
return LedgerAction(
type=row["type"],
asset=row["asset"],
amount=Decimal(row["amount"]),
fee=Decimal(row.get("fee", "0")),
refid=row.get("refid", ""),
- date=date,
+ timestamp=row["time"],
)
diff --git a/ledger_action.py b/ledger_action.py
index cc0eb83..9879c1b 100644
--- a/ledger_action.py
+++ b/ledger_action.py
@@ -15,7 +15,7 @@ class LedgerAction:
asset (str): The cryptocurrency or fiat asset associated with the action.
amount (Decimal): The amount involved in the action. Positive for deposits, negative for withdrawals.
fee (Decimal): The transaction fee (if applicable).
- date (str): The date of the action in string format (typically "YYYY-MM-DD").
+ timestamp (str): The date of the action in string format (typically "YYYY-MM-DD HH:mm:ss").
refid (str): A reference ID used to group related rows (e.g., EUR-crypto trades).
"""
@@ -23,5 +23,9 @@ class LedgerAction:
asset: str
amount: Decimal
fee: Decimal
- date: str
+ timestamp: str
refid: str
+
+ @property
+ def date(self) -> str:
+ return self.timestamp.split(" ")[0]
diff --git a/test_kraken.py b/test_kraken.py
index 7b3776a..8550003 100644
--- a/test_kraken.py
+++ b/test_kraken.py
@@ -24,7 +24,7 @@ class TestKrakenFunctions(unittest.TestCase):
amount=Decimal("0.5"),
fee=Decimal("0.001"),
refid="12345",
- date="2025-04-16",
+ timestamp="2025-04-16 12:00:00",
)
self.assertEqual(parse_row(row), expected)
@@ -41,7 +41,7 @@ class TestKrakenFunctions(unittest.TestCase):
amount=Decimal("2.0"),
fee=Decimal("0"), # Default fee
refid="", # Default refid
- date="2025-04-16",
+ timestamp="2025-04-16 15:00:00",
)
self.assertEqual(parse_row(row), expected)
@@ -58,7 +58,7 @@ class TestKrakenFunctions(unittest.TestCase):
amount=Decimal("1.5"),
fee=Decimal("0.01"),
refid="67890",
- date="2025-04-16",
+ timestamp="2025-04-16 09:00:00",
)
]
self.assertEqual(read_ledger("dummy_path.csv"), expected)
@@ -94,7 +94,7 @@ class TestKrakenFunctionsRealFiles(unittest.TestCase):
amount=Decimal("1000.0000"),
fee=Decimal("0"),
refid="",
- date="2024-07-01",
+ timestamp="2024-07-01 00:00:00",
),
LedgerAction(
type="trade",
@@ -102,7 +102,7 @@ class TestKrakenFunctionsRealFiles(unittest.TestCase):
amount=Decimal("-130.4204"),
fee=Decimal("0"),
refid="d1e57f",
- date="2024-07-12",
+ timestamp="2024-07-12 16:26:22",
),
LedgerAction(
type="trade",
@@ -110,7 +110,7 @@ class TestKrakenFunctionsRealFiles(unittest.TestCase):
amount=Decimal("1321.95097670"),
fee=Decimal("5.28780391"),
refid="d1e57f",
- date="2024-07-12",
+ timestamp="2024-07-12 16:26:22",
),
LedgerAction(
type="withdrawal",
@@ -118,7 +118,7 @@ class TestKrakenFunctionsRealFiles(unittest.TestCase):
amount=Decimal("-1312.66317279"),
fee=Decimal("4.00000000"),
refid="",
- date="2024-07-12",
+ timestamp="2024-07-12 16:36:49",
),
LedgerAction(
type="deposit",
@@ -126,7 +126,7 @@ class TestKrakenFunctionsRealFiles(unittest.TestCase):
amount=Decimal("100.0000"),
fee=Decimal("0"),
refid="",
- date="2024-08-02",
+ timestamp="2024-08-02 14:24:30",
),
]