A stocks portfolio backend application to trade and view stocks, view portfolio for a user and update stocks.
API routes:
- /api/v1/stocks/{stockId} (GET)
-> Gives the details of a stock with id 'stockId'
- /api/v1/stocks/upload (POST)
-> Parses the bhavcopy csv file and updates the current prices of all the stocks in the database.
-> To update the details of the stocks, go to Postman and under the POST request options, click on Body.
-> Since a csv file is to be processed, click on 'form-data'. This takes in a key value pair where the key is the file name variable accepted by the controller layer and the value is the csv file.
-> In my code, I am taking the file input by the variable name 'file' - so for the key part, type 'file' and check the adjacent box. Set the input type from Text to File.
-> Finally, upload the csv file in the value field and hit Send.
-> If the update was a success, an integer denoting the total number of records updated is returned as a response.
- /api/v1/trade (POST)
-> Takes userId, stockId, typeOfTransaction (buy/sell) and quantity of shares to establish a trade
- /api/v1/portfolio/{userId} (GET)
-> Takes userId as the request parameter and returns the current holdings of the user 'userId'