{"action":"created","issue":{"url":"https://api.github.com/repos/mementum/backtrader/issues/65","repository_url":"https://api.github.com/repos/mementum/backtrader","labels_url":"https://api.github.com/repos/mementum/backtrader/issues/65/labels{/name}","comments_url":"https://api.github.com/repos/mementum/backtrader/issues/65/comments","events_url":"https://api.github.com/repos/mementum/backtrader/issues/65/events","html_url":"https://github.com/mementum/backtrader/issues/65","id":140393961,"number":65,"title":"Extending the PandasDataFeed","user":{"login":"ericbrown","id":449599,"avatar_url":"https://avatars.githubusercontent.com/u/449599?v=3","gravatar_id":"","url":"https://api.github.com/users/ericbrown","html_url":"https://github.com/ericbrown","followers_url":"https://api.github.com/users/ericbrown/followers","following_url":"https://api.github.com/users/ericbrown/following{/other_user}","gists_url":"https://api.github.com/users/ericbrown/gists{/gist_id}","starred_url":"https://api.github.com/users/ericbrown/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericbrown/subscriptions","organizations_url":"https://api.github.com/users/ericbrown/orgs","repos_url":"https://api.github.com/users/ericbrown/repos","events_url":"https://api.github.com/users/ericbrown/events{/privacy}","received_events_url":"https://api.github.com/users/ericbrown/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-03-12T15:40:20Z","updated_at":"2016-03-14T10:29:46Z","closed_at":null,"body":"I just found backtrader. Nice work.\r\n\r\nI do all my work in pandas and was happy to see that you have a pandas datafeed. I\"m trying to follow the examples given for extending datafeeds but I am running into an issue.\r\n\r\nExample with CSV: http://backtrader.readthedocs.org/en/latest/extending-a-datafeed.html\r\n\r\nMy code following the example:\r\n\r\n```python\r\nclass AddDataFieldsPandas(PandasData):\r\n\r\n\tlines = ('optix_close','optix_pess', 'optix_opt',)\r\n\tparams = (\r\n\t\t('optix_close', -1),\r\n\t\t('optix_pess', -1),\r\n\t\t('optix_opt', -1),\r\n\t)\r\n\r\n\tlinefields = PandasData.datafields + ['optix_close', 'optix_pess', 'optix_opt']\r\n\r\n```\r\nI've tried a few permutations of this, including:\r\n\r\n```python\r\nclass AddDataFieldsPandas(PandasData):\r\n\r\n\tlines = ('optix_close','optix_pess', 'optix_opt',)\r\n\tparams = (\r\n\t\t('optix_close', -1),\r\n\t\t('optix_pess', -1),\r\n\t\t('optix_opt', -1),\r\n\t)\r\n\r\n\tdatafields = PandasData.datafields + ['optix_close', 'optix_pess', 'optix_opt']\r\n\r\n```\r\nand\r\n\r\n```python\r\nclass AddDataFieldsPandas(PandasData):\r\n\r\n\tlines = ('optix_close','optix_pess', 'optix_opt',)\r\n\tparams = (\r\n\t\t('optix_close', -1),\r\n\t\t('optix_pess', -1),\r\n\t\t('optix_opt', -1),\r\n\t)\r\n\r\n\tPandasData.datafields = PandasData.datafields + ['optix_close', 'optix_pess', 'optix_opt']\r\n\r\n```\r\n\r\nNone of these add the extra params. When i run my strat, I get the following error:\r\n\r\n> AttributeError: 'Lines_LineSeries_DataSeries_OHLC_OHLCDateTime_Abst' object has no attribute 'optix_close'\r\n\r\nIf I run your sample [MyTest strat](http://backtrader.readthedocs.org/en/latest/automated-bt-run/automated-bt-run.html#applying-a-user-defined-strategy) and try to add one of the extra params to the log i get the same error, so its not my strat causing the issue...I'm just not getting the extra params/lines into the pandas data definition.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/mementum/backtrader/issues/comments/196244989","html_url":"https://github.com/mementum/backtrader/issues/65#issuecomment-196244989","issue_url":"https://api.github.com/repos/mementum/backtrader/issues/65","id":196244989,"user":{"login":"mementum","id":5713511,"avatar_url":"https://avatars.githubusercontent.com/u/5713511?v=3","gravatar_id":"","url":"https://api.github.com/users/mementum","html_url":"https://github.com/mementum","followers_url":"https://api.github.com/users/mementum/followers","following_url":"https://api.github.com/users/mementum/following{/other_user}","gists_url":"https://api.github.com/users/mementum/gists{/gist_id}","starred_url":"https://api.github.com/users/mementum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mementum/subscriptions","organizations_url":"https://api.github.com/users/mementum/orgs","repos_url":"https://api.github.com/users/mementum/repos","events_url":"https://api.github.com/users/mementum/events{/privacy}","received_events_url":"https://api.github.com/users/mementum/received_events","type":"User","site_admin":false},"created_at":"2016-03-14T10:29:45Z","updated_at":"2016-03-14T10:29:45Z","body":"Your code has this\r\n\r\n```python\r\ndata = bt.feeds.PandasData(dataname=df)\r\n```\r\n\r\nBut should instead have this\r\n\r\n```python\r\ndata = AddDataFieldsPandas(dataname=df)\r\n```\r\n\r\nThe `lines` you add are getting added to your own derived class not to the parent class and that's the reason the code fails, because `PandasData` has no line named `optix_close`"}}