def max_drawdown(close: Series, method: str = None, all: bool = False) -> float: """Maximum Drawdown from close. Default: 'dollar'. Args: close (pd.Series): Series of 'close's method (str): Max DD calculation options: 'dollar', 'percent', 'log'. Default: 'dollar' all (bool): If True, it returns all three methods as a dict. Default: False >>> result = ta.max_drawdown(close, method="dollar", all=False) """ close = verify_series(close) max_dd = drawdown(close).max() max_dd_ = { "dollar": max_dd.iloc[0], "percent": max_dd.iloc[1], "log": max_dd.iloc[2] } if all: return max_dd_ if isinstance(method, str) and method in max_dd_.keys(): return max_dd_[method] return max_dd_["dollar"]
def max_drawdown(close: Series, method:str = None, all:bool = False) -> float: """Maximum Drawdown from close. Defaults to 'dollar'. """ close = verify_series(close) max_dd = drawdown(close).max() max_dd_ = { "dollar": max_dd.iloc[0], "percent": max_dd.iloc[1], "log": max_dd.iloc[2] } if all: return max_dd_ if isinstance(method, str) and method in max_dd_.keys(): return max_dd_[method] return max_dd_["dollar"]