{"id":20802215,"url":"https://github.com/picadoh/stocks-api","last_synced_at":"2025-05-07T00:45:56.653Z","repository":{"id":225882960,"uuid":"66852353","full_name":"picadoh/stocks-api","owner":"picadoh","description":"Simple Stocks Spring Boot Application","archived":false,"fork":false,"pushed_at":"2019-04-06T22:52:22.000Z","size":27,"stargazers_count":12,"open_issues_count":0,"forks_count":10,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-31T04:41:15.588Z","etag":null,"topics":["example","java","spring","spring-boot"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/picadoh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2016-08-29T14:43:51.000Z","updated_at":"2024-10-30T05:16:34.000Z","dependencies_parsed_at":"2024-03-04T20:13:01.298Z","dependency_job_id":"13954be8-e8d3-4bc3-b659-70d8cf4ff2c5","html_url":"https://github.com/picadoh/stocks-api","commit_stats":null,"previous_names":["picadoh/stocks-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/picadoh%2Fstocks-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/picadoh%2Fstocks-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/picadoh%2Fstocks-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/picadoh%2Fstocks-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/picadoh","download_url":"https://codeload.github.com/picadoh/stocks-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252793564,"owners_count":21805054,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["example","java","spring","spring-boot"],"created_at":"2024-11-17T18:28:51.737Z","updated_at":"2025-05-07T00:45:56.645Z","avatar_url":"https://github.com/picadoh.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"### Simple Stocks API\n\nThis is an example application that provides the means of managing simple stocks and trades.\n\nThis is offered as a simple web service that provides the following operations:\n- Record a trade\n- Record a stock\n- Get stock details\n- Calculate stock dividend\n- Calculate stock P/E ratio\n- Calculate stock price based on trades recorded in the past X minutes (configurable)\n- Calculate the GBCE All Share Index using geometric mean of prices for all stocks\n\n### Requirements\n- Java 8\n- Maven 3\n\n### Design\nThe application is structured in layers, namely:\n\nA *controller* is responsible for handling the requests and communicating with the layer service for providing a response. Here the internal domain is converted to DTOs to eliminate the coupling between the API and the internal domain.\n\nA *service* is responsible for executing the business logic, here we know how to compute stock prices and GBCE indexes.\n\nA *domain object* represents the model (Stock and Trade)\n\nA *repository* abstracts the underlying datastore. For the sake of the example, the underlying datastore is a local hash set.\n\n### Code structure\nThe *application* contains the main application source code and unit tests.\n\nThe *integration-tests* module contains the end-to-end tests made at web service level.\n\n### Build\n\n    project$ mvn clean install\n\n### Running\n\n\tproject$ cd application\n    project$ mvn spring-boot:run\n\nFor validation purposes you can now access localhost:8080 in the corresponding endpoints in order to test the service. The following endpoints are available:\n\n    POST /stock - Create new stock\n    POST /trade - Create new trade\n\n    GET /stocks?symbol=GIN - Get stock details for stock with symbol GIN\n    GET /stocks/dividend?symbol=GIN - Calculate dividend yield for stock with symbol GIN\n    GET /stocks/peratio?symbol=GIN - Calculate P/E ratio for stock with symbol GIN\n    GET /stocks/price?symbol=GIN - Calculate the stock price for stock with symbol GIN\n    GET /stocks/gbceasi - Calculate GBCE all shares index\n\nThe following CURL examples might come in handy while validating the application\n\n    curl -H \"Content-Type: application/json\" -X POST -d '{\"symbol\":\"GIN\",\"type\": \"COMMON\",\"lastDividend\": \"8\",\"fixedDividend\": \"0.02\",\"parValue\": \"100\",\"tickerPrice\": \"1.1\"}' http://localhost:8080/stock\n    curl -H \"Content-Type: application/json\" -X POST -d '{\"stockSymbol\": \"GIN\",\"price\": \"10.6\",\"quantity\": \"3\",\"indicator\": \"BUY\"}' http://localhost:8080/trade\n\n    curl -H \"Content-Type: application/json\" http://localhost:8080/stocks?symbol=GIN\n    curl -H \"Content-Type: application/json\" http://localhost:8080/stocks/dividend?symbol=GIN\n    curl -H \"Content-Type: application/json\" http://localhost:8080/stocks/peratio?symbol=GIN\n    curl -H \"Content-Type: application/json\" http://localhost:8080/stocks/price?symbol=GIN\n    curl -H \"Content-Type: application/json\" http://localhost:8080/stocks/gbceasi\n\n### Integration Tests\nIntegration tests run under a specific maven profile so it is possible to run them in a separate pipeline stage.\n\n    project$ mvn clean install -Pintegration-tests\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpicadoh%2Fstocks-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpicadoh%2Fstocks-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpicadoh%2Fstocks-api/lists"}