{"action":"created","issue":{"url":"https://api.github.com/repos/gbeced/pyalgotrade/issues/54","labels_url":"https://api.github.com/repos/gbeced/pyalgotrade/issues/54/labels{/name}","comments_url":"https://api.github.com/repos/gbeced/pyalgotrade/issues/54/comments","events_url":"https://api.github.com/repos/gbeced/pyalgotrade/issues/54/events","html_url":"https://github.com/gbeced/pyalgotrade/issues/54","id":108511969,"number":54,"title":"Forex Example","user":{"login":"crazy25000","id":8519081,"avatar_url":"https://avatars.githubusercontent.com/u/8519081?v=3","gravatar_id":"","url":"https://api.github.com/users/crazy25000","html_url":"https://github.com/crazy25000","followers_url":"https://api.github.com/users/crazy25000/followers","following_url":"https://api.github.com/users/crazy25000/following{/other_user}","gists_url":"https://api.github.com/users/crazy25000/gists{/gist_id}","starred_url":"https://api.github.com/users/crazy25000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crazy25000/subscriptions","organizations_url":"https://api.github.com/users/crazy25000/orgs","repos_url":"https://api.github.com/users/crazy25000/repos","events_url":"https://api.github.com/users/crazy25000/events{/privacy}","received_events_url":"https://api.github.com/users/crazy25000/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-09-27T04:13:55Z","updated_at":"2015-10-02T04:16:44Z","closed_at":"2015-09-27T23:43:15Z","body":"Would you also post sample code, CSV to test currency strategy? "},"comment":{"url":"https://api.github.com/repos/gbeced/pyalgotrade/issues/comments/144912542","html_url":"https://github.com/gbeced/pyalgotrade/issues/54#issuecomment-144912542","issue_url":"https://api.github.com/repos/gbeced/pyalgotrade/issues/54","id":144912542,"user":{"login":"crazy25000","id":8519081,"avatar_url":"https://avatars.githubusercontent.com/u/8519081?v=3","gravatar_id":"","url":"https://api.github.com/users/crazy25000","html_url":"https://github.com/crazy25000","followers_url":"https://api.github.com/users/crazy25000/followers","following_url":"https://api.github.com/users/crazy25000/following{/other_user}","gists_url":"https://api.github.com/users/crazy25000/gists{/gist_id}","starred_url":"https://api.github.com/users/crazy25000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crazy25000/subscriptions","organizations_url":"https://api.github.com/users/crazy25000/orgs","repos_url":"https://api.github.com/users/crazy25000/repos","events_url":"https://api.github.com/users/crazy25000/events{/privacy}","received_events_url":"https://api.github.com/users/crazy25000/received_events","type":"User","site_admin":false},"created_at":"2015-10-02T04:16:44Z","updated_at":"2015-10-02T04:16:44Z","body":"With the below code I get an error because the strategy class requires an instrument:\r\n\r\n    def run_strategy(smaPeriod):\r\n        feed = csvfeed.Feed(\"Date\", \"%m.%d.%Y\")\r\n        feed.addValuesFromCSV(\"eur_usd.csv\")\r\n\r\n        myStrategy = MyStrategy(feed, smaPeriod)\r\n        myStrategy.run()\r\n        print \"Final portfolio value: $%.2f\" % myStrategy.getBroker().getEquity()\r\n\r\n    run_strategy(15)\r\n\r\nThis is the beginning of the default strategy class in the tutorial:\r\n\r\n    class MyStrategy(strategy.BacktestingStrategy):\r\n        def __init__(self, feed, instrument, smaPeriod):\r\n            strategy.BacktestingStrategy.__init__(self, feed, 1000)\r\n\r\nIf I add EURGBP to be used as an instrument, it gives a key error:\r\n\r\n    def run_strategy(smaPeriod):\r\n        feed = csvfeed.Feed(\"Date\", \"%m.%d.%Y\")\r\n        feed.addValuesFromCSV(\"eur_usd.csv\")\r\n\r\n        myStrategy = MyStrategy(feed, smaPeriod)\r\n        myStrategy.run()\r\n        print \"Final portfolio value: $%.2f\" % myStrategy.getBroker().getEquity()\r\n\r\n    run_strategy(15)\r\n\r\n#####    self.__sma = ma.SMA(feed[instrument].getPriceDataSeries(), smaPeriod)\r\n#####  File \"/usr/lib/python2.7/site-packages/pyalgotrade/feed/__init__.py\", line 113, in __getitem__\r\n#####    return self.__ds[key]\r\n##### KeyError: 'EURGBP'\r\n\r\nI also tried removing instrument as a requirement for the strategy class, but got a different error. \r\n"}}