Requirements & Installation


API key

Begin by visiting the Getting Started page at From there, read under the subheadings Creating a Developer Account and Registering an App. Read the post, How to create a TD Ameritrade API key for automated trading, for more details. It includes screenshots to help you from start to finish.


If you’re not already familiar with Node.Js, it’s an open-source, cross-platform, back-end JavaScript runtime environment that runs on the V8 engine and executes JavaScript code outside a web browser. Download and install Node.js to the environment on which you plan to run Trade For Me.


If you made it past the dependencies list at the top of the page and you’re still reading, you are most certainly my people. The kind of folks that like to tinker with geek things. You may or may not have installed, or at least used, a database backend for another application. If you haven’t this will be tricky for your first run at it. You have options:

  • Install MySQL Community Server
    • It’s free to download, install, and use.
    • It’s available for a wide variety of operating systems
  • Use a hosted database server
    • Bluehost is an awesome hosting company. If you just need a database for this app, you could probably get away with just the basic plan.
  • Use Docker
    • I’m currently running my app inside a docker container, although, my database isn’t in it. There’s no reason it couldn’t be, though!
    • Here’s an example of a docker compose file that could potentially get you started. This one will mount a volume for the MySQL data so it will persist between restarts. Essential if you don’t want to lose your data.
version: '3'
  image: mysql
   MYSQL_DATABASE: 'tradeforme'
   MYSQL_USER: 'tradeforme_user'
   MYSQL_PASSWORD: 'tradeForMeuserPaSs!'
   MYSQL_ROOT_PASSWORD: 'tradeForMrootPasS!'
   - "3306:3306"
   - mysql_volume:/var/lib/mysql

Regardless of the option you choose, you must create a database and database user with the appropriate permissions. Feel free to use this SQL. Just be sure you change MY_STRONG_PASSWORD with an actual strong password. If you’re unable to run SQL directly due to limitations by your host, you will need to use whichever mechanism they allow to create databases and users. The important bit is the GRANT statement. When creating your user, grant it the same permissions as listed here. These permissions are the minimum required to install and use the app.

CREATE SCHEMA `tradeforme` ;

If you need to set mysql_native_password (because you got an error that the authentication method wasn’t supported)

ALTER USER 'tradeforme_user'@'%' IDENTIFIED WITH mysql_native_password BY 'MY_STRONG_PASSWORD';

If you see this error: You do not have the SUPER privilege and binary logging is enabled (you might want to use the less safe log_bin_trust_function_creators variable)

Using SET in this way will not persist the global variable, however, you should only need to do this one time right before you initialize the application.

SET GLOBAL log_bin_trust_function_creators=1;


  • Extract zip package to a folder on your computer or server
  • Generate self-signed SSL certificates (read README.txt in resources/cert for detailed instructions)
  • cd to your project root and execute: npm install –production
  • Rename _db-example.conf to _db.conf and update with your database credentials
  • Execute: node tradeforme config init
  • Update values and execute: node tradeforme config set –acctNum=123 –tdConfig.apiKey=XYZ –tdConfig.redirectUri=https://localhost:3000 –tz=America/Chicago
  • Execute: node tradeforme config get [to verify config options]
  • Execute: node tradeforme login
    • View log/YYYY-MM-DD.log to find your login URL. It will be a URL to with your redirect URL as a parameter. You will login with your TD Ameritrade credentials allowing the TD Ameritrade Developer API to interact with your brokerage account. Upon successful authentication, you’ll be redirected back to your redirect URL (on your localhost) and Trade For Me will save the auth/access tokens in the database for future API calls.
  • Make $$$