Dependencies

API key

Begin by visiting the Getting Started page at developer.tdameritrade.com. 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.

Advanced Features

There are certain order types and features of the API that cannot be used without first contacting TD Ameritrade support. You MUST contact them and ask that they disable advanced features on your account. There is no public information that I can find regarding what that means exactly, but you will NOT be able to use the Trade For Me application unless you complete this step. If you find that there are features in TOS or otherwise that you will lose as a result, you may create another brokerage account with TD Ameritrade dedicated to your automated trading.

Docker

You may use the app without docker, but it’s by far the easiest way to get up and running. Download docker desktop for Mac or Windows and hit the ground running! After checkout (there’s a free version of the app too), you will be presented with a regular download option and a docker download option. Download the docker package, unzip it to your computer, launch a terminal inside the folder, and execute:

docker compose up -d

You may optionally edit the provided .env file before launching the docker container.

If you’re taking the docker route, you can stop reading. This rest of this page is for manual installation.


Node.js (unless using docker)

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.

MySQL (unless using docker)

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

If you’re not using the docker install package, 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` ;
CREATE USER 'tradeforme_user'@'%' IDENTIFIED BY 'MY_STRONG_PASSWORD';
GRANT ALL PRIVILEGES ON `tradeforme`.* TO 'tradeforme_user'@'%';

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;

Manual Installation [core application]

Extract zip package to a folder on your computer or server

Generate self-signed SSL certificates. The README.txt in resources/cert has detailed instructions. OpenSSL is required.

Windows users may wish to download Git Bash for this step. That will make it easer, although, if you know your way around OpenSSL and command line apps, you probably don’t need it.

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 (to verify config options):
node tradeforme config get

Execute:
node tradeforme login

View log/YYYY-MM-DD.log to find your login URL. It will be a URL to auth.tdameritrade.com 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 and Trade For Me will handle the auth/access tokens for future API calls.

Execute (for paid versions only):
node tradeforme activate [email protected]

Make $$$

Installation [strategy]

  • Extract zip package
  • Place the extracted file into /strategies directory within your application directory