code: def return_on_initial_capital(capital, period_pl, leverage=None):
      
      if capital <= 0:
          raise ValueError('cost must be a positive number not %s' % capital)
      leverage = leverage or 1.
      eod = capital + (leverage * period_pl.cumsum())
      ltd_rets = (eod / capital) - 1.
      dly_rets = ltd_rets
      dly_rets.iloc[1:] = (1. + ltd_rets).pct_change().iloc[1:]
      return dly_rets
docs: Return the daily return series based on the capital