No description
Find a file
Dan Anglin a483eae0cb
docs: update README.md
- Added overview section.
- Added instructions on running the docker image.
2023-02-19 19:26:29 +00:00
kubernetes fix: updated kubernetes manifest 2023-02-19 17:27:13 +00:00
.dockerignore feat: add stock ticker app 2023-02-19 16:28:25 +00:00
.gitignore feat: add stock ticker app 2023-02-19 16:28:25 +00:00
Dockerfile feat: add stock ticker app 2023-02-19 16:28:25 +00:00
go.mod feat: add stock ticker app 2023-02-19 16:28:25 +00:00
handlers.go feat: add stock ticker app 2023-02-19 16:28:25 +00:00
main.go feat: add stock ticker app 2023-02-19 16:28:25 +00:00
README.md docs: update README.md 2023-02-19 19:26:29 +00:00
types.go feat: add stock ticker app 2023-02-19 16:28:25 +00:00

Stock Ticker

Overview

$ curl http://stock-ticker.test/stockprice

Symbol: MSFT

Week       | Closing Price
==========================
2023-02-17 |   258.0600
2023-02-10 |   263.1000
2023-02-03 |   258.3500
2023-01-27 |   248.1600
2023-01-20 |   240.2200
2023-01-13 |   239.2300
2023-01-06 |   224.9300

This is a simple web service that prints the last 'N' weeks of closing stock prices for a particular stock. The data is retrieved from Alpha Vantage's API.

The web service servers the following endpoints:

  • /healthcheck - Returns 200 if the server is up and running.
  • /stockprice - Prints the closing prices for the latest N weeks.

Alpha Vantage API Key

Before running the web service you'll need to obtain an API key from Alpha Vantage. You can claim a free key from:

https://www.alphavantage.co/support/#api-key

Required environment variables

Environment Variable Description Example
SYMBOL The symbol of the stock. MSFT
NWEEKS Display the closing price for the last N weeks. 7
APIKEY Your API key from Alpha Vantage.

Command line arguments

Argument Description Default
address The address that the web server will listen on. 0.0.0.0:8080

Running the docker image locally

The docker image is published to the GitLab container registry here. You can pull and run the docker image from the registry with the following command:

docker run --rm \
    -d \
    -e SYMBOL=MSFT \
    -e NWEEKS=3 \
    -e APIKEY=<YOUR_API_KEY> \
    --publish 8080:8080 \
    --name stock-ticker \
    registry.gitlab.com/dananglin/stock-ticker:v0.1.0

Alternatively you can build and run the docker image locally.

git clone https://gitlab.com/dananglin/stock-ticker.git
cd stock-ticker
docker build -t stock-ticker .
docker run --rm \
    -d \
    -e SYMBOL=MSFT \
    -e NWEEKS=3 \
    -e APIKEY=<YOUR_API_KEY> \
    --publish 8080:8080 \
    --name stock-ticker \
    stock-ticker

Now you can go to http://localhost:8080/stockprice in your browser to view a table of the latest weekly closing stock prices for MSFT.