This project is a simple endpoint that checks some info about a stock and returns it.
- All stock values have 15min of delay
- All currency values are in BRL.
- For now only IBOVESPA stocks.
Endpoint | Name | Request Type | Return | Return Code |
---|---|---|---|---|
"/" | Hello World | GET | str | 200 |
"/health-check" | Health Check | GET | str | 200 |
"/ibov:stock-id" | Stock | GET | json | 200 |
$ curl http://localhost:4666/ibov/petr4
will return:
{
"price": "22.72",
"max": "22.98",
"min": "22.53",
"variation": "-0.52",
"stock-id": "petr4",
"currency": "brl",
"time": "2020-08-15T15:36:59.858-0300"
}
- Invalid stock ids will get you a 404.
- Passing no stock id will get you a 500.
You must have Java installed on your machine. To run dev mode you must have Leiningen too.
$ lein deps
$ lein run
$ java -jar ./executable/stocks-standalone.jar
$ lein repl
user=> (require 'stocks.web)
user=> (def server (stocks.web/run-dev))
$ lein repl
user=> (require 'stocks.web)
user=> (def server (stocks.web/-main))
user=> (.stop server)
Your app should now be running on localhost:4666.
Run all tests
$ lein test
Run tests in watch mode (you must have fswatch installed)
$ lein test:watch
I hope this can be useful for anyone. In the future I may create a new endpoint that returns in USD.