blob: 9879c1bf08263e6b84901d0603b484a79562eb41 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
from dataclasses import dataclass
from decimal import Decimal
@dataclass
class LedgerAction:
"""
A structured representation of a ledger row for cryptocurrency transactions.
The `LedgerAction` class encapsulates details of each action recorded in the ledger,
whether it's a deposit, trade, or other types of transactions.
Attributes:
type (str): The type of action, e.g., "trade" or "deposit".
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).
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).
"""
type: str
asset: str
amount: Decimal
fee: Decimal
timestamp: str
refid: str
@property
def date(self) -> str:
return self.timestamp.split(" ")[0]
|