class_docstr: The ledger tracks all orders and transactions as well as the current
  state of the portfolio and positions.
  
  Attributes
  ----------
  portfolio : zipline.protocol.Portfolio
      The updated portfolio being managed.
  account : zipline.protocol.Account
      The updated account being managed.
  position_tracker : PositionTracker
      The current set of positions.
  todays_returns : float
      The current day's returns. In minute emission mode, this is the partial
      day's returns. In daily emission mode, this is
      ``daily_returns[session]``.
  daily_returns_series : pd.Series
      The daily returns series. Days that have not yet finished will hold
      a value of ``np.nan``.
  daily_returns_array : np.ndarray
      The daily returns as an ndarray. Days that have not yet finished will
      hold a value of ``np.nan``.
class_docstr_tok: ["The","ledger","tracks","all","orders","and","transactions","as","well","as","the","current","state","of","the","portfolio","and","positions",".","Attributes","--","--","--","--","--","portfolio",":","zipline.protocol.Portfolio","The","updated","portfolio","being","managed",".","account",":","zipline.protocol.Account","The","updated","account","being","managed",".","position_tracker",":","PositionTracker","The","current","set","of","positions",".","todays_returns",":","float","The","current","day","'s","returns",".","In","minute","emission","mode",",","this","is","the","partial","day","'s","returns",".","In","daily","emission","mode",",","this","is","``","daily_returns","[","session","]","``",".","daily_returns_series",":","pd.Series","The","daily","returns","series",".","Days","that","have","not","yet","finished","will","hold","a","value","of","``","np.nan","``",".","daily_returns_array",":","np.ndarray","The","daily","returns","as","an","ndarray",".","Days","that","have","not","yet","finished","will","hold","a","value","of","``","np.nan","``","."]
code: def __init__(self, trading_sessions, capital_base, data_frequency):
      if len(trading_sessions):
          start = trading_sessions[0]
      else:
          start = None
  
      # Have some fields of the portfolio changed? This should be accessed
      # through ``self._dirty_portfolio``
      self.__dirty_portfolio = False
      self._immutable_portfolio = zp.Portfolio(start, capital_base)
      self._portfolio = zp.MutableView(self._immutable_portfolio)
  
      self.daily_returns_series = pd.Series(
          np.nan,
          index=trading_sessions,
      )
      # Get a view into the storage of the returns series. Metrics
      # can access this directly in minute mode for performance reasons.
      self.daily_returns_array = self.daily_returns_series.values
  
      self._previous_total_returns = 0
  
      # this is a component of the cache key for the account
      self._position_stats = None
  
      # Have some fields of the account changed?
      self._dirty_account = True
      self._immutable_account = zp.Account()
      self._account = zp.MutableView(self._immutable_account)
  
      # The broker blotter can override some fields on the account. This is
      # way to tangled up at the moment but we aren't fixing it today.
      self._account_overrides = {}
  
      self.position_tracker = PositionTracker(data_frequency)
  
      self._processed_transactions = {}
  
      self._orders_by_modified = {}
      self._orders_by_id = OrderedDict()
  
      # Keyed by asset, the previous last sale price of positions with
      # payouts on price differences, e.g. Futures.
      #
      # This dt is not the previous minute to the minute for which the
      # calculation is done, but the last sale price either before the period
      # start, or when the price at execution.
      self._payout_last_sale_prices = {}
  
imports: from __future__ import division
  from collections import namedtuple, OrderedDict
  from functools import partial
  from math import isnan
  import logbook
  import numpy
  import pandas
  from six import iteritems, itervalues, PY2
  from zipline.assets import Future
  from zipline.finance.transaction import Transaction
  import zipline.protocol
  from zipline.utils.sentinel import sentinel
  from .position import Position
  from ._finance_ext import PositionStats, calculate_position_tracker_stats, update_position_last_sale_prices
label_desc: Use image node_id 1 to create a new Ledger object from inherited base classes: object with example: obj = Ledger(trading_sessions, capital_base, data_frequency)