'The purpose of this method is to provide a portfolio
object to algorithms running inside the same trading
client. The data needed is captured raw in a
PerformancePeriod, and in this method we rename some
fields for usability and remove extraneous fields.'

def as_portfolio(self):

    portfolio = self._portfolio_store
    portfolio.capital_used = self.cash_flow
    portfolio.starting_cash = self.starting_cash
    portfolio.portfolio_value = (self.ending_cash + self.ending_value)
    portfolio.pnl = self.pnl
    portfolio.returns = self.returns
    portfolio.cash = self.ending_cash
    portfolio.start_date = self.period_open
    portfolio.positions = self.position_tracker.get_positions()
    portfolio.positions_value = self.ending_value
    portfolio.positions_exposure = self.ending_exposure
    return portfolio
