<commit_before>#
# Copyright 2013 Quantopian, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


import logbook
import math
import numpy as np
import numpy.linalg as la

import zipline.finance.trading as trading

import pandas as pd

from . risk import (
    alpha,
    check_entry,
    choose_treasury,
    information_ratio,
    sharpe_ratio,
    sortino_ratio,
)

log = logbook.Logger('Risk Cumulative')


class RiskMetricsCumulative(object):
    """
    :Usage:
        Instantiate RiskMetricsCumulative once.
        Call update() method on each dt to update the metrics.
    """

    def __init__(self, sim_params):
        self.treasury_curves = trading.environment.treasury_curves
        self.start_date = sim_params.period_start.replace(
            hour=0, minute=0, second=0, microsecond=0
        )
        self.end_date = sim_params.period_end.replace(
            hour=0, minute=0, second=0, microsecond=0
        )

        all_trading_days = trading.environment.trading_days
        mask = ((all_trading_days >= self.start_date) &
                (all_trading_days <= self.end_date))

        self.trading_days = all_trading_days[mask]
        if sim_params.period_end not in self.trading_days:
            last_day = pd.tseries.index.DatetimeIndex(
                [sim_params.period_end]
            )
            self.trading_days = self.trading_days.append(last_day)

        self.sim_params = sim_params

        if sim_params.emission_rate == 'daily':
            self.initialize_daily_indices()
        elif sim_params.emission_rate == 'minute':
            self.initialize_minute_indices(sim_params)

        self.algorithm_returns = None
        self.benchmark_returns = None

        self.compounded_log_returns = []
        self.moving_avg = []

        self.algorithm_volatility = []
        self.benchmark_volatility = []
        self.algorithm_period_returns = []
        self.benchmark_period_returns = []

        self.algorithm_covariance = None
        self.benchmark_variance = None
        self.condition_number = None
        self.eigen_values = None
<commit_msg>MAINT: Remove unused member from cumulative risk metrics.<commit_after>#
# Copyright 2013 Quantopian, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


import logbook
import math
import numpy as np
import numpy.linalg as la

import zipline.finance.trading as trading

import pandas as pd

from . risk import (
    alpha,
    check_entry,
    choose_treasury,
    information_ratio,
    sharpe_ratio,
    sortino_ratio,
)

log = logbook.Logger('Risk Cumulative')


class RiskMetricsCumulative(object):
    """
    :Usage:
        Instantiate RiskMetricsCumulative once.
        Call update() method on each dt to update the metrics.
    """

    def __init__(self, sim_params):
        self.treasury_curves = trading.environment.treasury_curves
        self.start_date = sim_params.period_start.replace(
            hour=0, minute=0, second=0, microsecond=0
        )
        self.end_date = sim_params.period_end.replace(
            hour=0, minute=0, second=0, microsecond=0
        )

        all_trading_days = trading.environment.trading_days
        mask = ((all_trading_days >= self.start_date) &
                (all_trading_days <= self.end_date))

        self.trading_days = all_trading_days[mask]
        if sim_params.period_end not in self.trading_days:
            last_day = pd.tseries.index.DatetimeIndex(
                [sim_params.period_end]
            )
            self.trading_days = self.trading_days.append(last_day)

        self.sim_params = sim_params

        if sim_params.emission_rate == 'daily':
            self.initialize_daily_indices()
        elif sim_params.emission_rate == 'minute':
            self.initialize_minute_indices(sim_params)

        self.algorithm_returns = None
        self.benchmark_returns = None

        self.compounded_log_returns = []

        self.algorithm_volatility = []
        self.benchmark_volatility = []
        self.algorithm_period_returns = []
        self.benchmark_period_returns = []

        self.algorithm_covariance = None
        self.benchmark_variance = None
        self.condition_number = None
        self.eigen_values = None

{'fraction_non_alphanumeric': 0.07814594905190576, 'fraction_numerical': 0.0061290940432867265, 'mean_word_length': 2.7703971119133572, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6796427', 'n_tokens_mistral': 1543, 'n_tokens_neox': 1474, 'n_words': 396}