Getting Started with Alpaca

Alex Roland
3 min readJun 4, 2019

--

The term “Algorithm Trading” is constantly being thrown around investment spheres currently. However, up until recently, there were not viable brokers for the average retail investor. Alpaca serves to fit that niche.

Alpaca’s commitment to a completely free platform allows users to make the most of their trades, and cuts out the high commissions that were previously unavoidable. The question that clearly follows then, is how do I get started?

Luckily, this process is designed to be as easy as possible, and I will walk you through it here below. First navigate to Alpaca and click sign up. Simply follow the directions that are prompted, until you arrive at the dashboard. It should look something like this:

For your testing purposes, it is important to use the paper trading dashboard instead of the live dashboard so that you can gain an understanding of the platform without the use of real money.

Once you have arrived at the paper trading dashboard, click “Generate New Key.” These API keys will allow you to interact with the Alpaca platform. Please store your secret key securely as it will disappear once the page is refreshed.

The next step in the process is interacting with Alpaca’s REST API. For the purposes of this demonstration I will be coding in Python using the PyCharm IDE. However, Alpaca works with all languages that support REST and most IDE’s will work much the same. My setup looks like this:

Luckily, Alpaca already provides extensive documentation as well as guides, so getting started is easy for all levels of programmers. Next we will navigate to the “How To Code” portion of the API documentations. Here we will copy and the code from the Account Examples tab and paste it into our IDE.

IMPORTANT: In order to interact with Alpaca’s API, you must download the python library “alpaca_trade_api”. This can be done by using the pip tool from python.

Next task is defining our link, key, and private key variables. In my case this looks like the following but your keys will be different.

After that, the program is ready to run! As long as you do not receive the error message, your account is successfully linked with the REST API.

Now that you have an understanding of how to interact with Alpaca, you can begin exploring the other functions of the API. I suggest looking at our User Control Menu that allows the user to manually use some of the functions that the Alpaca platform offers such as submitting trades, managing your portfolio, and pulling market data. After that, I encourage you to check out some of the sample algorithms to get a grasp on a fully implemented trading program.

--

--