bt_data = svix_df.copy()
bt_data.set_index('Date', inplace=True)
bt_data.index = pd.to_datetime(bt_data.index)
bt_data.index = pd.to_datetime(bt_data.index, format="%Y%m%d")
def ulcer_index(returns, N=None, boundary=None):
    if returns is None or len(returns) == 0:
        return 1e-8
    if N is not None:
        returns = returns[-N:]
    prices = (1 + returns).cumprod()
    running_max = np.maximum.accumulate(prices)
    drawdowns = (prices - running_max) / running_max
    if boundary is not None:
        drawdowns = np.where(drawdowns <= -boundary, boundary * (drawdowns / boundary) ** 2, drawdowns)
    ui = np.sqrt((drawdowns**2).mean())
    if ui <= 0:  # Handle zero or negative Ulcer Index
        return 1e-8
    uncompounded_cumulative_returns = returns.sum()
    upi = uncompounded_cumulative_returns / ui
    return upi
def NAME_1_index(returns):
    if returns is None or len(returns) == 0:
        return 1e-8
    wins = returns > 0
    losses = returns < 0
    p_right = wins.sum() / len(returns)
    p_wrong = losses.sum() / len(returns)
    avg_win = 1e-8 if p_right == 1 else wins.mean()
    avg_loss = 1e-8 if p_wrong == 1 else losses.mean()
    NAME_1 = p_right - (p_wrong / ((avg_win + 1e-8) / np.abs(avg_loss + 1e-8)))
    temp = returns.cumsum().cummax()
    # Create a dictionary mapping each unique value in temp to its first index
    first_indices = {value: idx for idx, value in temp.drop_duplicates().items()}
    # Use the dictionary to create a new series with the same index as temp
    first_indices_series = pd.Series([first_indices.get(x, 1e-8) for x in temp], index=temp.index)
    avg_dd = first_indices_series.diff().replace(0, 1e-8).dropna().mean()
    return NAME_1/avg_dd
log=[]
class BrokerObserver(bt.Observer):
    lines = ('value', 'pct_change', 'ulcer_index', 'NAME_1_index', 'NAME_1_upi')
    plotinfo = dict(plot=True, subplot=True)
    def __init__(self):
        self.portfolio_values = pd.Series(dtype=float)  # Store portfolio values as pandas Series
        self.returns = pd.Series(dtype=float)  # Store returns as pandas Series
    def start(self):
        self.plotlines.value._name = 'Portfolio Value'
        self.plotlines.pct_change._name = 'Percentage Change'
        self.plotlines.ulcer_index._name = 'Ulcer Index'
        self.plotlines.NAME_1_index._name = 'NAME_1 Index'
        self.plotlines.NAME_1_upi._name = 'Kel*UPI'
        self.ulcer_index_values = []
        self.NAME_1_index_values = []
        self.NAME_1_upi_values = []
    def next(self):
        value = self._owner.broker.getval Write exactly 7 paragraphs each separated with two new lines answering this question. The 6th paragraph must start with "victim".
user