def test_GBCE_calculation(self): market1 = Market() stock1 = Stock("GOOG") stock2 = Stock("APPL") market1.add_stock_to_market(stock1) market1.add_stock_to_market(stock2) stock1.add_transaction('buy', 10, 100) stock2.add_transaction('buy', 10, 100) s1_price = stock1.price() s2_price = stock2.price() no_of_stocks = len(market1.list_stocks()) asi = (s1_price*s2_price)**(1/no_of_stocks) self.assertEqual(market1.all_share_index(), asi)
def test_GBCE_calculation(self): market1 = Market() stock1 = Stock("GOOG") stock2 = Stock("APPL") market1.add_stock_to_market(stock1) market1.add_stock_to_market(stock2) stock1.add_transaction('buy', 10, 100) stock2.add_transaction('buy', 10, 100) s1_price = stock1.price() s2_price = stock2.price() no_of_stocks = len(market1.list_stocks()) asi = (s1_price * s2_price)**(1 / no_of_stocks) self.assertEqual(market1.all_share_index(), asi)
def test_calculate_stock_price(self): stock1 = Stock("GOOG") stock1.add_transaction('buy', 10, 100) stock1.add_transaction('buy', 10, 100) stock_price = ((10*100)+(10*100))/(100+100.) self.assertEqual(stock1.price(), stock_price)
def test_calculate_stock_price(self): stock1 = Stock("GOOG") stock1.add_transaction('buy', 10, 100) stock1.add_transaction('buy', 10, 100) stock_price = ((10 * 100) + (10 * 100)) / (100 + 100.) self.assertEqual(stock1.price(), stock_price)