Sync your Ghostfolio with IBKR ( more to come? Help is always welcome! )
Important: When you configure your Flex Query give it: Cash report and Cash transactions and Trades and nothing else
Follow this guide to configure your Flex Queries in your Interactive Brokers account: https://help.wealthica.com/help/how-to-connect-ib-interactive-brokers-and-configure-the-flex-report
Important: If you dont want ghostfolio-sync to sync everything everytime and make it quicker, just set a shorter window for the query. Keep in mind that what was not synced by ghostfolio-sync in that period of time will be lost (ie when the window moves and content was not uploaded to ghostfolio). This can be avoided at the cost of a longer window of time and longer sync
- Take note of your user KEY (generated upon user creation and used to login to Ghostfolio)
- Run the following on the terminal (replace
ghostfol.io
withlocalhost
or your host url if you are self-hosting):
curl -X POST -H "Content-Type: application/json" \
-d '{ "accessToken": "YOUR-USER-KEY-GOES-HERE }' \
https://ghostfol.io/api/v1/auth/anonymous
- Take note of the token
{"authToken":"12cd45...
. That is your GHOST_TOKEN
docker run -e GHOST_TOKEN=YOUR_GHOST_TOKEN -e IBKR_TOKEN=YOUR-IBKR-TOKEN -e IBKR_QUERY=YOUR-IBKR-QUERY agusalex/ghostfolio-sync
In Podman
podman run -e GHOST_TOKEN=YOUR_GHOST_TOKEN -e IBKR_TOKEN=$IBKR_TOKEN -e IBKR_QUERY=$IBKR_QUERY -e GHOST_HOST=http://$GHOST_URL -e GHOST_CURRENCY=EUR -e GHOST_IBKR_PLATFORM=$IBKR_PLATFORM -v ./mapping.yaml:/usr/app/src/mapping.yaml:Z agusalex/ghostfolio-sync
You can specify the symbol mappings in mapping.yaml
and you do not need to rebuild the container with the above mount command.
Envs | Description |
---|---|
IBKR_TOKEN | Your Token |
IBKR_QUERY | Your Query ID |
GHOST_TOKEN | The token for your ghostfolio account |
GHOST_KEY | The key for your ghostfolio account, if this is used you don't need GHOST_TOKEN and vice-versa |
GHOST_HOST | (optional) Ghostfolio Host, only add if using custom ghostfolio |
GHOST_CURRENCY | (optional) Ghostfolio Account Currency, only applied if the account doesn't exist |
GHOST_IBKR_PLATFORM | (optional) For self-hosted, specify the Platform ID |
CRON | (optional) To run on a Cron Schedule |
OPERATION | (optional) SYNCIBKR (default) or DELETEALL (will erase all operations of all accounts) |
If you are using ghostfolio self-hosted option, you need to go into Ghostfolio and add a platform for IBKR.
Then make a request to /account
to find the relevant platform ID and store it in the IBKR_PLATFORM env variable
curl "http://10.0.0.2:3333/api/v1/account" \
-H "Authorization: Bearer $GHOST_TOKEN"
export IBKR_PLATFORM=<PUT PLATFORM ID HERE>
- Feel free to submit any issue or PR's you think necessary
- If you like the work and want to buy me a coffee you are more than welcome :)