Skip to content

This is a prototype for building a brokerage company's account and trades management platform. One Requirement is for a REST API service to manage trades using the Spring Boot framework. Add functionality to add or delete transactions as well as to perform some queries.

Notifications You must be signed in to change notification settings

saieshwar/Stock-Trade-API-Hackerrank

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stock-Trade-API-Hackerrank

This is a prototype for building a brokerage company's account and trades management platform. One Requirement is for a REST API service to manage trades using the Spring Boot framework. Add functionality to add or delete transactions as well as to perform some queries.

Reach out to me

LinkedIn Gmail



Each trade is a JSON entry with the following keys:

id: This is the trade unique ID.

type: This is the trade type, buy or sell.

user: The user responsible for the trade. The user itself is a JSON entry consisting of following fields:

id: This is the user unique ID.

name: This is the user name.

symbol: This is the stock symbol.

price: This is the stock price for one stock (upto two places of decimal) at the time of the trade. The stock price is between 130.42 and 195.65inclusive.

timestamp: This is the timestamp for the trade creation given in the format yyyy-MM-dd HH:mm:ss. The timezone is EST (UTC -4).

Execution

# To build the project standard maven build is sufficient
mvn clean install

# To start/run the project spring boot maven plugin is included just run
mvn spring-boot:run

# The integration test may be executed using
mvn test

Usage

Once the application is started,

  1. Erase all the trades, run below command in cURL
$curl -i -X DELETE http://localhost:8080/erase
  1. Add a new trade,
$curl -X POST http://localhost:8080/trades/  -H "content-type: application/json"
-d "
    {
        "id": 1,
        "type": "buy",
        "user": {
            "id": 2,
            "name": "Amy Palmer"
        },
        "symbol": "AA",
        "shares": 11,
        "price": 174.82,
        "timestamp": "2018-12-28 13:18:48"
    }"
  1. Return a trade filtered by ID, http://localhost:8080/trades/1 (1 -> id of trade).
  2. http://localhost:8080/trades/ , return all trades the response should be sorted in ascending order by trade ID.
  3. Get all the trades filtered by USER ID,goto http://localhost:8080/trades/users/2 the response should be sorted in ascending order by trade ID.(2 -> id of user)
  4. http://localhost:8080/trades/stocks/AA, return all the trades filtered by STOCK SYMBOL the response should be sorted in ascending order by trade ID. (AA -> stock symbol)
  5. Return all the trades filtered by USER ID & STOCK SYMBOL the response should be sorted in ascending order by trade ID, http://localhost:8080/trades/users/2/stocks/AA (2 -> id of user, AA-> stock symbol).

About

This is a prototype for building a brokerage company's account and trades management platform. One Requirement is for a REST API service to manage trades using the Spring Boot framework. Add functionality to add or delete transactions as well as to perform some queries.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages