class_docstr: This analyzer calculates the SharpeRatio of a strategy using a risk free
  asset which is simply an interest rate
  
  See also:
  
    - https://en.wikipedia.org/wiki/Sharpe_ratio
  
  Params:
  
    - ``timeframe``: (default: ``TimeFrame.Years``)
  
    - ``compression`` (default: ``1``)
  
      Only used for sub-day timeframes to for example work on an hourly
      timeframe by specifying "TimeFrame.Minutes" and 60 as compression
  
    - ``riskfreerate`` (default: 0.01 -> 1%)
  
      Expressed in annual terms (see ``convertrate`` below)
  
    - ``convertrate`` (default: ``True``)
  
      Convert the ``riskfreerate`` from annual to monthly, weekly or daily
      rate. Sub-day conversions are not supported
  
    - ``factor`` (default: ``None``)
  
      If ``None``, the conversion factor for the riskfree rate from *annual*
      to the chosen timeframe will be chosen from a predefined table
  
        Days: 252, Weeks: 52, Months: 12, Years: 1
  
      Else the specified value will be used
  
    - ``annualize`` (default: ``False``)
  
      If ``convertrate`` is ``True``, the *SharpeRatio* will be delivered in
      the ``timeframe`` of choice.
  
      In most occasions the SharpeRatio is delivered in annualized form.
      Convert the ``riskfreerate`` from annual to monthly, weekly or daily
      rate. Sub-day conversions are not supported
  
    - ``stddev_sample`` (default: ``False``)
  
      If this is set to ``True`` the *standard deviation* will be calculated
      decreasing the denominator in the mean by ``1``. This is used when
      calculating the *standard deviation* if it's considered that not all
      samples are used for the calculation. This is known as the *Bessels'
      correction*
  
    - ``daysfactor`` (default: ``None``)
  
      Old naming for ``factor``. If set to anything else than ``None`` and
      the ``timeframe`` is ``TimeFrame.Days`` it will be assumed this is old
      code and the value will be used
  
    - ``legacyannual`` (default: ``False``)
  
      Use the ``AnnualReturn`` return analyzer, which as the name implies
      only works on years
  
    - ``fund`` (default: ``None``)
  
      If ``None`` the actual mode of the broker (fundmode - True/False) will
      be autodetected to decide if the returns are based on the total net
      asset value or on the fund value. See ``set_fundmode`` in the broker
      documentation
  
      Set it to ``True`` or ``False`` for a specific behavior
  
  Methods:
  
    - get_analysis
  
      Returns a dictionary with key "sharperatio" holding the ratio
code: def __init__(self):
      if self.p.legacyannual:
          self.anret = AnnualReturn()
      else:
          self.timereturn = TimeReturn(
              timeframe=self.p.timeframe,
              compression=self.p.compression,
              fund=self.p.fund,
          )
  
file_path: backtrader/backtrader/analyzers/sharpe.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import math
  from backtrader.utils.py3 import itervalues
  from backtrader import Analyzer, TimeFrame
  from backtrader.mathsupport import average, standarddev
  from backtrader.analyzers import TimeReturn, AnnualReturn
label_desc: Use image node_id 1 to create a new SharpeRatio object from inherited base classes: Analyzer with example: obj = SharpeRatio()