Skip to content

Conversation

@maximilian-sh
Copy link

Fixes #246

Description

The Trade Republic API now requires the secAccNo (securities account number) parameter for the compactPortfolio subscription. This PR fixes the issue where portfolio mode was not returning any positions.

Changes

  1. Added secAccNo attribute to TradeRepublicApi class
  2. Enhanced settings() method to extract secAccNo from the settings response (checks for securitiesAccountNumber field)
  3. Updated compact_portfolio() method to include secAccNo in the subscription request
  4. Also added compact_portfolio_by_type() method for completeness (as mentioned in the issue)

Testing

  • Tested with web login session
  • Successfully retrieves portfolio positions after fix
  • Extracts securitiesAccountNumber from /api/v2/auth/account response

Related

Based on findings from @ganzinotti in issue #246. The fix ensures that secAccNo is automatically extracted from the account settings and included in the subscription request.

Fixes pytr-org#246

The Trade Republic API now requires the secAccNo (securities account number)
parameter for the compactPortfolio subscription. This fix:

1. Adds secAccNo attribute to TradeRepublicApi class
2. Extracts secAccNo from settings response (securitiesAccountNumber field)
3. Includes secAccNo in compactPortfolio subscription request
4. Also adds compact_portfolio_by_type method for completeness

Based on findings from @ganzinotti in issue pytr-org#246.
_subscription_id_counter = 1
_previous_responses: Dict[str, str] = {}
subscriptions: Dict[str, Dict[str, Any]] = {}
secAccNo = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would make this private

self.secAccNo = account["id"]
break
return settings_data

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are all these locations still relevant to try?

In my case the securities account number is stored in settings_data["securitiesAccountNumber"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Portfolio mode not working

2 participants