This repository automates the extraction of transaction data from PDF broker statements and imports them directly into Ghostfolio. Currently, a parser for Sunrise is implemented, and additional parsers (e.g., for Flatex.at) will be added in the future.
Clone the repository and set up a virtual environment:
git clone https://github.com/fucnim17/pdf-broker-2-ghostfolio.git
cd pdf-broker-2-ghostfolio
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
To import transactions, you need a Bearer Token from Ghostfolio. To get one, paste the following text into your console, replacing <INSERT_SECURITY_TOKEN_OF_ACCOUNT>
with the security token from your Ghostfolio account:
curl -X POST http://localhost:3333/api/v1/auth/anonymous \
-H "Content-Type: application/json" \
-d '{ "accessToken": "<INSERT_SECURITY_TOKEN_OF_ACCOUNT>" }'
You will get your access token as a response like this:
"authToken"": "eyJh..."
Store this token somewhere, you will need it later on. For additional information visit Ghostfolio and scroll down.
Before running the script, create a .env
file in the project root directory:
nano .env
Then, add the following content (adjust the values to your setup):
# 📂 Directory where PDFs are stored
PDF_DIRECTORY=/path/to/your/pdf_folder/
PDF_FILENAME=pdf_name.pdf
# 🌐 Ghostfolio API Settings
GHOSTFOLIO_HOST=http://localhost:3333
API_TOKEN=eyJh...
ACCOUNT_ID=your_ghostfolio_account_id
To manually run the script:
python parser/sunrise_parser.py
After successful import, the processed PDF will be deleted automatically.
To exit the virtual environment, run:
deactivate
- Support for multiple brokers: More parsers will be added for different statement formats.
- Automated file monitoring: The script will run continuously, waiting for new PDFs to process.
- Capital gains tax: Add the option to import capital gains tax as a fee.
- Improved error handling: Enhancements for handling edge cases and failed imports.
This script is licensed under the GNU General Public License Version 3. See the LICENSE
file for details.