Skip to content

Stocks-tax-calculation is a Clojure application that simulates the purchase and sale of shares, calculating taxes for each operation. It processes input as JSON via STDIN and outputs results in JSON format via STDOUT. The application uses in-memory data storage and supports Docker for deployment. Testing are automated with Makefile commands.

Notifications You must be signed in to change notification settings

FabsHC/stock-tax-calculation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stock-tax-calculation

WIP Clojure stock-tax-calculation Build & Tests

FYI: The Golang version of this project: capital-gain

This project simulates the purchase and sale of shares. It does not use any database, all data is stored in memory during the execution of a list of operations.

The application will receive a list of operations that it can execute purchase and sale, returning for each operation how much tax was paid. The operations will be in the order in which they occurred, that is, the second operation in the list happened after the first and so on. Each line is an independent simulation, the program will not maintain the state obtained in one line for the others.

Below we have the application input and output data.

Input:

Name Detail
operation Whether the operation is a purchase(buy) or sale(sell) operation
unit-cost Share unit price in a currency with two decimal places
quantity Number of shares traded

Output:

Name Detail
tax Amount of tax paid for the operation performed

In the resources folder we have several examples to run the application. In the CASES.md we are detailing these examples.

Project Organization

├── /src
    └── /stocks
        ├── /models................: Model map functions
        ├── /services..............: Business logic functions
        ├── /util..................: Util functions 
        └── core.clj...............: Main application file
└── /test..........................: Unit tests file

How to run

The application expects data in STDIN format and will return json in STDOUT format. So you can provide a JSON or a file containing several lines with each line having a JSON. Examples below:

  • Direct JSON input
    make run INPUT='[{"operation":"buy", "unit-cost":10.00, "quantity": 100}, {"operation":"sell", "unit-cost":15.00, "quantity": 50}, {"operation":"sell", "unit-cost":15.00, "quantity": 50}]'
  • Reading file
    make run-file FILE=doc/resources/case_1
  • Docker direct input
    WIP 
  • Docker reading file for input
    WIP 

How to run the tests

WIP

Lint and Coverage

WIP

About

Stocks-tax-calculation is a Clojure application that simulates the purchase and sale of shares, calculating taxes for each operation. It processes input as JSON via STDIN and outputs results in JSON format via STDOUT. The application uses in-memory data storage and supports Docker for deployment. Testing are automated with Makefile commands.

Resources

Stars

Watchers

Forks