Skip to content

OliRafa/tastytrade-ghostfolio

Repository files navigation

Python Poetry Buy Me A Coffee


Tastytrade-Ghostfolio

Transfer Tastytrade transactions to Ghostfolio.

Getting StartedCreditsReport BugRequest FeatureRoadmap

Table of Contents
  1. Getting Started
  2. Roadmap
  3. Contributing
  4. License
  5. Contact
  6. Acknowledgments

Getting Started

Tastytrade-Ghostfolio plugin works best when doing account management all by itself. In other words, manually creating activities in your Ghostfolio account is not only not needed, but it's also discouraged. That's because some operations (like symbol change, or stock splits) need to understand the complete picture of the account, and change its state totally.

It'll start by getting (or creatting) a Tastytrade account from Ghostfolio, and from that it'll start adding trading transactions and/or dividends.

This plugin runs completely in the background, and is provided as container images hosted on Docker Hub for linux/amd64.

Environment Variables

Start by setting up the appropriate environment variables, listed below:

Name Type Default Value Description
GHOSTFOLIO_ACCOUNT_TOKEN string The Ghostfolio Account Token.
GHOSTFOLIO_BASE_URL string (optional) "https://ghostfol.io" The Ghostfolio URL. If you're self hosting you should change it for your particular instance URL, otherwise all data will be exported to Ghostfolio cloud offering.
TASTYTRADE_USERNAME string The Tastytrade username.
TASTYTRADE_PASSWORD string The Tastytrade password.

Docker

For evaluation, you can run it by:

$ docker run --rm --name tastytrade-ghostfolio -e GHOSTFOLIO_ACCOUNT_TOKEN=<account_token> -e TASTYTRADE_USERNAME=myuser -e TASTYTRADE_PASSWORD=super_secure olirafa/tastytrade-ghostfolio

It'll spawn the container, ingest all data from Tastytrade, export it all to Ghostfolio, and then remove the container at the end.

To unleash the plugin's potential, you would want to deploy it scheduled to run from time to time (weekly, for example). For that, two approaches are presented, deploying using Docker Compose or in your Kubernetes cluster.

Docker Compose

The plugin was developed without a scheduler (like Cron) by design, so another tool is needed for that. We suggest using Ofelia, and that's what we have in the provided Docker Compose file.

First, clone the repo:

$ git clone https://github.com/OliRafa/tastytrade-ghostfolio.git

Enter the repo folder:

$ cd tastytrade-ghostfolio

Then, you'll need a .env file with the environment variables set. A example file can be found here.

With everything ready, run the following command:

$ docker compose up -d

It will deploy it in your Docker Compose infrastructure, running weekly by default.

Kubernetes

Start by deploying environment variables as ConfigMaps and/or Secrets.

Since Kubernetes has a build-in scheduler, you can create a CronJob following the official documentation.

For an example of such CronJob deployment, take a look below:

apiVersion: batch/v1
kind: CronJob
metadata:
  name: tastytrade-ghostfolio
  namespace: ghostfolio
spec:
  schedule: "@hourly"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
            - name: tastytrade-ghostfolio
              image: olirafa/tastytrade-ghostfolio
              imagePullPolicy: IfNotPresent
              env:
                - name: GHOSTFOLIO_ACCOUNT_TOKEN
                  valueFrom:
                    configMapKeyRef:
                      name: tastytrade-ghostfolio-configs
                      key: GHOSTFOLIO_ACCOUNT_TOKEN
                - name: GHOSTFOLIO_BASE_URL
                  valueFrom:
                    configMapKeyRef:
                      name: tastytrade-ghostfolio-configs
                      key: GHOSTFOLIO_BASE_URL
                - name: TASTYTRADE_USERNAME
                  valueFrom:
                    secretKeyRef:
                      name: tastytrade-credentials
                      key: user
                - name: TASTYTRADE_PASSWORD
                  valueFrom:
                    secretKeyRef:
                      name: tastytrade-credentials
                      key: password
          restartPolicy: OnFailure

(back to top)

Roadmap

  • Stock buys and sells
  • Forward share splits
  • Symbol changes
  • Dividends and dividend reinvestments
  • Account balance

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

Top contributors:

contrib.rocks image

Acknowledgments

(back to top)

License

Distributed under the Unlicense License. See LICENSE.txt for more information.

(back to top)


Rafael Oliveira  ·  olirafa.github.io  ·  GitHub @OliRafa  ·  LinkedIn @OliRafa