code: def testBuySellBuy(self):
      posTracker = returns.PositionTracker(broker.IntegerTraits())
      posTracker.buy(1, 10)
      self.assertEqual(posTracker.getAvgPrice(), 10)
      self.assertEqual(posTracker.getPnL(price=9), -1)
      self.assertEqual(posTracker.getPnL(), 0)
      self.assertEqual(posTracker.getPnL(price=10), 0)
      self.assertEqual(posTracker.getPnL(price=11), 1)
      self.assertEqual(posTracker.getReturn(), 0)
      self.assertEqual(posTracker.getReturn(13), 0.3)
  
      # Closing the long position and short selling 1 @ $13.
      # The cost basis for the new position is $13.
      posTracker.sell(2, 13)
      self.assertEqual(posTracker.getAvgPrice(), 13)
      self.assertEqual(posTracker.getPnL(), 3)
      self.assertEqual(round(posTracker.getReturn(), 8), 0.23076923)
  
      posTracker.buy(1, 10)
      self.assertEqual(posTracker.getAvgPrice(), 0)
      self.assertEqual(posTracker.getPnL(), 6)
      self.assertEqual(
          round(posTracker.getReturn(), 9), round(0.46153846153846, 9)
      )
  
imports: import datetime
  from .None import common
  from .None import strategy_test
  from .None import position_test
  from testcases import test_strategy
  from pyalgotrade.barfeed import yahoofeed
  from pyalgotrade.barfeed import csvfeed
  from pyalgotrade.stratanalyzer import returns
  from pyalgotrade import broker
  from pyalgotrade import marketsession
label_desc: Use image node_id 8 for calling the PosTrackerTestCase obj's underlying member method code with example usage: obj.testBuySellBuy() without return types