Endpoints are configured in controllers/PortfolioResource:
POST /api/portfolios/create/{name}
- Create a new portfolio with the given name and an empty list of assets
GET /api/portfolios
- Get all portfolios
- Query param
assets
can be provided to filter by a list of asset symbols
GET /api/portfolios/{name}
- Get a portfolio by name
- Query param
assets
can be provided to filter by a list of asset symbols
DELETE /api/portfolios/{name}
- Delete a portfolio by name
GET /api/portfolios/{name}/total-value
- Get the total value of a portfolio by name
Start the application:
./gradlew clean run --args='server config/app.yml'
curl -X GET "http://localhost:8080/api/portfolio/"
You should see "Will's Portfolio" and "Ale's Portfolio". The values of BTC and ETH will be cached for 20 seconds after the request is made.
curl -X GET "http://localhost:8080/api/portfolio?assets=BTC&assets=ETH"
curl -X GET "http://localhost:8080/api/portfolio/Will%27s%20Portfolio?assets=USD"
curl -X DELETE "http://localhost:8080/api/portfolio/Will%27s%20Portfolio"
curl -X GET "http://localhost:8080/api/portfolio/Will%27s%20Portfolio/total-value"
You should get a 404 with the message "Portfolio 'Will's Portfolio' not found."
curl -X POST "http://localhost:8080/api/portfolio/create/Empty%20Portfolio"
curl -X GET "http://localhost:8080/api/portfolio/Empty%20Portfolio?assets=BTC"
You should get a 404 with the message "Asset 'BTC' not found in portfolio 'Empty Portfolio'."
curl -X GET "http://localhost:8080/api/portfolio/Empty%20Portfolio/total-value"
Since the portfolio is empty, the total value should be returned as 0.
Run all unit tests located in test/kotlin/portfolios:
./gradlew clean test