English | Русский | Українська | Srpski | Српски
Usage
Configuration (config)
ibkr-porez config
Creating or modifying personal data and IBKR access settings.
You will be prompted for:
- IBKR Flex Token: Get Token ↗
- IBKR Query ID: Create Flex Query ↗
- Personal ID: JMBG / EBS
- Full Name: First and Last Name
- Address: Registered Address
- City Code: 3-digit municipality code. Example:
223(Novi Sad). Code can be found in the list (see column “Šifra”). Also available in the dropdown on the ePorezi portal. - Phone: Phone
- Email: Email
- Data Directory: Absolute path to folder with data files (
transactions.json,declarations.json,rates.json, etc.). Default:ibkr-porez-datain the application folder. - Output Folder: Absolute path to folder for saving files from
sync,export,export-flex,reportcommands. Default: your system’s Downloads folder.
Fetch Data (fetch)
ibkr-porez fetch
Downloads latest data from IBKR and syncs exchange rates from NBS (National Bank of Serbia).
Saves them to local storage.
Import Historical Data (import)
ibkr-porez import /path/to/activity_statement.csv
Loading transaction history older than 365 days, which cannot be retrieved via Flex Query (fetch).
To create a file with transactions on the Interactive Brokers portal, see Export Full History ↗
⚠️ Do not forget to run
fetchafterimportso the application adds maximum details at least for the last year into the less detailed data loaded from CSV.
Synchronization Logic (import + fetch)
When loading data from CSV (import) and Flex Query (fetch), the system prioritizes more complete Flex Query data:
- Flex Query (
fetch) data is the source of truth. It overwrites CSV data for any matching dates. - If a Flex Query record matches a CSV record semantically (Date, Ticker, Price, Quantity), it counts as an update (replacing with official ID).
- If data structure differs (e.g. split orders in Flex Query vs “bundled” record in CSV), the old CSV record is removed, and new Flex Query records are added.
- Completely identical records are skipped.
Sync Data and Create Declarations (sync)
ibkr-porez sync
Does the same as fetch:
- Downloads latest transactions from IBKR via Flex Query
- Syncs exchange rates from NBS
Then creates all necessary declarations for the last 45 days (if they haven’t been created already).
You can then Manage created declarations.
💡 If you ran
syncfor the first time and it created declarations that you already submitted before starting to use the application, you can quickly mark them all as paid and remove them from list output:ibkr-porez list --status submitted -1 | ibkr-porez pay
View Statistics (stat)
ibkr-porez stat --year 2025
ibkr-porez stat --ticker AAPL
ibkr-porez stat --month 2025-01
Shows:
- Dividends received (in RSD)
- Number of sales (taxable events)
- Estimated Realized P/L (Capital Gains) (in RSD)
- Detailed breakdown by tickers or months (when using filters)
Generate Tax Report (report)
ibkr-porez report
If you don’t specify report type and period, PPDG-3R for the last complete half-year is generated by default
- Creates
ppdg3r_XXXX_HY.xmlin Output Folder - Import this file into the Serbian Tax Administration portal (ePorezi)
- Manually upload the file from Confirmation Document to Item 8
To select a different declaration type or time period, see the documentation
ibkr-porez report --help
Declaration Management
After creating declarations through the sync command, you can view them, change their status, and export them for upload to the tax portal.
List Declarations (list)
Shows a list of all declarations with the ability to filter by status.
# Show active declarations (default):
# draft + submitted + pending
ibkr-porez list
# Show all declarations
ibkr-porez list --all
# Filter by status
ibkr-porez list --status draft
ibkr-porez list --status submitted
ibkr-porez list --status pending
ibkr-porez list --status finalized
# Only declaration IDs (for use in pipes)
ibkr-porez list --ids-only
ibkr-porez list --status draft -1
Example usage in Linux-style:
# Submit all drafts
ibkr-porez list --status draft -1 | ibkr-porez submit
View Declaration Details (show)
Shows detailed information about a specific declaration.
ibkr-porez show <declaration_id>
Displays:
- Declaration type (PPDG-3R or PP OPO)
- Declaration period
- Status (draft, submitted, pending, finalized)
- Transaction details and calculations
- Attached files
Submit Declaration (submit)
ibkr-porez submit <id> [<id> ...]
Marks the declaration as submitted (imported to the tax portal).
Behavior depends on declaration type:
PPDG-3Rmoves topendingaftersubmit(waiting for tax authority assessment).PP OPOaftersubmit:- moves to
submittedif tax is due; - moves directly to
finalizedif tax due is0.
- moves to
Pay Declaration (pay)
ibkr-porez pay <id> [<id> ...]
ibkr-porez pay <id> --tax 1234.56
Marks the declaration as finalized and stores payment date.
Option --tax lets you record tax amount during payment, without a separate assess step.
After this, it will disappear from the list shown by list (without --all)
Record Assessed Tax (assess)
# Record official tax amount from the tax authority
ibkr-porez assess <declaration_id> --tax-due 1234.56
# Record amount and immediately mark as already paid
ibkr-porez assess <declaration_id> --tax-due 1234.56 --paid
This command is mainly for PPDG-3R, where tax amount is determined by the tax authority after submission.
What it does:
- stores official tax amount in declaration metadata;
- with
--paid, immediately moves declaration tofinalized; - without
--paid:- if amount is greater than zero, keeps declaration active (
submitted) for later payment; - if amount is zero, moves declaration to
finalized.
- if amount is greater than zero, keeps declaration active (
Export Declaration (export)
ibkr-porez export <declaration_id>
ibkr-porez export <declaration_id> -o /path/to/output
Copies XML and all attached files (attach) to Output Folder or to the directory specified in parameters.
Revert Declaration Status (revert)
# Revert to draft (default)
ibkr-porez revert <id> [<id> ...]
# Revert to submitted
ibkr-porez revert <id> [<id> ...] --to submitted
Reverts declaration status.
Attach File to Declaration (attach)
# Attach file
ibkr-porez attach <declaration_id> /path/to/file.pdf
# Delete attached file
ibkr-porez attach <declaration_id> <file_id> --delete
ibkr-porez attach <declaration_id> --delete --file-id <file_id>
Attaches a file to a declaration or removes an attached file from declaration storage.
For saving to declaration storage, only the file name is used (path is discarded), so names must be unique - otherwise a file with the same name will overwrite a previously uploaded file with the same name even if from a different path
💡 Attached files are copied along with the declaration XML during export
Export Flex Query (export-flex)
ibkr-porez export-flex 2025-01-15
ibkr-porez export-flex 2025-01-15 -o /path/to/output.xml
ibkr-porez export-flex 2025-01-15 -o - # Output to stdout (for pipes)
Exports Flex Query XML file obtained during fetch or sync on the specified date.
Example usage in Linux-style:
ibkr-porez export-flex 2025-01-15 | ibkr-porez import