Repository navigation
PortfolioDB 1.7.4
The fourth pass over the audit: the two findings the re-audit of 1.7.3 added.
The weekly report's contributor arithmetic credited a sale's move twice and
counted a baseline-day trade as new, which round 3's flat-price fixtures could
not see; and 35 SQL integration tests had never run in CI because the only job
with a database ran the slow suite alone. The weekly report also stops taking
futures-only market-overview snapshots as its week boundaries. No schema
change and no migration.
Upgrading
- Nothing to do. If you run the weekly report yourself, expect the
contributor amounts to change where the week held sales or trades dated on
the start snapshot's day; the week's totals were already right. - The 1.7.3 Upgrading step (rerun
--replace-estimateswithout--since
once if it was used with--sinceon 1.7.2) still applies if not done.
Changed
- The 35 SQL integration tests now run in CI.
test_dedupe_guards.py,
test_fd_store.pyandtest_data_quality_sql.pytalk SQL to a real
database and skip when none is configured; the only CI job with a database
ran the MCPslowsuite alone, so those cases had never executed there. The
job now runs them too, withPORTFOLIODB_TESTS_REQUIRE_DB=1making a skip
for lack of a database a failure (one shareddb.connect_for_tests). The FD
store tests read committed synthetic fixtures underapp/tests/fixtures/fd/
instead of the gitignored enrichment cache, so a clean clone exercises every
round trip (1.7.3 re-audit, N06). The four unused test imports pyflakes kept
listing are gone.
Fixed
- Weekly contributor P&L no longer double-counts sales or baseline-day
trades. The contribution gave every opening share its full start-to-end
move and then addedquantity × (sale − start)for the shares sold during
the week, so a sale earned the same move twice: selling 5 of 10 at $110
with quotes $100 → $120 printed $250 for a $150 gain, and a full
liquidation or a round trip were off by the same amount. A trade dated on
the start snapshot's day was also counted as both part of the opening
position and a new trade. The sale term now compares against the closing
quote, contributions count only trades dated after the baseline day (the
trades listing still shows the calendar week and says so), and with cash
mirroring the trades the symbol contributions sum to the change in
securities plus cash. The report's week boundaries are now taken from
snapshots that quote a held symbol, so a futures-only market-overview run
can no longer become the start or end of the week and value every holding
as missing (1.7.3 re-audit, N05; boundary defect found in round 3).