@@ -34,6 +34,7 @@ class WealthsimpleAPIBase:
3434 'FetchAccountHistoricalFinancials' : "query FetchAccountHistoricalFinancials($id: ID!, $currency: Currency!, $startDate: Date, $resolution: DateResolution!, $endDate: Date, $first: Int, $cursor: String) {\n account(id: $id) {\n id\n financials {\n historicalDaily(\n currency: $currency\n startDate: $startDate\n resolution: $resolution\n endDate: $endDate\n first: $first\n after: $cursor\n ) {\n edges {\n node {\n ...AccountHistoricalFinancials\n __typename\n }\n __typename\n }\n pageInfo {\n hasNextPage\n endCursor\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n }\n \n fragment AccountHistoricalFinancials on AccountHistoricalDailyFinancials {\n date\n netLiquidationValueV2 {\n ...Money\n __typename\n }\n netDepositsV2 {\n ...Money\n __typename\n }\n __typename\n }\n \n fragment Money on Money {\n amount\n cents\n currency\n __typename\n }" ,
3535 'FetchIdentityHistoricalFinancials' : "query FetchIdentityHistoricalFinancials($identityId: ID!, $currency: Currency!, $startDate: Date, $endDate: Date, $first: Int, $cursor: String, $accountIds: [ID!]) {\n identity(id: $identityId) {\n id\n financials(filter: {accounts: $accountIds}) {\n historicalDaily(\n currency: $currency\n startDate: $startDate\n endDate: $endDate\n first: $first\n after: $cursor\n ) {\n edges {\n node {\n ...IdentityHistoricalFinancials\n __typename\n }\n __typename\n }\n pageInfo {\n hasNextPage\n endCursor\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n }\n \n fragment IdentityHistoricalFinancials on IdentityHistoricalDailyFinancials {\n date\n netLiquidationValueV2 {\n amount\n currency\n __typename\n }\n netDepositsV2 {\n amount\n currency\n __typename\n }\n __typename\n }" ,
3636 'FetchCorporateActionChildActivities' : "query FetchCorporateActionChildActivities($activityCanonicalId: String!) {\n corporateActionChildActivities(\n condition: {activityCanonicalId: $activityCanonicalId}\n ) {\n nodes {\n ...CorporateActionChildActivity\n __typename\n }\n __typename\n }\n }\n \n fragment CorporateActionChildActivity on CorporateActionChildActivity {\n canonicalId\n activityCanonicalId\n assetName\n assetSymbol\n assetType\n entitlementType\n quantity\n currency\n price\n recordDate\n __typename\n }" ,
37+ 'FetchBrokerageMonthlyStatementTransactions' : "query FetchBrokerageMonthlyStatementTransactions($period: String!, $accountId: String!) {\n brokerageMonthlyStatements(period: $period, accountId: $accountId) {\n id\n statementType\n createdAt\n data {\n ... on BrokerageMonthlyStatementObject {\n ...BrokerageMonthlyStatementObject\n __typename\n }\n __typename\n }\n __typename\n }\n }\n \n fragment BrokerageMonthlyStatementObject on BrokerageMonthlyStatementObject {\n custodianAccountId\n activitiesPerCurrency {\n currency\n currentTransactions {\n ...BrokerageMonthlyStatementTransactions\n __typename\n }\n __typename\n }\n currentTransactions {\n ...BrokerageMonthlyStatementTransactions\n __typename\n }\n isMultiCurrency\n __typename\n }\n \n fragment BrokerageMonthlyStatementTransactions on BrokerageMonthlyStatementTransactions {\n balance\n cashMovement\n unit\n description\n transactionDate\n transactionType\n __typename\n }" ,
3738 }
3839
3940 def __init__ (self , sess : Optional [WSAPISession ] = None ):
@@ -761,3 +762,38 @@ def get_corporate_action_child_activities(self, activity_canonical_id):
761762 'corporateActionChildActivities.nodes' ,
762763 'array' ,
763764 )
765+
766+ def get_statement_transactions (self , account_id : str , period : str ) -> list [Any ]:
767+ """Retrieve transactions from account monthly statement.
768+
769+ Args:
770+ account_id (str): The account ID to retrieve transactions for.
771+ period (str): The statement start date in 'YYYY-MM-DD' format.
772+ For example, '2025-10-01' for October 2025 statement.
773+
774+ Returns:
775+ list[Any]: A list of transactions.
776+
777+ Raises:
778+ WSApiException: If the response format is unexpected.
779+ """
780+ statements = self .do_graphql_query (
781+ 'FetchBrokerageMonthlyStatementTransactions' ,
782+ {
783+ 'accountId' : account_id ,
784+ 'period' : period ,
785+ },
786+ 'brokerageMonthlyStatements' ,
787+ 'array' ,
788+ )
789+
790+ if isinstance (statements , list ) and len (statements ) > 0 :
791+ statement = statements [0 ]
792+ data = statement .get ('data' ) if 'data' in statement else {}
793+ transactions = data .get ('currentTransactions' ) if 'currentTransactions' in data else []
794+
795+
796+ if not isinstance (transactions , list ):
797+ raise WSApiException (f"Unexpected response format: { self .get_statement_transactions .__name__ } " , transactions )
798+
799+ return transactions
0 commit comments