ibkr-flex-accounting 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ibkr_flex_accounting/__init__.py +64 -0
- ibkr_flex_accounting/_io.py +28 -0
- ibkr_flex_accounting/account.py +864 -0
- ibkr_flex_accounting/cli.py +134 -0
- ibkr_flex_accounting/controls.py +109 -0
- ibkr_flex_accounting/performance.py +156 -0
- ibkr_flex_accounting/py.typed +0 -0
- ibkr_flex_accounting/reporting.py +354 -0
- ibkr_flex_accounting/store.py +673 -0
- ibkr_flex_accounting-0.1.0.dist-info/METADATA +124 -0
- ibkr_flex_accounting-0.1.0.dist-info/RECORD +14 -0
- ibkr_flex_accounting-0.1.0.dist-info/WHEEL +4 -0
- ibkr_flex_accounting-0.1.0.dist-info/entry_points.txt +2 -0
- ibkr_flex_accounting-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"""Strict, resumable Interactive Brokers Flex Web Service v3 accounting engine."""
|
|
2
|
+
|
|
3
|
+
from . import account, controls, performance, reporting, store
|
|
4
|
+
from .account import SCHEMA, TOL, empty_store, latest, load, merge, parse, revision, value
|
|
5
|
+
from .controls import validate
|
|
6
|
+
from .performance import parse as parse_performance
|
|
7
|
+
from .reporting import JournalError, ReportingError, acknowledge, acquisition, request
|
|
8
|
+
from .store import (
|
|
9
|
+
activity,
|
|
10
|
+
bootstrap,
|
|
11
|
+
collect,
|
|
12
|
+
compact,
|
|
13
|
+
configuration,
|
|
14
|
+
income_facts,
|
|
15
|
+
known_shas,
|
|
16
|
+
missing_performance_day,
|
|
17
|
+
missing_performance_days,
|
|
18
|
+
nav_history,
|
|
19
|
+
periods,
|
|
20
|
+
prune_superseded,
|
|
21
|
+
save,
|
|
22
|
+
superseded,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
__version__ = "0.1.0"
|
|
26
|
+
|
|
27
|
+
__all__ = [
|
|
28
|
+
"SCHEMA",
|
|
29
|
+
"TOL",
|
|
30
|
+
"JournalError",
|
|
31
|
+
"ReportingError",
|
|
32
|
+
"__version__",
|
|
33
|
+
"account",
|
|
34
|
+
"acknowledge",
|
|
35
|
+
"acquisition",
|
|
36
|
+
"activity",
|
|
37
|
+
"bootstrap",
|
|
38
|
+
"collect",
|
|
39
|
+
"compact",
|
|
40
|
+
"configuration",
|
|
41
|
+
"controls",
|
|
42
|
+
"empty_store",
|
|
43
|
+
"income_facts",
|
|
44
|
+
"known_shas",
|
|
45
|
+
"latest",
|
|
46
|
+
"load",
|
|
47
|
+
"merge",
|
|
48
|
+
"missing_performance_day",
|
|
49
|
+
"missing_performance_days",
|
|
50
|
+
"nav_history",
|
|
51
|
+
"parse",
|
|
52
|
+
"parse_performance",
|
|
53
|
+
"performance",
|
|
54
|
+
"periods",
|
|
55
|
+
"prune_superseded",
|
|
56
|
+
"reporting",
|
|
57
|
+
"request",
|
|
58
|
+
"revision",
|
|
59
|
+
"save",
|
|
60
|
+
"store",
|
|
61
|
+
"superseded",
|
|
62
|
+
"validate",
|
|
63
|
+
"value",
|
|
64
|
+
]
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""Atomic file writes and SHA-256 digests with no external dependencies."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import hashlib
|
|
6
|
+
import os
|
|
7
|
+
import tempfile
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def digest(path: str | Path) -> str:
|
|
12
|
+
"""Return the hex SHA-256 digest of a file."""
|
|
13
|
+
return hashlib.sha256(Path(path).read_bytes()).hexdigest()
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def atomic_write(path: str | Path, data: str | bytes) -> None:
|
|
17
|
+
"""Write bytes or UTF-8 text atomically via same-directory temp file + fsync + replace."""
|
|
18
|
+
target = Path(path)
|
|
19
|
+
target.parent.mkdir(parents=True, exist_ok=True)
|
|
20
|
+
with tempfile.NamedTemporaryFile(dir=target.parent, delete=False) as handle:
|
|
21
|
+
temp = Path(handle.name)
|
|
22
|
+
handle.write(data.encode("utf-8") if isinstance(data, str) else data)
|
|
23
|
+
handle.flush()
|
|
24
|
+
os.fsync(handle.fileno())
|
|
25
|
+
try:
|
|
26
|
+
os.replace(temp, target)
|
|
27
|
+
finally:
|
|
28
|
+
temp.unlink(missing_ok=True)
|