@@ -20,15 +20,18 @@ private static void test1() throws ExchangeException, PortfolioException {
2020 Sector sector2 = new Sector (SectorType .IT );
2121 Sector sector3 = new Sector (SectorType .HEALTH_CARE );
2222
23- CompanyTicker companyTicker1 = new CompanyTicker ("HDFCBANK" );
23+ Exchange nseExchange = new Exchange ("NSE" );
24+ Exchange nasdaqExchange = new Exchange ("NSE" );
25+
26+ CompanyTicker companyTicker1 = new CompanyTicker ("HDFCBANK" , nseExchange );
2427 Company company1 = new Company ("HDFC Bank" , sector1 , companyTicker1 );
2528 exchangeService .registerCompany (company1 );
2629
27- CompanyTicker companyTicker2 = new CompanyTicker ("MSFT" );
30+ CompanyTicker companyTicker2 = new CompanyTicker ("MSFT" , nasdaqExchange );
2831 Company company2 = new Company ("Microsoft" , sector2 , companyTicker2 );
2932 exchangeService .registerCompany (company2 );
3033
31- CompanyTicker companyTicker3 = new CompanyTicker ("APOLLO" );
34+ CompanyTicker companyTicker3 = new CompanyTicker ("APOLLO" , nseExchange );
3235 Company company3 = new Company ("Apollo" , sector3 , companyTicker3 );
3336 exchangeService .registerCompany (company3 );
3437
@@ -50,6 +53,25 @@ private static void test1() throws ExchangeException, PortfolioException {
5053 AssetType .EQUITY ); // TODO: Check BuyingStrategy
5154 Order order = portfolioService .buy (orderData , user );
5255 System .out .println ("Order placed = " + order );
56+ System .out .println ("Positions when the first BUY order is placed: " + portfolioService .getPositions (AssetType .EQUITY , user ));
57+
58+ System .out .println ("Repeating the same order but with more quantity" );
59+ orderData = new OrderData (company1 ,
60+ new MarketOrderStrategy (
61+ company1 .getCompanyTicker ().getLatestPrice ().getAmount () * 5 , 5 ),
62+ AssetType .EQUITY ); // TODO: Check BuyingStrategy
63+ order = portfolioService .buy (orderData , user );
64+ System .out .println ("Order placed = " + order );
65+ System .out .println ("Positions when the second BUY order is placed: " + portfolioService .getPositions (AssetType .EQUITY , user ));
66+
67+ System .out .println ("Executing a SELL" );
68+ orderData = new OrderData (company1 ,
69+ new MarketOrderStrategy (
70+ company1 .getCompanyTicker ().getLatestPrice ().getAmount () * 2 , 2 ),
71+ AssetType .EQUITY ); // TODO: Check BuyingStrategy
72+ order = portfolioService .sell (orderData , user );
73+ System .out .println ("Order placed = " + order );
74+ System .out .println ("Positions when the first SELL order is placed: " + portfolioService .getPositions (AssetType .EQUITY , user ));
5375
5476 System .out .println ("Holdings when order not executed yet: " + portfolioService .getHoldings (AssetType .EQUITY , user ));
5577
0 commit comments