code: def calc_period_stats(pos_stats, ending_cash):
      net_liq = calc_net_liquidation(
          ending_cash, pos_stats.long_value, pos_stats.short_value
      )
      gross_leverage = calc_leverage(pos_stats.gross_exposure, net_liq)
      net_leverage = calc_leverage(pos_stats.net_exposure, net_liq)
  
      return PeriodStats(
          net_liquidation=net_liq,
          gross_leverage=gross_leverage,
          net_leverage=net_leverage,
      )
  
imports: from __future__ import division
  import logbook
  import numpy
  from collections import namedtuple
  from catalyst.assets import Future
  from six import itervalues, iteritems
  import catalyst.protocol
  from catalyst.constants import LOG_LEVEL
label_desc: Use image node_id 3 for calling a global function with example usage: calc_period_stats(pos_stats, ending_cash) and returns: PeriodStats