feat: DB-first architecture with lock-safe writes

- price_monitor: writes live prices to both JSON and mofin.db (holdings + live_prices + portfolio_summary)
- mofin_db: added execute_with_retry/commit_with_retry with exponential backoff on 'database is locked'
- mofin_db: increased timeout 5s->15s, added PRAGMA busy_timeout=15000
- price_monitor retry loop: fixed break-before-if-ok bug (was not retrying on write failure)
- DB connection: WAL mode + retry decorator for all write operations
- cash sync: preserves DB authoritative cash (JSON cash not pushed to DB)

This is the DB-first version. JSON writes remain for dashboard compatibility.
Next step: remove JSON writes entirely for full DB-only architecture.
This commit is contained in:
知微
2026-07-06 12:02:11 +08:00
parent 687155487d
commit e185b4e4dc
30 changed files with 1856 additions and 2042 deletions
+66
View File
@@ -27,6 +27,12 @@
"high": 1215.52,
"low": 1185.0,
"close": 1194.45
},
{
"date": "2026-07-06",
"high": 1215.0,
"low": 1180.0,
"close": 1203.23
}
],
"02202": [
@@ -63,6 +69,12 @@
"high": 50.2,
"low": 48.31,
"close": 49.09
},
{
"date": "2026-07-06",
"high": 49.96,
"low": 48.81,
"close": 49.38
}
],
"02359": [
@@ -119,6 +131,12 @@
"high": 502.0,
"low": 444.55,
"close": 480.32
},
{
"date": "2026-07-06",
"high": 499.0,
"low": 448.0,
"close": 476.72
}
],
"06160": [
@@ -155,6 +173,12 @@
"high": 687.04,
"low": 633.01,
"close": 643.81
},
{
"date": "2026-07-06",
"high": 649.88,
"low": 615.0,
"close": 649.01
}
],
"09868": [
@@ -197,6 +221,12 @@
"high": 757.88,
"low": 713.0,
"close": 738.38
},
{
"date": "2026-07-06",
"high": 745.0,
"low": 690.11,
"close": 743.0
}
],
"300124": [
@@ -211,6 +241,12 @@
"high": 74.63,
"low": 67.31,
"close": 72.15
},
{
"date": "2026-07-06",
"high": 71.94,
"low": 68.6,
"close": 69.55
}
],
"000657": [
@@ -225,6 +261,12 @@
"high": 101.5,
"low": 87.88,
"close": 89.63
},
{
"date": "2026-07-06",
"high": 90.58,
"low": 80.46,
"close": 81.83
}
],
"000711": [
@@ -239,6 +281,12 @@
"high": 5.26,
"low": 4.87,
"close": 5.26
},
{
"date": "2026-07-06",
"high": 5.65,
"low": 5.0,
"close": 5.29
}
],
"001309": [
@@ -253,6 +301,12 @@
"high": 892.1,
"low": 795.0,
"close": 881.91
},
{
"date": "2026-07-06",
"high": 918.98,
"low": 860.0,
"close": 916.6
}
],
"002594": [
@@ -267,6 +321,12 @@
"high": 88.88,
"low": 81.9,
"close": 88.47
},
{
"date": "2026-07-06",
"high": 88.95,
"low": 86.61,
"close": 87.68
}
],
"00700": [
@@ -335,6 +395,12 @@
"high": 646.85,
"low": 574.1,
"close": 618.02
},
{
"date": "2026-07-06",
"high": 710.0,
"low": 659.16,
"close": 695.26
}
]
}