06/03 Optimize codes, fix Schwab Account sync errors
This commit is contained in:
@@ -163,6 +163,17 @@ def _raise_for_status(resp, context=''):
|
||||
|
||||
# ── Public API helpers ────────────────────────────────────────────────────────
|
||||
|
||||
def get_account_number_hashes(connection):
|
||||
"""
|
||||
Return {accountNumber: hashValue} mapping.
|
||||
Schwab requires the hashValue (encrypted account number) in all endpoint paths.
|
||||
"""
|
||||
data = _authed_get(connection, '/trader/v1/accounts/accountNumbers')
|
||||
mapping = {item['accountNumber']: item['hashValue'] for item in data}
|
||||
log.info('[schwab] get_account_number_hashes: %d account(s)', len(mapping))
|
||||
return mapping
|
||||
|
||||
|
||||
def get_accounts(connection):
|
||||
"""Return list of Schwab account dicts."""
|
||||
data = _authed_get(connection, '/trader/v1/accounts', params={'fields': 'positions'})
|
||||
|
||||
Reference in New Issue
Block a user