pytr icon indicating copy to clipboard operation
pytr copied to clipboard

Fix portfolio mode by adding secAccNo parameter to compactPortfolio

Open maximilian-sh opened this issue 1 month ago • 0 comments

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.

maximilian-sh avatar Nov 06 '25 12:11 maximilian-sh