def __init__(self, index=None, columns=None, ndim=None, freq=None): if index is not None and not isinstance(index, pd.Index): index = pd.Index(index) if columns is not None and not isinstance(columns, pd.Index): columns = pd.Index(columns) self._index = index self._columns = columns self._ndim = ndim self._freq = None if freq is not None: self._freq = freq_delta(freq) elif isinstance(self.index, DatetimeTypes): if self.index.freq is not None: self._freq = freq_delta(self.index.freq) elif self.index.inferred_freq is not None: self._freq = freq_delta(self.index.inferred_freq)
def freq(self): """Index frequency.""" if self._freq is not None: return freq_delta(self._freq) if isinstance(self.index, DatetimeTypes): if self.index.freq is not None: try: return freq_delta(self.index.freq) except ValueError as e: warnings.warn(repr(e)) if self.index.inferred_freq is not None: try: return freq_delta(self.index.inferred_freq) except ValueError as e: warnings.warn(repr(e)) return self._freq
def year_freq(self): """Year frequency.""" from vectorbt import settings year_freq = self._year_freq if year_freq is None: year_freq = settings.returns['year_freq'] return freq_delta(year_freq)
def freq(self): """Index frequency.""" freq = self._freq if freq is None: freq = defaults.array_wrapper['freq'] if freq is not None: return freq_delta(freq) if isinstance(self.index, DatetimeTypes): if self.index.freq is not None: try: return freq_delta(self.index.freq) except ValueError as e: warnings.warn(repr(e)) if self.index.inferred_freq is not None: try: return freq_delta(self.index.inferred_freq) except ValueError as e: warnings.warn(repr(e)) return freq
def freq(self): """Index frequency.""" from vectorbt import settings freq = self._freq if freq is None: freq = settings.array_wrapper['freq'] if freq is not None: return freq_delta(freq) if isinstance(self.index, DatetimeTypes): if self.index.freq is not None: try: return freq_delta(self.index.freq) except ValueError as e: warnings.warn(repr(e), stacklevel=2) if self.index.inferred_freq is not None: try: return freq_delta(self.index.inferred_freq) except ValueError as e: warnings.warn(repr(e), stacklevel=2) return freq
def year_freq(self): """Year frequency.""" year_freq = self._year_freq if year_freq is None: year_freq = defaults.returns['year_freq'] return freq_delta(year_freq)