Coder Social home page Coder Social logo

fx-market-price-api's Introduction

FX Market Price Handler API

Overview

This API was created with the assumption it would be linked up with a user interface for users to retrieve only the latest prices of selected instruments/currencies from a Foreign Exchange price feed and to be able to store them to access later. This API parses CSV data of various prices and modifies them accordingly by adding a margin adjustment to the bid prices and ask prices.

This was created using the following tech stack:

  • Java
  • Spring Boot
  • Maven
  • MySQL
  • JUnit
  • Postman

    Process

  • Following the Model-View-Controller (MVC) design pattern I separated my methods into a Price Class, PriceController, PriceService and PriceRepository.
  • In the PriceService I have a methods that parse CSV data of various currencies/instruments into Price objects and adjusts incoming prices with a commission. The commission is as follows:(-0.1% for bid price, +0.1% for ask price) All prices are rounded up to 4 decimal places.
  • The PriceController uses different REST endpoints to retrieve only the latest price according to each instrument name.

  • The API is designed so via a user interface, a user can save selected prices to a database to access again later using a PriceRepository.

    Testing

    I created separate test files for the PriceController and PriceService
    I attempted to use Mockito as part of my testing process, but this created many errors. Mockito appears to be used with dummy/mock data, but in this case I already had data to use and test. Due to time constraints I removed my Mockito code to keep my code clean, and chose to do continue my unit tests in JUnit. Unit Testing was done with JUnit to test the following cases:

  • That prices are being processed in sequence and none are missing
  • That only the latest price for a given instrument is stored (and client can not see older prices)
  • Each price is validated to ensure that bid < ask and that the commission has been applied correctly

    Integration Testing done with Postman to ensure that all REST endpoints worked effectively.


    Proposed strategy for E2E testing:
    For E2E automation testing I think Mockito and Postman would be ideal test automation frameworks to use. Mockito can be used to automate all unit tests with mock data and mock objects. Postman can be used to automate the integration testing of the API so that removes the task of always manually refreshing Postman each time the API is altered. With API testing we need to analyze certain factors when sending the request and retrieving a response, such as data accuracy, HTTP status codes, response times, error codes in case the API returns any errors, and authorization checks. Spring Boot itself also the option to integrate Selenium for automation testing. Selenium is primarily used for web automation so this would be used when the entire FX trading application has been fully completed with both the API and the frontend user interface.

    Possible Improvements
    I would have liked to use Mockito effectively for my unit testing and would have liked to make my API more RESTful, to effectively handle responses, requests and any errors with HTTP status codes.

  • fx-market-price-api's People

    Contributors

    kirstytheproud avatar

    Stargazers

    Roman avatar

    Watchers

     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.