示例#1
0
文件: stddev.py 项目: pgari/zipline
 def assert_required_fields(self, event):
     """
     We only allow events with a price field to be run through
     the returns transform.
     """
     if 'price' not in event:
         raise WrongDataForTransform(transform="StdDevEventWindow",
                                     fields='price')
示例#2
0
 def assert_required_fields(self, event):
     """
     We only allow events with all of our tracked fields.
     """
     for field in self.fields:
         if field not in event:
             raise WrongDataForTransform(
                 transform="MovingAverageEventWindow", fields=self.fields)
示例#3
0
 def check_required_fields(self, event):
     """
     We only allow events with a price field to be run through
     the returns transform.
     """
     if not hasattr(event, 'price'):
         raise WrongDataForTransform(transform="ReturnsEventWindow",
                                     fields=['price'])
示例#4
0
    def check_required_fields(self, event):
        """
        We only allow events with all of our tracked fields.
        """
        # All events require a 'dt' field.
        if not hasattr(event, 'dt'):
            raise WrongDataForTransform(
                transform=self.__class__.__name__,
                fields=['dt'],
            )

        # Subclasses must implement the 'fields' property to specify other
        # required fields.
        for field in self.fields:
            if field not in event:
                raise WrongDataForTransform(
                    transform=self.__class__.__name__,
                    fields=self.fields,
                )
示例#5
0
文件: vwap.py 项目: zixan/zipline
 def assert_required_fields(self, event):
     if 'price' not in event or 'volume' not in event:
         raise WrongDataForTransform(transform="VWAPEventWindow",
                                     fields=self.fields)
示例#6
0
 def assert_required_fields(self, event):
     for field in self.fields:
         if field not in event:
             raise WrongDataForTransform(
                 transform="VWAPEventWindow",
                 fields=self.fields)