We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Support for nans in input data
If a ticker hasn't started trading yet, pandas' convention is to use nans. Currently it seems as if zipline raises an exception if there are nans in the input data. This should be fixed and the corresponding ticker to should not be included if it hasn't started trading yet.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `zipline/sources/data_frame_source.py`
Content:
```
1 
2 #
3 # Copyright 2013 Quantopian, Inc.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 
17 """
18 Tools to generate data sources.
19 """
20 import pandas as pd
21 
22 from zipline.gens.utils import hash_args
23 
24 from zipline.sources.data_source import DataSource
25 
26 
27 class DataFrameSource(DataSource):
28     """
29     Yields all events in event_list that match the given sid_filter.
30     If no event_list is specified, generates an internal stream of events
31     to filter.  Returns all events if filter is None.
32 
33     Configuration options:
34 
35     sids   : list of values representing simulated internal sids
36     start  : start date
37     delta  : timedelta between internal events
38     filter : filter to remove the sids
39     """
40 
41     def __init__(self, data, **kwargs):
42         assert isinstance(data.index, pd.tseries.index.DatetimeIndex)
43 
44         self.data = data
45         # Unpack config dictionary with default values.
46         self.sids = kwargs.get('sids', data.columns)
47         self.start = kwargs.get('start', data.index[0])
48         self.end = kwargs.get('end', data.index[-1])
49 
50         # Hash_value for downstream sorting.
51         self.arg_string = hash_args(data, **kwargs)
52 
53         self._raw_data = None
54 
55     @property
56     def mapping(self):
57         return {
58             'dt': (lambda x: x, 'dt'),
59             'sid': (lambda x: x, 'sid'),
60             'price': (float, 'price'),
61             'volume': (int, 'volume'),
62         }
63 
64     @property
65     def instance_hash(self):
66         return self.arg_string
67 
68     def raw_data_gen(self):
69         for dt, series in self.data.iterrows():
70             for sid, price in series.iteritems():
71                 if sid in self.sids:
72                     event = {
73                         'dt': dt,
74                         'sid': sid,
75                         'price': price,
76                         # Just chose something large
77                         # if no volume available.
78                         'volume': 1e9,
79                     }
80                     yield event
81 
82     @property
83     def raw_data(self):
84         if not self._raw_data:
85             self._raw_data = self.raw_data_gen()
86         return self._raw_data
87 
88 
89 class DataPanelSource(DataSource):
90     """
91     Yields all events in event_list that match the given sid_filter.
92     If no event_list is specified, generates an internal stream of events
93     to filter.  Returns all events if filter is None.
94 
95     Configuration options:
96 
97     sids   : list of values representing simulated internal sids
98     start  : start date
99     delta  : timedelta between internal events
100     filter : filter to remove the sids
101     """
102 
103     def __init__(self, data, **kwargs):
104         assert isinstance(data.major_axis, pd.tseries.index.DatetimeIndex)
105 
106         self.data = data
107         # Unpack config dictionary with default values.
108         self.sids = kwargs.get('sids', data.items)
109         self.start = kwargs.get('start', data.major_axis[0])
110         self.end = kwargs.get('end', data.major_axis[-1])
111 
112         # Hash_value for downstream sorting.
113         self.arg_string = hash_args(data, **kwargs)
114 
115         self._raw_data = None
116 
117     @property
118     def mapping(self):
119         mapping = {
120             'dt': (lambda x: x, 'dt'),
121             'sid': (lambda x: x, 'sid'),
122             'price': (float, 'price'),
123             'volume': (int, 'volume'),
124         }
125 
126         # Add additional fields.
127         for field_name in self.data.minor_axis:
128             if field_name in ['price', 'volume', 'dt', 'sid']:
129                 continue
130             mapping[field_name] = (lambda x: x, field_name)
131 
132         return mapping
133 
134     @property
135     def instance_hash(self):
136         return self.arg_string
137 
138     def raw_data_gen(self):
139         for dt in self.data.major_axis:
140             df = self.data.major_xs(dt)
141             for sid, series in df.iteritems():
142                 if sid in self.sids:
143                     event = {
144                         'dt': dt,
145                         'sid': sid,
146                     }
147                     for field_name, value in series.iteritems():
148                         event[field_name] = value
149 
150                     yield event
151 
152     @property
153     def raw_data(self):
154         if not self._raw_data:
155             self._raw_data = self.raw_data_gen()
156         return self._raw_data
157
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/zipline/sources/data_frame_source.py b/zipline/sources/data_frame_source.py
--- a/zipline/sources/data_frame_source.py
+++ b/zipline/sources/data_frame_source.py
@@ -1,6 +1,5 @@
-
 #
-# Copyright 2013 Quantopian, Inc.
+# Copyright 2015 Quantopian, Inc.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -17,6 +16,7 @@
 """
 Tools to generate data sources.
 """
+import numpy as np
 import pandas as pd
 
 from zipline.gens.utils import hash_args
@@ -26,16 +26,14 @@
 
 class DataFrameSource(DataSource):
     """
-    Yields all events in event_list that match the given sid_filter.
-    If no event_list is specified, generates an internal stream of events
-    to filter.  Returns all events if filter is None.
+    Data source that yields from a pandas DataFrame.
 
-    Configuration options:
+    :Axis layout:
+        * columns : sids
+        * index : datetime
 
-    sids   : list of values representing simulated internal sids
-    start  : start date
-    delta  : timedelta between internal events
-    filter : filter to remove the sids
+    :Note:
+        Bars where the price is nan are filtered out.
     """
 
     def __init__(self, data, **kwargs):
@@ -52,6 +50,8 @@
 
         self._raw_data = None
 
+        self.started_sids = set()
+
     @property
     def mapping(self):
         return {
@@ -69,6 +69,12 @@
         for dt, series in self.data.iterrows():
             for sid, price in series.iteritems():
                 if sid in self.sids:
+                    # Skip SIDs that can not be forward filled
+                    if np.isnan(price) and \
+                       sid not in self.started_sids:
+                        continue
+                    self.started_sids.add(sid)
+
                     event = {
                         'dt': dt,
                         'sid': sid,
@@ -88,16 +94,15 @@
 
 class DataPanelSource(DataSource):
     """
-    Yields all events in event_list that match the given sid_filter.
-    If no event_list is specified, generates an internal stream of events
-    to filter.  Returns all events if filter is None.
+    Data source that yields from a pandas Panel.
 
-    Configuration options:
+    :Axis layout:
+        * items : sids
+        * major_axis : datetime
+        * minor_axis : price, volume, ...
 
-    sids   : list of values representing simulated internal sids
-    start  : start date
-    delta  : timedelta between internal events
-    filter : filter to remove the sids
+    :Note:
+        Bars where the price is nan are filtered out.
     """
 
     def __init__(self, data, **kwargs):
@@ -114,6 +119,8 @@
 
         self._raw_data = None
 
+        self.started_sids = set()
+
     @property
     def mapping(self):
         mapping = {
@@ -140,6 +147,12 @@
             df = self.data.major_xs(dt)
             for sid, series in df.iteritems():
                 if sid in self.sids:
+                    # Skip SIDs that can not be forward filled
+                    if np.isnan(series['price']) and \
+                       sid not in self.started_sids:
+                        continue
+                    self.started_sids.add(sid)
+
                     event = {
                         'dt': dt,
                         'sid': sid,

{"golden_diff": "diff --git a/zipline/sources/data_frame_source.py b/zipline/sources/data_frame_source.py\n--- a/zipline/sources/data_frame_source.py\n+++ b/zipline/sources/data_frame_source.py\n@@ -1,6 +1,5 @@\n-\n #\n-# Copyright 2013 Quantopian, Inc.\n+# Copyright 2015 Quantopian, Inc.\n #\n # Licensed under the Apache License, Version 2.0 (the \"License\");\n # you may not use this file except in compliance with the License.\n@@ -17,6 +16,7 @@\n \"\"\"\n Tools to generate data sources.\n \"\"\"\n+import numpy as np\n import pandas as pd\n \n from zipline.gens.utils import hash_args\n@@ -26,16 +26,14 @@\n \n class DataFrameSource(DataSource):\n     \"\"\"\n-    Yields all events in event_list that match the given sid_filter.\n-    If no event_list is specified, generates an internal stream of events\n-    to filter.  Returns all events if filter is None.\n+    Data source that yields from a pandas DataFrame.\n \n-    Configuration options:\n+    :Axis layout:\n+        * columns : sids\n+        * index : datetime\n \n-    sids   : list of values representing simulated internal sids\n-    start  : start date\n-    delta  : timedelta between internal events\n-    filter : filter to remove the sids\n+    :Note:\n+        Bars where the price is nan are filtered out.\n     \"\"\"\n \n     def __init__(self, data, **kwargs):\n@@ -52,6 +50,8 @@\n \n         self._raw_data = None\n \n+        self.started_sids = set()\n+\n     @property\n     def mapping(self):\n         return {\n@@ -69,6 +69,12 @@\n         for dt, series in self.data.iterrows():\n             for sid, price in series.iteritems():\n                 if sid in self.sids:\n+                    # Skip SIDs that can not be forward filled\n+                    if np.isnan(price) and \\\n+                       sid not in self.started_sids:\n+                        continue\n+                    self.started_sids.add(sid)\n+\n                     event = {\n                         'dt': dt,\n                         'sid': sid,\n@@ -88,16 +94,15 @@\n \n class DataPanelSource(DataSource):\n     \"\"\"\n-    Yields all events in event_list that match the given sid_filter.\n-    If no event_list is specified, generates an internal stream of events\n-    to filter.  Returns all events if filter is None.\n+    Data source that yields from a pandas Panel.\n \n-    Configuration options:\n+    :Axis layout:\n+        * items : sids\n+        * major_axis : datetime\n+        * minor_axis : price, volume, ...\n \n-    sids   : list of values representing simulated internal sids\n-    start  : start date\n-    delta  : timedelta between internal events\n-    filter : filter to remove the sids\n+    :Note:\n+        Bars where the price is nan are filtered out.\n     \"\"\"\n \n     def __init__(self, data, **kwargs):\n@@ -114,6 +119,8 @@\n \n         self._raw_data = None\n \n+        self.started_sids = set()\n+\n     @property\n     def mapping(self):\n         mapping = {\n@@ -140,6 +147,12 @@\n             df = self.data.major_xs(dt)\n             for sid, series in df.iteritems():\n                 if sid in self.sids:\n+                    # Skip SIDs that can not be forward filled\n+                    if np.isnan(series['price']) and \\\n+                       sid not in self.started_sids:\n+                        continue\n+                    self.started_sids.add(sid)\n+\n                     event = {\n                         'dt': dt,\n                         'sid': sid,\n", "issue": "Support for nans in input data\nIf a ticker hasn't started trading yet, pandas' convention is to use nans. Currently it seems as if zipline raises an exception if there are nans in the input data. This should be fixed and the corresponding ticker to should not be included if it hasn't started trading yet.\n\n", "before_files": [{"content": "\n#\n# Copyright 2013 Quantopian, Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"\nTools to generate data sources.\n\"\"\"\nimport pandas as pd\n\nfrom zipline.gens.utils import hash_args\n\nfrom zipline.sources.data_source import DataSource\n\n\nclass DataFrameSource(DataSource):\n    \"\"\"\n    Yields all events in event_list that match the given sid_filter.\n    If no event_list is specified, generates an internal stream of events\n    to filter.  Returns all events if filter is None.\n\n    Configuration options:\n\n    sids   : list of values representing simulated internal sids\n    start  : start date\n    delta  : timedelta between internal events\n    filter : filter to remove the sids\n    \"\"\"\n\n    def __init__(self, data, **kwargs):\n        assert isinstance(data.index, pd.tseries.index.DatetimeIndex)\n\n        self.data = data\n        # Unpack config dictionary with default values.\n        self.sids = kwargs.get('sids', data.columns)\n        self.start = kwargs.get('start', data.index[0])\n        self.end = kwargs.get('end', data.index[-1])\n\n        # Hash_value for downstream sorting.\n        self.arg_string = hash_args(data, **kwargs)\n\n        self._raw_data = None\n\n    @property\n    def mapping(self):\n        return {\n            'dt': (lambda x: x, 'dt'),\n            'sid': (lambda x: x, 'sid'),\n            'price': (float, 'price'),\n            'volume': (int, 'volume'),\n        }\n\n    @property\n    def instance_hash(self):\n        return self.arg_string\n\n    def raw_data_gen(self):\n        for dt, series in self.data.iterrows():\n            for sid, price in series.iteritems():\n                if sid in self.sids:\n                    event = {\n                        'dt': dt,\n                        'sid': sid,\n                        'price': price,\n                        # Just chose something large\n                        # if no volume available.\n                        'volume': 1e9,\n                    }\n                    yield event\n\n    @property\n    def raw_data(self):\n        if not self._raw_data:\n            self._raw_data = self.raw_data_gen()\n        return self._raw_data\n\n\nclass DataPanelSource(DataSource):\n    \"\"\"\n    Yields all events in event_list that match the given sid_filter.\n    If no event_list is specified, generates an internal stream of events\n    to filter.  Returns all events if filter is None.\n\n    Configuration options:\n\n    sids   : list of values representing simulated internal sids\n    start  : start date\n    delta  : timedelta between internal events\n    filter : filter to remove the sids\n    \"\"\"\n\n    def __init__(self, data, **kwargs):\n        assert isinstance(data.major_axis, pd.tseries.index.DatetimeIndex)\n\n        self.data = data\n        # Unpack config dictionary with default values.\n        self.sids = kwargs.get('sids', data.items)\n        self.start = kwargs.get('start', data.major_axis[0])\n        self.end = kwargs.get('end', data.major_axis[-1])\n\n        # Hash_value for downstream sorting.\n        self.arg_string = hash_args(data, **kwargs)\n\n        self._raw_data = None\n\n    @property\n    def mapping(self):\n        mapping = {\n            'dt': (lambda x: x, 'dt'),\n            'sid': (lambda x: x, 'sid'),\n            'price': (float, 'price'),\n            'volume': (int, 'volume'),\n        }\n\n        # Add additional fields.\n        for field_name in self.data.minor_axis:\n            if field_name in ['price', 'volume', 'dt', 'sid']:\n                continue\n            mapping[field_name] = (lambda x: x, field_name)\n\n        return mapping\n\n    @property\n    def instance_hash(self):\n        return self.arg_string\n\n    def raw_data_gen(self):\n        for dt in self.data.major_axis:\n            df = self.data.major_xs(dt)\n            for sid, series in df.iteritems():\n                if sid in self.sids:\n                    event = {\n                        'dt': dt,\n                        'sid': sid,\n                    }\n                    for field_name, value in series.iteritems():\n                        event[field_name] = value\n\n                    yield event\n\n    @property\n    def raw_data(self):\n        if not self._raw_data:\n            self._raw_data = self.raw_data_gen()\n        return self._raw_data\n", "path": "zipline/sources/data_frame_source.py"}], "after_files": [{"content": "#\n# Copyright 2015 Quantopian, Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"\nTools to generate data sources.\n\"\"\"\nimport numpy as np\nimport pandas as pd\n\nfrom zipline.gens.utils import hash_args\n\nfrom zipline.sources.data_source import DataSource\n\n\nclass DataFrameSource(DataSource):\n    \"\"\"\n    Data source that yields from a pandas DataFrame.\n\n    :Axis layout:\n        * columns : sids\n        * index : datetime\n\n    :Note:\n        Bars where the price is nan are filtered out.\n    \"\"\"\n\n    def __init__(self, data, **kwargs):\n        assert isinstance(data.index, pd.tseries.index.DatetimeIndex)\n\n        self.data = data\n        # Unpack config dictionary with default values.\n        self.sids = kwargs.get('sids', data.columns)\n        self.start = kwargs.get('start', data.index[0])\n        self.end = kwargs.get('end', data.index[-1])\n\n        # Hash_value for downstream sorting.\n        self.arg_string = hash_args(data, **kwargs)\n\n        self._raw_data = None\n\n        self.started_sids = set()\n\n    @property\n    def mapping(self):\n        return {\n            'dt': (lambda x: x, 'dt'),\n            'sid': (lambda x: x, 'sid'),\n            'price': (float, 'price'),\n            'volume': (int, 'volume'),\n        }\n\n    @property\n    def instance_hash(self):\n        return self.arg_string\n\n    def raw_data_gen(self):\n        for dt, series in self.data.iterrows():\n            for sid, price in series.iteritems():\n                if sid in self.sids:\n                    # Skip SIDs that can not be forward filled\n                    if np.isnan(price) and \\\n                       sid not in self.started_sids:\n                        continue\n                    self.started_sids.add(sid)\n\n                    event = {\n                        'dt': dt,\n                        'sid': sid,\n                        'price': price,\n                        # Just chose something large\n                        # if no volume available.\n                        'volume': 1e9,\n                    }\n                    yield event\n\n    @property\n    def raw_data(self):\n        if not self._raw_data:\n            self._raw_data = self.raw_data_gen()\n        return self._raw_data\n\n\nclass DataPanelSource(DataSource):\n    \"\"\"\n    Data source that yields from a pandas Panel.\n\n    :Axis layout:\n        * items : sids\n        * major_axis : datetime\n        * minor_axis : price, volume, ...\n\n    :Note:\n        Bars where the price is nan are filtered out.\n    \"\"\"\n\n    def __init__(self, data, **kwargs):\n        assert isinstance(data.major_axis, pd.tseries.index.DatetimeIndex)\n\n        self.data = data\n        # Unpack config dictionary with default values.\n        self.sids = kwargs.get('sids', data.items)\n        self.start = kwargs.get('start', data.major_axis[0])\n        self.end = kwargs.get('end', data.major_axis[-1])\n\n        # Hash_value for downstream sorting.\n        self.arg_string = hash_args(data, **kwargs)\n\n        self._raw_data = None\n\n        self.started_sids = set()\n\n    @property\n    def mapping(self):\n        mapping = {\n            'dt': (lambda x: x, 'dt'),\n            'sid': (lambda x: x, 'sid'),\n            'price': (float, 'price'),\n            'volume': (int, 'volume'),\n        }\n\n        # Add additional fields.\n        for field_name in self.data.minor_axis:\n            if field_name in ['price', 'volume', 'dt', 'sid']:\n                continue\n            mapping[field_name] = (lambda x: x, field_name)\n\n        return mapping\n\n    @property\n    def instance_hash(self):\n        return self.arg_string\n\n    def raw_data_gen(self):\n        for dt in self.data.major_axis:\n            df = self.data.major_xs(dt)\n            for sid, series in df.iteritems():\n                if sid in self.sids:\n                    # Skip SIDs that can not be forward filled\n                    if np.isnan(series['price']) and \\\n                       sid not in self.started_sids:\n                        continue\n                    self.started_sids.add(sid)\n\n                    event = {\n                        'dt': dt,\n                        'sid': sid,\n                    }\n                    for field_name, value in series.iteritems():\n                        event[field_name] = value\n\n                    yield event\n\n    @property\n    def raw_data(self):\n        if not self._raw_data:\n            self._raw_data = self.raw_data_gen()\n        return self._raw_data\n", "path": "zipline/sources/data_frame_source.py"}]}