code: def maybe_create_close_position_transaction(
      self, asset, dt, data_portal
  ):
      if not self.positions.get(asset):
          return None
  
      amount = self.positions.get(asset).amount
      price = data_portal.get_spot_value(
          asset, "price", dt, self.data_frequency
      )
  
      # Get the last traded price if price is no longer available
      if isnan(price):
          price = self.positions.get(asset).last_sale_price
  
      txn = Transaction(
          asset=asset,
          amount=(-1 * amount),
          dt=dt,
          price=price,
          commission=0,
          order_id=None,
      )
      return txn
  
imports: from __future__ import division
  import logbook
  import numpy
  from collections import namedtuple
  from math import isnan
  from six import iteritems, itervalues
  from catalyst.finance.performance.position import Position
  from catalyst.finance.transaction import Transaction
  from catalyst.utils.input_validation import expect_types
  import catalyst.protocol
  from catalyst.assets import Future, Asset
  from .position import positiondict
  from catalyst.constants import LOG_LEVEL
label_desc: Use image node_id 8 for calling the PositionTracker obj's underlying member method code with example usage: obj.maybe_create_close_position_transaction(asset, dt, data_portal) and returns: txn, None