@@ -43,6 +43,10 @@ def test_ecps_has_liquid_assets():
4343 - Total US household liquid assets: tens of trillions
4444 """
4545 from policyengine_us_data .datasets .cps import EnhancedCPS_2024
46+ from policyengine_us_data .datasets .scf .fed_scf import SummarizedFedSCF_2022
47+ from policyengine_us_data .utils .asset_imputation import (
48+ add_scf_financial_asset_targets ,
49+ )
4650 from policyengine_us import Microsimulation
4751
4852 sim = Microsimulation (dataset = EnhancedCPS_2024 )
@@ -53,19 +57,29 @@ def test_ecps_has_liquid_assets():
5357 bonds = sim .calculate ("bond_assets" , map_to = "household" )
5458 total_liquid = bank + stocks + bonds
5559
56- # Total should be in the tens of trillions. This is a broad corruption
57- # check; distributional tests below carry the tighter SCF-shape signal.
60+ scf = SummarizedFedSCF_2022 (require = True ).load ()
61+ scf_asset_targets = add_scf_financial_asset_targets (scf )
62+ scf_total = sum (
63+ (scf [target ].fillna (0 ) * scf ["wgt" ]).sum () for target in scf_asset_targets
64+ )
65+
66+ # Total should be in the same broad order of magnitude as the SCF source
67+ # columns used for the overlapping liquid-asset leaves. This remains a
68+ # corruption check; distributional tests below carry the tighter shape
69+ # signal.
5870 total = total_liquid .sum ()
59- MINIMUM_TOTAL = 5e12 # $5 trillion floor
60- MAXIMUM_TOTAL = 40e12 # $40 trillion ceiling
71+ MINIMUM_TOTAL = scf_total * 0.15
72+ MAXIMUM_TOTAL = scf_total * 2.0
6173
6274 assert total > MINIMUM_TOTAL , (
6375 f"Total liquid assets ${ total / 1e12 :.1f} T below "
64- f"minimum ${ MINIMUM_TOTAL / 1e12 :.0f} T"
76+ f"minimum ${ MINIMUM_TOTAL / 1e12 :.1f} T "
77+ f"based on SCF source total ${ scf_total / 1e12 :.1f} T"
6578 )
6679 assert total < MAXIMUM_TOTAL , (
6780 f"Total liquid assets ${ total / 1e12 :.1f} T above "
68- f"maximum ${ MAXIMUM_TOTAL / 1e12 :.0f} T"
81+ f"maximum ${ MAXIMUM_TOTAL / 1e12 :.1f} T "
82+ f"based on SCF source total ${ scf_total / 1e12 :.1f} T"
6983 )
7084
7185
0 commit comments