'After the subsequent purchase, carry out two more buys/longs
and then close the position out with two additional sells/shorts.
The following prices have been tested against those calculated
via Interactive Brokers\' Trader Workstation (TWS).'

def test_calculate_round_trip(self):

    self.position.transact_shares('BOT', 100, PriceParser.parse(74.63), PriceParser.parse(1.0))
    self.position.transact_shares('BOT', 250, PriceParser.parse(74.62), PriceParser.parse(1.25))
    self.position.transact_shares('SLD', 200, PriceParser.parse(74.58), PriceParser.parse(1.0))
    self.position.transact_shares('SLD', 250, PriceParser.parse(75.26), PriceParser.parse(1.25))
    self.position.update_market_value(PriceParser.parse(77.75), PriceParser.parse(77.77))
    self.assertEqual(self.position.action, 'BOT')
    self.assertEqual(self.position.ticker, 'XOM')
    self.assertEqual(self.position.quantity, 0)
    self.assertEqual(self.position.buys, 450)
    self.assertEqual(self.position.sells, 450)
    self.assertEqual(self.position.net, 0)
    self.assertEqual(PriceParser.display(self.position.avg_bot, 5), 74.65778)
    self.assertEqual(PriceParser.display(self.position.avg_sld, 5), 74.95778)
    self.assertEqual(PriceParser.display(self.position.total_bot), 33596.0)
    self.assertEqual(PriceParser.display(self.position.total_sld), 33731.0)
    self.assertEqual(PriceParser.display(self.position.net_total), 135.0)
    self.assertEqual(PriceParser.display(self.position.total_commission), 5.5)
    self.assertEqual(PriceParser.display(self.position.net_incl_comm), 129.5)
    self.assertEqual(PriceParser.display(self.position.avg_price, 3), 74.665)
    self.assertEqual(PriceParser.display(self.position.cost_basis), 0.0)
    self.assertEqual(PriceParser.display(self.position.market_value), 0.0)
    self.assertEqual(PriceParser.display(self.position.unrealised_pnl), 0.0)
    self.assertEqual(PriceParser.display(self.position.realised_pnl), 129.5)
