Skip to content
Open
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
19 changes: 11 additions & 8 deletions schwab_api/schwab.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,9 @@ def orders_v2(self, account_id=None):
def get_account_info_v2(self):
account_info = dict()
self.update_token(token_type='api')
# somewhere around 2025-08-25, this change became necessary
if 'schwab-client-account' in self.headers:
self.headers['Schwab-Client-Ids'] = self.headers['schwab-client-account']
r = requests.get(urls.positions_v2(), headers=self.headers)
response = json.loads(r.text)
for account in response['accounts']:
Expand All @@ -694,18 +697,18 @@ def get_account_info_v2(self):
for security_group in account["groupedPositions"]:
if security_group["groupName"] == "Cash":
continue
for position in security_group["positions"]:
if "symbol" not in position["symbolDetail"]:
for position in security_group["holdingsRows"]:
if "symbol" not in position:
valid_parse = False
break
positions.append(
Position(
position["symbolDetail"]["symbol"],
position["symbolDetail"]["description"],
float(position["quantity"]),
0 if "costDetail" not in position else float(position["costDetail"]["costBasisDetail"]["costBasis"]),
0 if "priceDetail" not in position else float(position["priceDetail"]["marketValue"]),
position["symbolDetail"]["schwabSecurityId"]
position["symbol"]["symbol"],
position["description"],
float(position["qty"]["qty"]),
0 if "costBasis" not in position else float(position["costBasis"]["cstBasis"]),
0 if "marketValue" not in position else float(position["marketValue"]["val"]),
position["symbol"]["ssId"]
)._as_dict()
)
if not valid_parse:
Expand Down
2 changes: 1 addition & 1 deletion schwab_api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def account_info_v2():
return "https://ausgateway.schwab.com/api/is.TradeOrderManagementWeb/v1/TradeOrderManagementWebPort/customer/accounts"

def positions_v2():
return "https://ausgateway.schwab.com/api/is.Holdings/V1/Holdings/Holdings?=&includeCostBasis=true&includeRatings=true&includeUnderlyingOption=true"
return "https://ausgateway.schwab.com/api/is.Holdings/V1/Holdings/HoldingV2"

def ticker_quotes_v2():
return "https://ausgateway.schwab.com/api/is.TradeOrderManagementWeb/v1/TradeOrderManagementWebPort/market/quotes/list"
Expand Down