summaryrefslogtreecommitdiff
path: root/finance
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2024-09-08 11:03:45 +0200
committerxengineering <me@xengineering.eu>2024-09-08 17:21:32 +0200
commit9faaac7e25d2efdca36dcb67f96960d3ab72ab82 (patch)
tree216ae659393fe96cfcae0bb27917ae50f1b8758f /finance
parentfb479fcd7a477959157bdeb9543f11c8b9e8870c (diff)
downloadfinance-py-9faaac7e25d2efdca36dcb67f96960d3ab72ab82.tar
finance-py-9faaac7e25d2efdca36dcb67f96960d3ab72ab82.tar.zst
finance-py-9faaac7e25d2efdca36dcb67f96960d3ab72ab82.zip
Implement finance.flow.display()
Diffstat (limited to 'finance')
-rw-r--r--finance/flow.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/finance/flow.py b/finance/flow.py
index 836c137..443966c 100644
--- a/finance/flow.py
+++ b/finance/flow.py
@@ -3,6 +3,8 @@ from datetime import datetime
from decimal import Decimal
from typing import Generator
+import matplotlib.pyplot
+
@dataclasses.dataclass(kw_only=True, frozen=True)
class Flow:
@@ -64,3 +66,15 @@ def simulate(
values.append(value)
return (dates, values)
+
+
+def display(data: tuple[list[datetime], list[Decimal]]) -> None:
+ matplotlib.pyplot.plot(
+ list(data[0]), # type: ignore
+ [float(i) for i in data[1]],
+ label="Money",
+ )
+ matplotlib.pyplot.xlabel("Time")
+ matplotlib.pyplot.legend()
+ matplotlib.pyplot.xticks(rotation=45)
+ matplotlib.pyplot.show()