@@ -744,3 +744,142 @@ def get_creditcard_account(self, credit_card_account_id: str) -> Any:
744744 )
745745
746746 return account
747+
748+ def get_identity_current_financials (
749+ self ,
750+ currency : str ,
751+ account_ids : list [str ] | None = None ,
752+ start_date : str | None = None ,
753+ ) -> Any :
754+ """Retrieve current financials for an identity.
755+
756+ Args:
757+ currency: Currency to return amounts in (CAD or USD).
758+ account_ids: Optional list of account IDs to filter by.
759+ start_date: Optional start date in 'YYYY-MM-DD' format for computing
760+ simple returns over a specific period.
761+
762+ Returns:
763+ dict: Current financials including net liquidation value, net deposits,
764+ and simple returns.
765+
766+ Raises:
767+ WSApiException: If the response format is unexpected.
768+ """
769+ variables = {
770+ "identityId" : self .get_token_info ().get ("identity_canonical_id" ),
771+ "currency" : currency ,
772+ }
773+ if account_ids is not None :
774+ variables ["accountIds" ] = account_ids
775+ if start_date is not None :
776+ variables ["startDate" ] = start_date
777+
778+ return self .do_graphql_query (
779+ "FetchIdentityCurrentFinancials" ,
780+ variables ,
781+ "identity.financials.current" ,
782+ "object" ,
783+ )
784+
785+ def get_account_unrealized_pnl (self , account_id : str , currency : str ) -> Any :
786+ """Retrieve unrealized P&L for a specific account.
787+
788+ Args:
789+ account_id: The account ID to retrieve unrealized P&L for.
790+ currency: Currency to return amounts in (CAD or USD).
791+
792+ Returns:
793+ dict: Unrealized P&L including amount and rate.
794+
795+ Raises:
796+ WSApiException: If the response format is unexpected.
797+ """
798+ return self .do_graphql_query (
799+ "FetchAccountUnrealizedPnL" ,
800+ {
801+ "id" : account_id ,
802+ "currency" : currency ,
803+ },
804+ "account.financials.currentCombined.unrealizedPnL" ,
805+ "object" ,
806+ )
807+
808+ def get_identity_realized_returns (
809+ self ,
810+ currency : str ,
811+ account_ids : list [str ] | None = None ,
812+ start_date : str | None = None ,
813+ first : int | None = None ,
814+ ) -> Any :
815+ """Retrieve realized capital gains returns for an identity.
816+
817+ Args:
818+ currency: Currency to return amounts in (CAD or USD).
819+ account_ids: Optional list of account IDs to filter by.
820+ start_date: Optional start date in 'YYYY-MM-DD' format.
821+ first: Optional limit on the number of securities in the breakdown.
822+
823+ Returns:
824+ dict: Realized returns including total value and per-security breakdown.
825+
826+ Raises:
827+ WSApiException: If the response format is unexpected.
828+ """
829+ variables = {
830+ "identityId" : self .get_token_info ().get ("identity_canonical_id" ),
831+ "currency" : currency ,
832+ }
833+ if account_ids is not None :
834+ variables ["accountIds" ] = account_ids
835+ if start_date is not None :
836+ variables ["startDate" ] = start_date
837+ if first is not None :
838+ variables ["first" ] = first
839+
840+ return self .do_graphql_query (
841+ "FetchIdentityRealizedReturns" ,
842+ variables ,
843+ "identity.financials.realizedReturns" ,
844+ "object" ,
845+ )
846+
847+ def get_dividends (
848+ self ,
849+ currency : str ,
850+ account_ids : list [str ] | None = None ,
851+ start_date : str | None = None ,
852+ include_issuing_security_breakdown : bool = False ,
853+ ) -> Any :
854+ """Retrieve dividend income for an identity.
855+
856+ Args:
857+ currency: Currency to return amounts in (CAD or USD).
858+ account_ids: Optional list of account IDs to filter by.
859+ start_date: Optional start date in 'YYYY-MM-DD' format.
860+ include_issuing_security_breakdown: Whether to include a per-security
861+ breakdown of dividends.
862+
863+ Returns:
864+ dict: Dividend income including total value and optional per-security
865+ breakdown.
866+
867+ Raises:
868+ WSApiException: If the response format is unexpected.
869+ """
870+ variables = {
871+ "identityId" : self .get_token_info ().get ("identity_canonical_id" ),
872+ "currency" : currency ,
873+ "includeIssuingSecurityBreakdown" : include_issuing_security_breakdown ,
874+ }
875+ if account_ids is not None :
876+ variables ["accountIds" ] = account_ids
877+ if start_date is not None :
878+ variables ["startDate" ] = start_date
879+
880+ return self .do_graphql_query (
881+ "FetchDividendsV2" ,
882+ variables ,
883+ "identity.financials.dividendsV2" ,
884+ "object" ,
885+ )
0 commit comments