Solution is developed in the Visual Studio 2015. In addition to using C# .Net, Following frameworks are used.
- NUnit 3
- Moq
- FluentAssertion
This solution contains three projects
. README file is in the Solution Items folder.
- JPMorgan.SuperSimpleStocks.Domain
Project contains domain logic classes to implement the requirenments. - JPMorgan.SuperSimpleStocks.Domain.UnitTest
Unit test project for theDomain
project classes. To run these unit tests NUnit Test Adapter 3.6 is required which can be added to the visual studio. - JPMorgan.SuperSimpleStocks.GBCExchangeApi
This is a basic api for providing interface to run all the required methods. You can use web browser or any application like postman to call methods in this webapi. Postman can be downloaded or added as chrome extension.
-
Repositories:
This project folder contains classes for Repository pattern, which is used for storing stocks and trades in memory. If in future we need to record in a file or database we can extendIStockRespository
andITradeRespository
interfaces. -
Stock:
Project folder contains classes for Stocks. Stock is an Abstract class which implementsIStock
interface, it contains PERatio method. ClassesStockCommon
andStockPreferred
are derived from this abstract class.
These derived classes then implements DividendYield abstract method by overriding the base class abstract method with using respective dividend yield formula for preferred and common stock. -
Trade
Project folder contains ITrade interface and its implementation Trade class which contains properties to describe trade. This class contains no method as use cases didn't identified any.
MethodVolumeWeightedStockPrice
seems more suitable to put outside in a service class calledTrading
. -
StockExchange
This class is more like aservice class
which have following public methods.
AddStock
GetDividendYield
GetPERatio
GetAllShareIndex
- Trading
This class is also more like aservice class
which have following public methods.
AddTrade
GetVolumeWeightedStockPrice (By default price is based on trades in past 15 minutes.)
- Validation This class contains methods for validation, throws exceptions if valid parameters is not passed to the method in which these validation methods are being called.
- Enums This contains enum for TradeType.