# Path: alephnull/gens/utils.py
# def hash_args(*args, **kwargs):
#     """Define a unique string for any set of representable args."""
#     arg_string = '_'.join([str(arg) for arg in args])
#     kwarg_string = '_'.join([str(key) + '=' + str(value)
#                              for key, value in kwargs.iteritems()])
#     combined = ':'.join([arg_string, kwarg_string])
# 
#     hasher = md5()
#     hasher.update(combined)
#     return hasher.hexdigest()
# 
# Path: alephnull/sources/data_source.py
# class DataSource(object):
# 
#     __metaclass__ = ABCMeta
# 
#     @property
#     def event_type(self):
#         return DATASOURCE_TYPE.TRADE
# 
#     @property
#     def mapping(self):
#         """
#         Mappings of the form:
#         target_key: (mapping_function, source_key)
#         """
#         return {}
# 
#     @abstractproperty
#     def raw_data(self):
#         """
#         An iterator that yields the raw datasource,
#         in chronological order of data, one event at a time.
#         """
#         NotImplemented
# 
#     @abstractproperty
#     def instance_hash(self):
#         """
#         A hash that represents the unique args to the source.
#         """
#         pass
# 
#     def get_hash(self):
#         return self.__class__.__name__ + "-" + self.instance_hash
# 
#     def apply_mapping(self, raw_row):
#         """
#         Override this to hand craft conversion of row.
#         """
#         row = {target: mapping_func(raw_row[source_key])
#                for target, (mapping_func, source_key)
#                in self.mapping.items()}
#         row.update({'source_id': self.get_hash()})
#         row.update({'type': self.event_type})
#         return row
# 
#     @property
#     def mapped_data(self):
#         for row in self.raw_data:
#             yield Event(self.apply_mapping(row))
# 
#     def __iter__(self):
#         return self
# 
#     def next(self):
#         return self.mapped_data.next()


import pandas as pd
from alephnull.gens.utils import hash_args
from alephnull.sources.data_source import DataSource
        return {
            'dt': (lambda x: x, 'dt'),
            'sid': (lambda x: x, 'sid'),
            'price': (float, 'price'),
            'volume': (int, 'volume'),
        }

    @property
    def instance_hash(self):
        return self.arg_string

    def raw_data_gen(self):
        for dt, series in self.data.iterrows():
            for sid, price in series.iterkv():
                if sid in self.sids:
                    event = {
                        'dt': dt,
                        'sid': sid,
                        'price': price,
                        'volume': 1000,
                    }
                    yield event

    @property
    def raw_data(self):
        if not self._raw_data:
            self._raw_data = self.raw_data_gen()
        return self._raw_data



# Path: alephnull/gens/utils.py
# def hash_args(*args, **kwargs):
#     """Define a unique string for any set of representable args."""
#     arg_string = '_'.join([str(arg) for arg in args])
#     kwarg_string = '_'.join([str(key) + '=' + str(value)
#                              for key, value in kwargs.iteritems()])
#     combined = ':'.join([arg_string, kwarg_string])
# 
#     hasher = md5()
#     hasher.update(combined)
#     return hasher.hexdigest()
# 
# Path: alephnull/sources/data_source.py
# class DataSource(object):
# 
#     __metaclass__ = ABCMeta
# 
#     @property
#     def event_type(self):
#         return DATASOURCE_TYPE.TRADE
# 
#     @property
#     def mapping(self):
#         """
#         Mappings of the form:
#         target_key: (mapping_function, source_key)
#         """
#         return {}
# 
#     @abstractproperty
#     def raw_data(self):
#         """
#         An iterator that yields the raw datasource,
#         in chronological order of data, one event at a time.
#         """
#         NotImplemented
# 
#     @abstractproperty
#     def instance_hash(self):
#         """
#         A hash that represents the unique args to the source.
#         """
#         pass
# 
#     def get_hash(self):
#         return self.__class__.__name__ + "-" + self.instance_hash
# 
#     def apply_mapping(self, raw_row):
#         """
#         Override this to hand craft conversion of row.
#         """
#         row = {target: mapping_func(raw_row[source_key])
#                for target, (mapping_func, source_key)
#                in self.mapping.items()}
#         row.update({'source_id': self.get_hash()})
#         row.update({'type': self.event_type})
#         return row
# 
#     @property
#     def mapped_data(self):
#         for row in self.raw_data:
#             yield Event(self.apply_mapping(row))
# 
#     def __iter__(self):
#         return self
# 
#     def next(self):
#         return self.mapped_data.next()


# Path: alephnull/sources/data_frame_source.py
import pandas as pd
from alephnull.gens.utils import hash_args
from alephnull.sources.data_source import DataSource

        return {
            'dt': (lambda x: x, 'dt'),
            'sid': (lambda x: x, 'sid'),
            'price': (float, 'price'),
            'volume': (int, 'volume'),
        }

    @property
    def instance_hash(self):
        return self.arg_string

    def raw_data_gen(self):
        for dt, series in self.data.iterrows():
            for sid, price in series.iterkv():
                if sid in self.sids:
                    event = {
                        'dt': dt,
                        'sid': sid,
                        'price': price,
                        'volume': 1000,
                    }
                    yield event

    @property
    def raw_data(self):
        if not self._raw_data:
            self._raw_data = self.raw_data_gen()
        return self._raw_data



class DataPanelSource(DataSource):