Tutorial for AlpacaforR to connect to Alpaca API

AlpacaforR Tutorial connecting to Alpaca API with R

I’m in the process of documenting my trading algorithm which is a fully automated system that examines market moves and trades accordingly. Stay tuned for future updates and documentation. R is a language and an environment that is good for analyzing data and creating rich graphics. This page is a supplemental tutorial to AlpcaforR. One product I use and enjoy thoroughly are the Dell laptops. They are relatively inexpensive and can be purchased directly from Amazon with ease and speed. The power settings can be set to never sleep to allow your code to run 24 hours a day, 365 days a year. I recommend getting the Keep Awake plugin for Goggle Chrome and to just leave Chrome open and Keep Awake on. This ensures your code is always running waiting for the next day of market data and ready to make a move in the market whether that be to see when there is a downturn or to buy when there is support. Dell’s computers have a 4 year hardware warranty and for good reason. Thery aren’t likely to have any issues in that timeframe. If there is an issue Dell provides excellent support and will even send a technical engineer to make a hardware replacement if needed. Dell Support

The solid state hard drives are very stable and not prone to physical damage if the computer has a small physical shock as would occur from a small drop a short distance. The battery life is good and the screen resolution is great. The computer is light and for the money this is one of the best computers I’ve found. This computer would be more than sufficient to run your algorithm which we’ll get to next in the coming pages.

Learn how to use R for buying and selling stocks after you analyze market data with your custom automated API for free! No hidden trading fees or account dues. Its all free which is the best part.

Getting Help
There are several ways to get help with R.

R Mailing List | Mailing List archive (which you can search using the google site restriction site:stat.ethz.ch/pipermail/r-help) | StackOverflow
Just google R and your question. Surprisingly, it works.
Getting started
To get started make sure you have R installed on your computer Install R and create a brokerage account with Alpaca Markets Alpaca Markets Here is a list of countries Alpaca is available in. Countries You will also need a Polygon.io account to pull in market data. Polygon.io

For this course, I prefer the simplest, least distracting exposure to R - the R Terminal. The model of a terminal and an editor where you keep code and notes is very powerful, and can take many forms. Make sure you go to edit on the top of the R console and change the GUI preferences to change the window to SDI and whatever colors you want, hit save and apply and close then reopen the window for a better view.

Two usage notes to help your efficiency:

up arrow - your entire command history is stored here. Use it! It should be one of the most worn keys on your keyboard. Using it means you’re optimizing analysis of your data.
Alt-tab - (or command-tab on mac) this allows you to switch between applications without leaving the keyboard.
Download Packages