Skip to content

API to manage stock portfolios by deploying automated trading strategies.

License

Notifications You must be signed in to change notification settings

sahilmemon7/stock_portfolio_svc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stock Portfolio API

Java Spring MySQL Docker

Maintenance

License: MIT

API to manage stock portfolios by deploying automated trading strategies.

Stack

  • Java 21
  • Maven
  • Spring Boot
  • Spring Web
  • Spring Validation
  • Jakarta Validation
  • Spring Data JPA
  • MySQL Connector
  • Spring Security
  • JWT API
  • JWT Implementation
  • JWT Jackson
  • Spring Dotenv
  • Lombok
  • Spring Test
  • H2 Database
  • MacOS DNS Resolver
  • Docker

Setup

  • Install dependencies:
./mvnw clean install
  • Pull Docker MySQL image for running database server:
docker pull mysql:latest
  • Create an external volume for storing MySQL data:
docker volume create stock_portfolio_volume
  • Run the container:
docker compose up -d
  • Start the application:
./mvnw spring-boot:run
  • Stop the container:
docker compose down

Endpoints

Requests can be made to perform the following actions:

  • Add Portfolio
  • Get Portfolio
  • Delete Portfolio

Add Portfolio

Request

curl --location 'localhost:8080/api/v2/portfolio/add-portfolio' \
--header 'Content-Type: application/json' \
--data '{
    "name": "Test Portfolio",
    "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
    "currency": "USD"
}'

Response

{
    "portfolio": {
        "id": 1,
        "createdAt": "2025-01-21 14:48:28",
        "name": "Test Portfolio",
        "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
        "currency": "USD",
        "amount": 0,
        "stocks": [],
        "transactions": []
    }
}

Get Portfolio

Request

curl --location --request GET 'localhost:8080/api/v2/portfolio/get-portfolio' \
--header 'Content-Type: application/json' \
--data '{
    "name": "Test Portfolio"
}'

Response

{
    "portfolio": {
        "id": 1,
        "createdAt": "2025-01-21 14:48:28",
        "name": "Test Portfolio",
        "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
        "currency": "USD",
        "amount": 0.0000,
        "stocks": [],
        "transactions": []
    }
}

Delete Portfolio

Request

curl --location --request DELETE 'localhost:8080/api/v2/portfolio/delete-portfolio' \
--header 'Content-Type: application/json' \
--data '{
    "name": "Test Portfolio"
}'

Response

{
    "status": "Portfolio deleted successfully"
}