Manage Your Stocks from Google Spreadsheet Using API

Hitoshi Harada
Dec 4, 2018 · 4 min read
Photo by Neil Daftary

This is the Dec 4th entry for Trading API Advent Calendar. Yesterday was a post with Yoshi’s futuristic view on automation. We still have slots available for this Advent Calendar so please reach out to me (@umitanuki) or @AlpacaHQ if you are down to write something (pretty much anything is ok)!

Spreadsheet Trading

App Script

App Script is for many Google Apps as well as used as standalone app, but today we use it from Spreadsheet. In order to do so, you create a new spreadsheet, and select [Tools] -> [Script editor] from the menu.

It opens a editor in browser and you can start writing App Script. Write a simple function like

function doDouble(v) {
return v * 2;
}

Then you can call this function in the cell formula like

= doDouble(2)

Trading API?

That’s Great, Now What?

Sample Sheet

Screenshot of my sample spreadsheet

I actually share my sample spreadsheet with working script (also the full code is attached below). As this screenshot shows, you can update your portfolio values in one click and see it in a tabular format friendly to you. It can show your account information such as portfolio value and list of positions you hold. Here is the detail step you can follow to build your own.

  • Copy this spreadsheet
  • [Tools] -> [Script editor]
  • Add your API key ID and secret in the script. If you are doing it in paper trading, change the endpoint to https://paper-api.alpaca.markets
  • Click on the UPDATE button (you may get security warning but you can trust me :D), then that’s all!

The SUBMIT button submits an order using the “Order” section information. If it’s in the market hours, you will get order acceptance response in the “Result” cell.

Unlimited Possibilities

Enjoy Spreadsheet Trading!


Technology and services are offered by AlpacaDB, Inc. Brokerage services are provided by Alpaca Securities LLC (alpaca.markets), member FINRA/SIPC. Alpaca Securities LLC is a wholly-owned subsidiary of AlpacaDB, Inc.

You can find us @AlpacaHQ, if you use twitter.

Automation Generation

News and thought leadership on the changing landscape of…

Hitoshi Harada

Written by

CTO/CoFounder @AlpacaHQ (YC W19) the API-first brokerage for algorithmic trading and developers (https://alpaca.markets)

Automation Generation

News and thought leadership on the changing landscape of automated investing. Changing the market one algorithm at a time.

Hitoshi Harada

Written by

CTO/CoFounder @AlpacaHQ (YC W19) the API-first brokerage for algorithmic trading and developers (https://alpaca.markets)

Automation Generation

News and thought leadership on the changing landscape of automated investing. Changing the market one algorithm at a time.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store