Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion application/account_facts_readonly.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,13 @@ def collect_firstrade_account_facts(
missing_market_value += int(value_missing)
missing_currency += int(currency_missing)

provider_equity = _exact_balance_value(balances, ("total_equity",))
# Firstrade balance payloads commonly use total_value; the client also
# mirrors account-list totals as account_list_total_value. Keep exact
# keys only (never fuzzy cash substrings).
provider_equity = _exact_balance_value(
balances,
("total_equity", "total_value", "account_list_total_value"),
)
cash_balance = _exact_balance_value(balances, ("cash_balance",))
available_cash = _exact_balance_value(balances, ("available_cash",))
buying_power = _exact_balance_value(balances, ("buying_power",))
Expand Down
17 changes: 17 additions & 0 deletions tests/test_account_facts_readonly.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,3 +403,20 @@ def test_requires_timezone_aware_monotonic_observation_times():
)

assert error.value.reason_code == "observation_time_invalid"


@pytest.mark.parametrize(
"field",
["total_value", "account_list_total_value", "total_equity"],
)
def test_accepts_firstrade_total_value_as_provider_equity(field):
client = CachedReadOnlyClient()
client.balances = {field: "$1,234.50", "currency": "USD"}

result = collect_firstrade_account_facts(
client,
expected_account="synthetic-account-a",
clock=lambda: datetime(2026, 10, 8, 12, tzinfo=timezone.utc),
)

assert result["balances"]["provider_equity"] == "1234.5"
Loading