예제 #1
0
 def get_history_spec(self, bar_count, frequency, field, ffill):
     spec_key = HistorySpec.spec_key(bar_count, frequency, field, ffill)
     if spec_key not in self.history_specs:
         data_freq = self.sim_params.data_frequency
         spec = HistorySpec(
             bar_count,
             frequency,
             field,
             ffill,
             data_frequency=data_freq,
         )
         self.history_specs[spec_key] = spec
         if not self.history_container:
             self.history_container = self.history_container_class(
                 self.history_specs,
                 self.current_universe(),
                 self.datetime,
                 self.sim_params.data_frequency,
                 bar_data=self._most_recent_data,
             )
         self.history_container.ensure_spec(
             spec,
             self.datetime,
             self._most_recent_data,
         )
     return self.history_specs[spec_key]
예제 #2
0
    def add_history(self, bar_count, frequency, field,
                    ffill=True):
        daily_at_midnight = (self.sim_params.data_frequency == 'daily')

        history_spec = HistorySpec(bar_count, frequency, field, ffill,
                                   daily_at_midnight=daily_at_midnight)
        self.history_specs[history_spec.key_str] = history_spec
예제 #3
0
파일: algorithm.py 프로젝트: qnu/zipline
 def get_history_spec(self, bar_count, frequency, field, ffill):
     spec_key = HistorySpec.spec_key(bar_count, frequency, field, ffill)
     if spec_key not in self.history_specs:
         data_freq = self.sim_params.data_frequency
         spec = HistorySpec(
             bar_count,
             frequency,
             field,
             ffill,
             data_frequency=data_freq,
             env=self.trading_environment,
         )
         self.history_specs[spec_key] = spec
         if not self.history_container:
             self.history_container = self.history_container_class(
                 self.history_specs,
                 self.current_universe(),
                 self.datetime,
                 self.sim_params.data_frequency,
                 bar_data=self._most_recent_data,
                 env=self.trading_environment,
             )
         self.history_container.ensure_spec(
             spec, self.datetime, self._most_recent_data,
         )
     return self.history_specs[spec_key]
예제 #4
0
 def add_history(self, bar_count, frequency, field, ffill=True):
     data_frequency = self.sim_params.data_frequency
     history_spec = HistorySpec(bar_count, frequency, field, ffill,
                                data_frequency=data_frequency)
     self.history_specs[history_spec.key_str] = history_spec
     if self.initialized:
         if self.history_container:
             self.history_container.ensure_spec(
                 history_spec, self.datetime, self._most_recent_data,
             )
         else:
             self.history_container = self.history_container_class(
                 self.history_specs,
                 self.current_universe(),
                 self.sim_params.first_open,
                 self.sim_params.data_frequency,
             )
예제 #5
0
 def history(self, bar_count, frequency, field, ffill=True):
     spec_key_str = HistorySpec.spec_key(
         bar_count, frequency, field, ffill)
     history_spec = self.history_specs[spec_key_str]
     return self.history_container.get_history(history_spec, self.datetime)
예제 #6
0
 def history(self, bar_count, frequency, field, ffill=True):
     spec_key_str = HistorySpec.spec_key(
         bar_count, frequency, field, ffill)
     history_spec = self.history_specs[spec_key_str]
     return self.history_container.get_history(history_spec, self.datetime)
예제 #7
0
 def add_history(self, bar_count, frequency, field, ffill=True):
     history_spec = HistorySpec(bar_count, frequency, field, ffill)
     self.history_specs[history_spec.key_str] = history_spec