Get Started With Alpaca
The following is a list of working examples built by Alpaca and the developer community. They can be immediately used in paper or live trading, and best of all, they’re free to use and customize for your own purposes.
We want to emphasize that these examples are meant to be instructive and demonstrate some of the possibilities of the Alpaca platform. They have not been analyzed or tested for profitability. Use in live trading at your own discretion.
Also, you can always go back to a list of How-To Code Examples where you’ll find examples of how to do specific tasks using the Alpaca API in supported programming languages.
Got another interesting idea? Tell us about it in our Forum, and we can list it here.
Here are some great tutorial videos created by Alpaca community. Paper Trading with the Alpaca API Larry walks you through how to call API in python in 15 mins from setup to submit an order. Configuring Heroku Application to Run Alpaca Algos For FREE! Marcin puts together how to set up Heroku to host your algorithm with Process Scheduler. Simple python database and algotrading Patrick demonstrates how to build a trading algorithm using AlphaVantage data and Alpaca API.
This example works with both paper and live trading. How to get started and test the Alpaca trading API Want to trade with Alpaca, but you aren’t fully sure how the Alpaca API works yet? Here’s a step by step tutorial on testing the Alpaca API by trading manually using the Postman interface. This tutorial explains how to: Generate your API Keys Get your account information through API Get asset information through API Place an order through API Get positions through API Close positions through API Read the original post on our Forum!
This example works with both paper and live trading. How to get started with trading in your browser Alpaca is making it easier to trade stocks programmatically, by providing modern REST API, but it can be a bit of work to set up your programming environment before you can begin playing with API. When setting up your environment, there are a lot of complicated ecosystems to choose from. In this tutorial, we will explain how to set up a Google Colab notebook so you can start trading using your web browser and not have to worry about various coding language environments, code editors, or opening a terminal.
This example works with both paper and live trading. Alpaca’s trading API is not just about automation and frequency. Using a simple REST interface, you can build your own user interface suitable for your own trading needs. Google Spreadsheet is a great software that everyone can use, and with this example, you can trade directly from your portfolio management spreadsheet. Detailed Explanation on Medium Working Spreadsheet You Can Copy
This example works with both paper and live trading. Alpaca provides support for several open-source SDKs which make interfacing with our API easy. Below are links to similar algorithms implemented in multiple languages using each supported SDK. Examples are available in Python, Javascript/Node.js, Golang, and C#/.Net.
This example only works if you have a funded brokerage account or another means of accessing Polygon data. This algorithm is an active, daytrading strategy that captures small moves frequently using order book imbalance as an indicator. The idea is not secret or new - it’s a strategy that has been studied in academia and the industry. This example also gives you a good idea of how to use streaming data in an algorithm’s code.
This example only works if you have a funded brokerage account or another means of accessing Polygon data. An example algorithm for a momentum-based day trading strategy. Detailed Explanation on Medium Code on GitHub
This example only works if you have a funded brokerage account or another means of accessing Polygon data. This python script is a working example to execute scalping trading algorithm for Alpaca API. This algorithm uses real time order updates as well as minute level bar streaming from Polygon via Websockets (see the document for Polygon data access). One of the contributions of this example is to demonstrate how to handle multiple stocks concurrently as independent routine using Python’s asyncio.
This python script implements a utility class that makes it easy to manage your portfolio programmatically. The PortfolioManager class implements easy way to feed the desired portfolio structure either in weights or the number of shares, and submits the necessary orders in parallel. You can use this class and feed the data from static file (such as CSV) or dynamically calculate from some other data. Code on GitHub