Hi, I want to implement a risk management function but it seems with ou without my algo is returning the same stats.So I would like to know what doesn't work in my implementation.

Thank You

class MaximumDrawdownPercentPortfolio(RiskManagementModel):

def __init__(self, maximumDrawdownPercent = 0.15, isTrailing = False):

self.maximumDrawdownPercent = -abs(maximumDrawdownPercent)
self.isTrailing = isTrailing
self.initialised = False
self.portfolioHigh = 0;

def ManageRisk(self, algorithm, targets):

currentValue = algorithm.Portfolio.TotalPortfolioValue

if not self.initialised:
self.portfolioHigh = currentValue # Set initial portfolio value
self.initialised = True

# Update trailing high value if in trailing mode
if self.isTrailing and self.portfolioHigh < currentValue:
self.portfolioHigh = currentValue
return [] # return if new high reached

pnl = self.GetTotalDrawdownPercent(currentValue)
if pnl < self.maximumDrawdownPercent:
return self.Liquidate()

return []

def GetTotalDrawdownPercent(self, currentValue):
return (float(currentValue) / float(self.portfolioHigh)) - 1.0