Code Monkey home page Code Monkey logo

plaid2qfx's Introduction

plaid2qfx

Description

This is a Python script that leverages the Plaid API to download transactions and format them into QFX files for import into Quicken. (If anyone wants, I can very easily add an OFX format option for use with other financial software.)

Why?

Frankly, to solve a very specific pet peeve I had. After 20+ years of using Quicken, I discovered I really liked using SoFi as my primary bank. Unfortunately, SoFi doesn't support Quicken for Windows (only Quicken for Mac, go figure). And SoFi doesn't offer anything but a super lame CSV exports of transactions on a per-account basis.

Well why not just use the CSV file and something like ImportQIF you ask? Because the QIF format, just like SoFi's CSV exports, lacks a unique transaction ID that prevents duplicating transactions. And various other irritations. It just drove me nuts. My way is far superior :-) !

Instructions

If you are already intimidated at the idea of running a Python script, this is not for you. But please leave me a comment and if I get enough interest, I'll consider figuring out how to create a web app version.

A few requirements:

  • A working Pyton 3 installation plus some non-standard modules:
  • A free Plaid developer account
  • A bank account that Plaid supports for transaction downloads, which you need a developer account to fully search.
    • Search for your bank here and make sure it lists * Transactions * under Supported Products

Usage

Just run the script and it should prompt you through the rest. There are some options that may be useful after you are set up and working:

PS C:\Git\plaid2qfx> py plaid2qfx.py --help
usage: plaid2qfx.py [-h] [-u] [-l] [-s] [-a ACCOUNT]

options:
  -h, --help            show this help message and exit
  -u, --updateconf      Update previously stored API and other configuration items, then exit.
  -l, --linkaccount     Link an additional account. You'll be prompted interactively for the link account name.
  -s, --showaccounts    Just enumerate the linked accounts in config then exit. Access tokens will NOT be displayed.
  -a ACCOUNT, --account ACCOUNT
                        Use this if you only want to work with a specific linked account instead of all saved
                        accounts. Use the label you specified for this account when first set up.

Security and How It Works

  1. Thanks for the contributions of cononco99, we no longer need to encrypt the configuration file. Testing has confirmed that Plaid access_tokens do not have access to anything without being associated with the specific Plaid client_id and client_secret that was used to create the link. Instead, you will be asked interactively for your Plaid API client secret as needed, and this will never be stored by the script.
  2. You will be asked for your Plaid API client_id, which will be stored in the config.
  3. Then you will be asked where you would like to save QFX output files. I didn't really want those living in my working directory and accidently getting synced to my GitHub repo!
  4. Now you get to set up a Plaid linked account.
    • Give it a name. I use a simple abbreviation of my Bank name. "PLAID" and "DEFAULT" are reserved for other uses.
    • An .html file will be generated containing the first step in Plaid's Link flow. If you're security-conscious like me, open the html file in a text editor and verify that the only script content comes directly from Plaid.com and a small script block in the html file that writes the public token Plaid returns when you complete a link to your screen. Now that you feel safe, open that file in your browser and click the button to interface with Plaid.

Warning

I take no responsiblity for Plaid's handling of your credentials, their privacy practices, or their security overall. Plaid * is * a reputable vendor, and this script does * not * have any access to your credentials. But I do think everyone should think twice before entering their Bank password anywhere that isn't their Bank.

  • Once you complete the Plaid workflow, you should see a public_token on the web page. Copy that and paste it into the script. The script will complete the token exchange and receive and securely store an access token allowing the script to download transactions from your Bank any time you run it.
  • The script will get a couple more details, clean up the .html file and move on to downloading transactions and formatting them in a QFX file for you.

Caveats and Known Issues

  1. The .html file generated as part of the account linking process does not work properly in Firefox. You'll get a spinning circle when you click the button. Chrome and Edge work fine.
  2. Those who have legacy encrypted config files can run the decrypt_conf.py function, which will back up your encrypted config and convert it to a plaintext config MINUS your Plaid API client secret.

plaid2qfx's People

Contributors

philliphall avatar

Stargazers

Ryan Mesaros avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

cononco99

plaid2qfx's Issues

No response after clicking "Start Linking My Bank" button.

Using a real plaid client/secret, got as far as opening (automatically generated) auth.html . Clicked "Start Linking My Bank" button and I see a rotating circle icon that never goes away.

Opened up browser console and see error messages. Screenshots attached.

plaid2qfx_console
plaid2qfx_browser

conf file suggestion

Since there's only one thing thing that really needs to be confidential in the conf file ( the secret ), it would probably make more sense to enter that at runtime (instead of the key being used to decrypt the file) and leave the file unencrypted. This has a number of advantages:

  • The user has only one secret key to hold on to: the plaid client API secret, instead of two: the client API secret and the randomly generated key.
  • The code is simpler. In fact you can eliminate the configparser_crypt dependency altogether.
  • The config file becomes human readable and one line shorter.

Key error when setting up first account

When defining the first account, I get a "KeyError" :

Where would you like output files stored? [/home/cononco99]:
Doesn't look like we have any accounts defined yet. Let's set one up.
For the purposes of this script, what label would you like to give this linked account? test4

The next step is to open   /home/cononco99/plaid2qfx/auth.html in your web browser.
Enter your public_token from the auth page: public-development-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
Traceback (most recent call last):
  File "/home/cononco99/plaid2qfx/plaid2qfx.py", line 667, in <module>
    main()
  File "/home/cononco99/plaid2qfx/plaid2qfx.py", line 114, in main
    link_name = link_account()
                ^^^^^^^^^^^^^^
  File "/home/cononco99/plaid2qfx/plaid2qfx.py", line 261, in link_account
    (accounts, ins_id) = get_accounts(link_name, True)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cononco99/plaid2qfx/plaid2qfx.py", line 341, in get_accounts
    access_token=conf[link_name]['access_token']
                 ~~~~^^^^^^^^^^^
  File "/usr/lib/python3.11/configparser.py", line 979, in __getitem__
    raise KeyError(key)
KeyError: 'test4'

Attribute error while creating configuration

python plaid2qfx.py -s
Looks like you don't have a configuration file yet, so I will create one. It will be encrypted using the following randomly generated key that you are responsible for protecting:
25899636666d7e3c5e5a3b4a78feb00af1ed6ac27ea2dbb924ddd548e15429ab
Press enter once you have saved this key.
Please provide your Plaid API client_id: vvvv
Please provide your client API Secret:
Where would you like output files stored? [/home/cononco99]:
Traceback (most recent call last):
File "/home/cononco99/plaid2qfx/plaid2qfx.py", line 84, in
plaid_api_configuration = plaid.Configuration(
^^^^^^^^^^^^^^^^^^^
AttributeError: module 'plaid' has no attribute 'Configuration'. Did you mean: 'configuration'?

plaid (incorrectly) reports positive balance for credit card.

Plaid reports a positive balance for a credit card that holds debt but this should be a negative balance - the magnitude is right but the sign is wrong.

If you download a .qfx file for a credit card you can compare and see that the balance in the qfx file is negative (as it should be and as Quicken expects).

If you import a .qfx file created by plaid2qfx with the positive balance, the import will work but you will be unable to reconcile to the online balance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.