@@ -404,6 +404,10 @@ def __init__(self, sess: WSAPISession | None = None) -> None:
404404 super ().__init__ (sess )
405405 self .account_cache = {}
406406
407+ @staticmethod
408+ def _iso_z (dt : datetime | None ) -> str | None :
409+ return dt .strftime ("%Y-%m-%dT%H:%M:%S.%fZ" ) if dt else None
410+
407411 def get_accounts (self , open_only = True , use_cache = True ):
408412 cache_key = "open" if open_only else "all"
409413 if not use_cache or cache_key not in self .account_cache :
@@ -462,12 +466,8 @@ def get_account_historical_financials(
462466 {
463467 "id" : account_id ,
464468 "currency" : currency ,
465- "startDate" : start_date .strftime ("%Y-%m-%dT%H:%M:%S.%fZ" )
466- if start_date
467- else None ,
468- "endDate" : end_date .strftime ("%Y-%m-%dT%H:%M:%S.%fZ" )
469- if end_date
470- else None ,
469+ "startDate" : self ._iso_z (start_date ),
470+ "endDate" : self ._iso_z (end_date ),
471471 "resolution" : resolution ,
472472 "first" : first ,
473473 "cursor" : cursor ,
@@ -490,12 +490,8 @@ def get_identity_historical_financials(
490490 {
491491 "identityId" : self .get_token_info ().get ("identity_canonical_id" ),
492492 "currency" : currency ,
493- "startDate" : start_date .strftime ("%Y-%m-%dT%H:%M:%S.%fZ" )
494- if start_date
495- else None ,
496- "endDate" : end_date .strftime ("%Y-%m-%dT%H:%M:%S.%fZ" )
497- if end_date
498- else None ,
493+ "startDate" : self ._iso_z (start_date ),
494+ "endDate" : self ._iso_z (end_date ),
499495 "first" : first ,
500496 "cursor" : cursor ,
501497 "accountIds" : account_ids or [],
@@ -557,10 +553,8 @@ def filter_fn(activity):
557553 "orderBy" : order_by ,
558554 "first" : how_many ,
559555 "condition" : {
560- "startDate" : start_date .strftime ("%Y-%m-%dT%H:%M:%S.%fZ" )
561- if start_date
562- else None ,
563- "endDate" : end_date .strftime ("%Y-%m-%dT%H:%M:%S.%fZ" ),
556+ "startDate" : self ._iso_z (start_date ),
557+ "endDate" : self ._iso_z (end_date ),
564558 "accountIds" : account_id ,
565559 },
566560 },
0 commit comments