home-broker-system

module
v0.0.0-...-17a13fa Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2023 License: MIT

README

Home Broker Algorithm - Microservice

A Home Broker algorithm for Investment Brokers, developed with Go.

Report Bugs  •  Actions  •  Pull Requests

 

home_broker_flowchart

An algorithm intended for share purchase and sale operations in a Home Broker environment. The application was built on a microservices architecture, using Go and Kafka, which is adopted as a messaging system, where purchase and sale orders are produced on a specific topic. The algorithm, in turn, consumes these orders, processes them and, when there is a match, produces the resulting transaction in another topic. all encapsulated in Docker containers with the advantage of easy access to Confluent's Control Center for monitoring and managing Kafka.

 

Built With

Tech Tools

Table of Contents
  1. Getting Started
  2. License
  3. Contact

 

Getting Started

To get started, You need to have Go 1.21+ installed on your machine, for more information visit Go Downloads. You also need to have Docker Desktop installed, for more information visit Docker Desktop Install.

OBS: This guide is designed to run this project locally (Local Development), on Linux-based systems.

Installation

  1. Clone the repository.
git clone https://github.com/caard0s0/home-broker-system.git

Usage

After completing the installation, you can run the project.

  1. Create and run the Containers.

    docker compose up -d
    
  2. Open a browser tab at localhost:9021 to access your Cluster in the Confluent Control Center.

    cluster_control_center

  3. Opening your terminal at the root of the application, run the project.

    go run cmd/main.go
    
  4. Create a new Topic.

    WARNING: The Topic name must be exactly as written in the image.

    new_topic

  5. Create two new messages (one at a time) using the data below, to generate a New Match and consequently a Transaction.

    {
        "order_id": 1,
        "investor_id": 1,
        "stock_id": "Stock1",
        "current_shares": 10,
        "shares": 10,
        "price": 10,
        "order_type": "BUY"
    }
    
    {
        "order_id": 2,
        "investor_id": 2,
        "stock_id": "Stock1",
        "current_shares": 10,
        "shares": 10,
        "price": 10,
        "order_type": "SELL"
    }
    

    create_message

  6. Opening your terminal, you will see the result of the transaction exactly as it is below.

    OBS: You can also see the result in your Cluster.

    {
        "order_id": 1,
        "investor_id": 1,
        "stock_id": "Stock1",
        "order_type": "BUY",
        "status": "CLOSED",
        "partial": 0,
        "shares": 10,
        "transactions": [
            {
                "transaction_id": "324cb1a1-e73d-4deb-99bc-bf1440907412",
                "buyer_id": 1,
                "seller_id": 2,
                "stock_id": "Stock1",
                "price": 10,
                "shares": 10
            }
        ]
    }
    {
        "order_id": 2,
        "investor_id": 2,
        "stock_id": "Stock1",
        "order_type": "SELL",
        "status": "CLOSED",
        "partial": 0,
        "shares": 10,
        "transactions": [
            {
                "transaction_id": "324cb1a1-e73d-4deb-99bc-bf1440907412",
                "buyer_id": 1,
                "seller_id": 2,
                "stock_id": "Stock1",
                "price": 10,
                "shares": 10
            }
        ]
    }
    

Tests

To be able to run all the tests, follow the command below.

  1. Run all the Tests.
go test -v -cover ./...

License

This project is being distributed under the MIT License, see LICENSE.txt for more information.


Contact

  • Software Engineer
  • Vinicius Cardoso - Email

↑ back to top

Directories

Path Synopsis
internal
dto

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL