Fix portfolio mode by adding secAccNo parameter to compactPortfolio#256
Open
maximilian-sh wants to merge 2 commits intopytr-org:masterfrom
Open
Fix portfolio mode by adding secAccNo parameter to compactPortfolio#256maximilian-sh wants to merge 2 commits intopytr-org:masterfrom
maximilian-sh wants to merge 2 commits intopytr-org:masterfrom
Conversation
ExploracuriousAlex
approved these changes
Nov 13, 2025
pytr/api.py
Outdated
| _subscription_id_counter = 1 | ||
| _previous_responses: Dict[str, str] = {} | ||
| subscriptions: Dict[str, Dict[str, Any]] = {} | ||
| secAccNo = None |
Contributor
There was a problem hiding this comment.
I would make this private
Author
There was a problem hiding this comment.
Done, renamed to _secAccNo.
| self.secAccNo = account["id"] | ||
| break | ||
| return settings_data | ||
|
|
Contributor
There was a problem hiding this comment.
Are all these locations still relevant to try?
In my case the securities account number is stored in settings_data["securitiesAccountNumber"]
Author
There was a problem hiding this comment.
Good point — simplified to only use settings_data["securitiesAccountNumber"]. The other fallbacks were speculative. Same field works for me as well.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
cbfe507 to
d43535b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #246
Description
The Trade Republic API now requires the
secAccNo(securities account number) parameter for thecompactPortfoliosubscription. This PR fixes the issue where portfolio mode was not returning any positions.Changes
_secAccNoattribute toTradeRepublicApiclasssettings()method to extractsecAccNofromsettings_data["securitiesAccountNumber"]compact_portfolio()method to includesecAccNoin the subscription requestcompact_portfolio_by_type()method for completeness (as mentioned in the issue)Testing
securitiesAccountNumberfield is present in the/api/v2/auth/accountresponseRelated
Based on findings from @ganzinotti in issue #246.