Skip to content
Merged
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
26 changes: 10 additions & 16 deletions ws_api/wealthsimple_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,10 @@ def __init__(self, sess: WSAPISession | None = None) -> None:
super().__init__(sess)
self.account_cache = {}

@staticmethod
def _iso_z(dt: datetime | None) -> str | None:
return dt.strftime("%Y-%m-%dT%H:%M:%S.%fZ") if dt else None

def get_accounts(self, open_only=True, use_cache=True):
cache_key = "open" if open_only else "all"
if not use_cache or cache_key not in self.account_cache:
Expand Down Expand Up @@ -462,12 +466,8 @@ def get_account_historical_financials(
{
"id": account_id,
"currency": currency,
"startDate": start_date.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
if start_date
else None,
"endDate": end_date.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
if end_date
else None,
"startDate": self._iso_z(start_date),
"endDate": self._iso_z(end_date),
"resolution": resolution,
"first": first,
"cursor": cursor,
Expand All @@ -490,12 +490,8 @@ def get_identity_historical_financials(
{
"identityId": self.get_token_info().get("identity_canonical_id"),
"currency": currency,
"startDate": start_date.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
if start_date
else None,
"endDate": end_date.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
if end_date
else None,
"startDate": self._iso_z(start_date),
"endDate": self._iso_z(end_date),
"first": first,
"cursor": cursor,
"accountIds": account_ids or [],
Expand Down Expand Up @@ -557,10 +553,8 @@ def filter_fn(activity):
"orderBy": order_by,
"first": how_many,
"condition": {
"startDate": start_date.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
if start_date
else None,
"endDate": end_date.strftime("%Y-%m-%dT%H:%M:%S.%fZ"),
"startDate": self._iso_z(start_date),
"endDate": self._iso_z(end_date),
"accountIds": account_id,
},
},
Expand Down