A portfolio tracking API adding/deleting/updating trades and can do basic return calculations etc. By providing REST API endpoints in it.
The api's are written in NodeJS.
Steps to run the api server:
Make sure you have NodeJS version 10 or higher installed. (Database used: MongoDB: Mlab)
- Clone this repository.
- Navigate to repository folder and execute the following command:
npm install
- Create a local DB in mongo or remote in MLab. Make note of DB name along with username, password and host. You machine should be able to connect to database using any DB client. Also grant all privillages to it.
- Run
npm start
in root directory of project to start the api server. This will start the server. Server will listen on port5000
. - Import the following postman collection to have a look at the api's and try them out yourself. Set the following environment variable in postman. In addition this project is Hosted on Heroku
url : localhost:5000/api
,Heroku Url: https://lit-reaches-26043.herokuapp.com
All the parameters in all the api's are required, unless state optional
Link to Postman Collection
route - /stock
type: POST
Api for creating a new Stock/Security
{ "name" : "TCS", "price": "1892.11" }
route - /stock
type: GET
Api for fetching stocks
route - /trade
type: POST
Api To Create a trade (first time transaction) in the portfolio.
{ "_stockId": "5dc71dc764fab528dc4431d0", "quantity": 8 }
route - /trade/:id
type: PUT
Api To Update an existing trade (buying stocks) from portfolio.
{ "id":"1" }
route - /trade/:id
type: DELETE
Api for Selling/Removing stocks from portfolio.
route - /portfolio
type: GET
Api for getting all the securities and trades corresponding to it.
route - /holdings
type: GET
Api To get an aggregate view of all securities in the portfolio with its final quantity and average buy price.
route - /returns
type: GET
Api To get cumulative returns at any point of time of a particular portfolio.
Link: https://www.getpostman.com/collections/9f5a92140b9ca80c2816