code: def iter_txns(trds):
      
      pos = 0
      for trd in trds:
          if pos != 0 and is_decrease(pos, trd.qty) and crosses_zero(pos, trd.qty):
              # Split to make accounting for long/short possible
              closing_trd, opening_trd = trd.split(-pos)
              # setattr(closing_trd, '_txn_id', 1)
              # setattr(opening_trd, '_txn_id', 2)
              yield closing_trd
              pos = opening_trd.qty
              yield opening_trd
          else:
              pos += trd.qty
              yield trd
docs: iterator of trades which splits trades to ensure proper long/short accounting