Welcome to get-dat-money, where we get dat money. This service is a simple API that fetches price data for any ticker, for any date range. If the database does not yet have a particular ticker's data, it will fetch it from an external source and save it to the db. If it does have a ticker's data, it will fetch directly from the db.
There are three query params expected:
ticker(required)start_date(optional; defaults to "1900-01-01")- Expected format: YYYY-MM-DD
end_date(optional; defaults to today's date)- Expected format: YYYY-MM-DD
- Note that the data returned is up to (but not including) the
end_daterequested. e.g. sending a request withend_date=2023-03-15will return data for2023-03-14, but not for2023-03-15.
interval(optional; defaults to "1d")- Currently, "1d" is the only valid input until we beef out the fetcher(s).
There are two make commands:
make server detach=<true,false>- Spins up a database as well as the API server.
- Optional argument
detachdefaults tofalseso you can see the logs.
make kill- Kills the containers with a simple
docker compose down.
- Kills the containers with a simple
make test- Runs all unit tests.
Once the environment is healthy and the server is up, you can run curl commands to see the magic work, such as:
curl 'http://localhost:8080/api/v1/prices?ticker=AAPL&start_date=2023-03-01'
curl 'http://localhost:8080/api/v1/prices?ticker=MSFT&start_date=2022-01-01&end_date=2023-03-04'
curl 'http://localhost:8080/api/v1/prices?ticker=TSLA&interval=1d'
We use Github Actions for our CI workflow. You can find the simple job in .github/workflows/ci.yml.
It simply sets up two Go version environments: 1.19 and 1.20. Then, it installs dependencies, builds the module, and runs
go test ./... -cover
to recursively find and run tests, as well as print out the test coverage. You can find all the runs here.
This is a young buck that is still a work in progress to beef up. Tasks on the horizon are:
- Adding terraform (or AWS CDK?) IaC. Ideally, we'd have this running as an ECS service in a private subnet, with the access path being API Gateway, Network Load Balancer, and finally Application Load Balancer.
- See what other endpoints and functionalities make sense for this service.