def calculate_results(sim_params, env, data_portal, splits=None, txns=None, commissions=None):
 txns = (txns or [])
 splits = (splits or {})
 commissions = (commissions or {})
 perf_tracker = perf.PerformanceTracker(sim_params, get_calendar('NYSE'), env)
 results = []
 for date in sim_params.sessions:
  for txn in filter((lambda txn: (txn.dt == date)), txns):
   perf_tracker.process_transaction(txn)
  try:
   commissions_for_date = commissions[date]
   for comm in commissions_for_date:
    perf_tracker.process_commission(comm)
  except KeyError:
   pass
  try:
   splits_for_date = splits[date]
   perf_tracker.handle_splits(splits_for_date)
  except KeyError:
   pass
  msg = perf_tracker.handle_market_close(date, data_portal)
  perf_tracker.position_tracker.sync_last_sale_prices(date, False, data_portal)
  msg['account'] = perf_tracker.get_account(True)
  results.append(copy.deepcopy(msg))
 return results

def calculate_results ( sim_params , env , data_portal , splits = None , txns = None , commissions = None ) : txns = ( txns or [ ] ) splits = ( splits or { } ) commissions = ( commissions or { } ) perf_tracker = perf . PerformanceTracker ( sim_params , get_calendar ( 'NYSE' ) , env ) results = [ ] for date in sim_params . sessions : for txn in filter ( ( lambda txn : ( txn . dt == date ) ) , txns ) : perf_tracker . process_transaction ( txn ) try : commissions_for_date = commissions [ date ] for comm in commissions_for_date : perf_tracker . process_commission ( comm ) except KeyError : pass try : splits_for_date = splits [ date ] perf_tracker . handle_splits ( splits_for_date ) except KeyError : pass msg = perf_tracker . handle_market_close ( date , data_portal ) perf_tracker . position_tracker . sync_last_sale_prices ( date , False , data_portal ) msg [ 'account' ] = perf_tracker . get_account ( True ) results . append ( copy . deepcopy ( msg ) ) return results
run the given events through a stripped down version of the loop in algorithmsimulator .