Giter Site home page Giter Site logo

stock_portfolio's Introduction

Stock Portfolio

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)

  1. Clone this repository.
  2. Navigate to repository folder and execute the following command: npm install
  3. 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.
  4. Run npm start in root directory of project to start the api server. This will start the server. Server will listen on port 5000.
  5. 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

API Endpoints (localhost:5000/api/*)

All the parameters in all the api's are required, unless state optional

Link to Postman Collection

Add Stock

route - /stock

type: POST

Api for creating a new Stock/Security

Parameters In raw-JSON Body

{ "name" : "TCS", "price": "1892.11" }


Fetch Stock

route - /stock

type: GET

Api for fetching stocks


Creating a Trade

route - /trade

type: POST

Api To Create a trade (first time transaction) in the portfolio.

Parameters In raw-JSON Body

{ "_stockId": "5dc71dc764fab528dc4431d0", "quantity": 8 }


Updating a Trade (buying of additional stocks)

route - /trade/:id

type: PUT

Api To Update an existing trade (buying stocks) from portfolio.

Parameters In raw-JSON Body

{ "id":"1" }


Deleting a Trade (selling stocks)

route - /trade/:id

type: DELETE

Api for Selling/Removing stocks from portfolio.


Get Portfolio

route - /portfolio

type: GET

Api for getting all the securities and trades corresponding to it.


Get Holdings

route - /holdings

type: GET

Api To get an aggregate view of all securities in the portfolio with its final quantity and average buy price.


Get Returns

route - /returns

type: GET

Api To get cumulative returns at any point of time of a particular portfolio.


Postman Collection

Link: https://www.getpostman.com/collections/9f5a92140b9ca80c2816


Heroku Hosted URL

Link: https://lit-reaches-26043.herokuapp.com/

stock_portfolio's People

Contributors

dependabot[bot] avatar shubhamjain2908 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.