コード例 #1
0
    def test_should_return_week_working_days(self):
        result = util.range(date(2012, 12, 9), date(2012, 12, 15))
        assert len(result) is 5

        i = 0
        for day in result:
            assert day == datetime(2012, 12, 10 + i)
            i += 1
コード例 #2
0
        def evaluate(self, context, symbol, start=None, end=None):
            df_norm = context.dependencies(source_reference)
            df_index = dateutils.range(start, end, frequency='M')

            result = pandas.DataFrame(columns=df_norm.columns, index=df_index)

            result['open'] = df_norm['open'].resample('M', how='first')
            result['high'] = df_norm['high'].resample('M', how='max')
            result['low'] = df_norm['low'].resample('M', how='min')
            result['close'] = df_norm['close'].resample('M', how='last')
            result['volume'] = df_norm['volume'].resample('M', how='sum')

            return result.dropna()
コード例 #3
0
        def evaluate(self, context, symbol, start=None, end=None):
            df_norm = context.dependencies(source_reference)
            df_index = dateutils.range(start, end, frequency='M')

            result = pandas.DataFrame(columns=df_norm.columns, index=df_index)

            result['open'] = df_norm['open'].resample('M', how='first')
            result['high'] = df_norm['high'].resample('M', how='max')
            result['low'] = df_norm['low'].resample('M', how='min')
            result['close'] = df_norm['close'].resample('M', how='last')
            result['volume'] = df_norm['volume'].resample('M', how='sum')

            return result.dropna()
コード例 #4
0
        def evaluate(self, context, symbol, start=None, end=None):
            df_split = context.dependencies(source_reference)
            df_normalization = pandas.DataFrame(index=dateutils.range(start, end))

            for column in ['open', 'high', 'low', 'close']:
                df_normalization[column] = 1

            for i in range(len(df_split)):
                row = df_split.ix[i]
                day = dateutils.relative_working_day(-1, row.name)
                df_normalization.update(df_normalization[:day] * row['factor'])
            df_normalization['volume'] = 1 / df_normalization['close']

            return df_normalization
コード例 #5
0
 def test_return_should_be_list_of_date_instances(self):
     result = util.range()
     assert isinstance(result[-1], date)
コード例 #6
0
 def test_should_use_config_start_date_til_today_when_no_arg_is_pased(self):
     result = util.range()
     assert result[0].date() == util.next_working_day(config.START_DATE)
     assert result[-1].date() == util.last_working_day()
コード例 #7
0
 def test_should_use_today_date_when_argument_is_not_pased(self):
     result = util.range()
     assert result[-1].date() == util.last_working_day()
コード例 #8
0
 def test_should_use_config_start_date_when_argument_is_not_pased(self):
     result = util.range()
     assert result[0].date() == util.next_working_day(config.START_DATE)
コード例 #9
0
 def test_should_return_only_working_days(self):
     result = util.range(date(2012, 11, 29), date(2012, 12, 3))
     assert len(result) is 3
     assert result[0] == datetime(2012, 11, 29)
     assert result[1] == datetime(2012, 11, 30)
     assert result[2] == datetime(2012, 12, 03)