We’ve all heard about algorithmic trading in the news. It sounds great! You think of a program making money for you while you sip Mai Tais and smoke the finest ganja on the beach in Jamaica. I’m going to show you how you can do it yourself with TD Ameritrade and a laptop.

Before we start, you need to know that great reward comes with great risk. Don’t do this with money you’re not willing to lose.

Getting API Keys

The first thing you’ll need is a TD Ameritrade account. You don’t need to be a US citizen to get an account, and the process is pretty easy. If you’re in Jamaica, you’ll have to send TD Ameritrade signed copies of the documents they give you via Fedex or DHL. After you’ve signed up for TD Ameritrade, head over to their developer website and sign up for a developer account. Create an app and specify it. TD’s developer website will not accept a Callback URL that doesn’t begin with https, even if it’s localhost. You can test applications locally by removing the “https” with “http” in the URL bar after the redirect, or serving localhost over TLS.

Image for post

The app Callback URL must begin with https://

Once you’ve created your app, its client ID will be available to you in the dashboard. It seems you can only create one app per developer account.

Image for post

The OAuth2 Client ID is available as the Consumer Key in the dashboard.

You can use this client ID in any OAuth2 client library to interact with TD Ameritrade’s API. If you use Go, I’ve written a TD Ameritrade client library that handles authentication and interaction with the TD Ameritrade REST API, and if you use Python, Alex Golec wrote a python wrapper.

#stocks #algorithmic-trading #golang #trading #options

Printing Money With TD Ameritrade’s API
4.20 GEEK