Max Drawdown

A maximum drawdown (MDD) is the maximum observed loss from a peak to a trough of a portfolio before a new peak is attained. Maximum drawdown is an indicator of downside risk over a specified time period. (Source: Investopedia)
from empyrial import empyrial, Engine
portfolio = Engine(
start_date = "2018-01-01",
portfolio= ["BABA", "PDD", "KO", "AMD","^IXIC"],
risk_manager = {"Max Drawdown" : -0.2} #Stop the investment when the drawdown becomes superior to -20%