{"action":"created","issue":{"url":"https://api.github.com/repos/ranaroussi/qtpylib/issues/31","repository_url":"https://api.github.com/repos/ranaroussi/qtpylib","labels_url":"https://api.github.com/repos/ranaroussi/qtpylib/issues/31/labels{/name}","comments_url":"https://api.github.com/repos/ranaroussi/qtpylib/issues/31/comments","events_url":"https://api.github.com/repos/ranaroussi/qtpylib/issues/31/events","html_url":"https://github.com/ranaroussi/qtpylib/issues/31","id":190169682,"number":31,"title":"No data from Blotter to Algo","user":{"login":"ErnstTmp","id":17543131,"avatar_url":"https://avatars.githubusercontent.com/u/17543131?v=3","gravatar_id":"","url":"https://api.github.com/users/ErnstTmp","html_url":"https://github.com/ErnstTmp","followers_url":"https://api.github.com/users/ErnstTmp/followers","following_url":"https://api.github.com/users/ErnstTmp/following{/other_user}","gists_url":"https://api.github.com/users/ErnstTmp/gists{/gist_id}","starred_url":"https://api.github.com/users/ErnstTmp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ErnstTmp/subscriptions","organizations_url":"https://api.github.com/users/ErnstTmp/orgs","repos_url":"https://api.github.com/users/ErnstTmp/repos","events_url":"https://api.github.com/users/ErnstTmp/events{/privacy}","received_events_url":"https://api.github.com/users/ErnstTmp/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":20,"created_at":"2016-11-17T21:29:43Z","updated_at":"2016-12-02T05:51:36Z","closed_at":null,"body":"Hi Ran,\r\nthanks again for creating qtpylib, it is great.\r\n\r\nI have a strange behaviour: if I create a fresh Anaconda environment, install qtpylib there (with `pip install qtpylib --upgrade --no-cache-dir`), create the database and run the blotter, the quote data for AAPL is stored in the database. \r\nHowever, if  I start a simple strategy - only printing when on_bar() is called, I only get the printout once, so on_bar() is called only once. If I print the bars, they are the first bars when the blotter was started, not the current bars. Then, nothing happens.\r\n\r\nIf I start the same strategy on an older install (a few weeks) of qtpylib on another machine, the strategy runs fine.\r\n\r\nIf I remove the line \r\n```\r\npreload     = \"1D\", # preload 1 day history when starting\r\n```\r\n\r\nfrom the instrument definition, it works.\r\n\r\n```python\r\nstrategy = AAPLStrat(\r\n        instruments = [ (\"AAPL\", \"STK\", \"SMART\", \"USD\", \"\", 0.0, \"\") ], # ib tuples\r\n        resolution  = \"1min\", # Pandas resolution (use \"K\" for tick bars)\r\n        tick_window = 20, # no. of ticks to keep\r\n        bar_window  = 5, # no. of bars to keep\r\n        preload     = \"1D\", # preload 1 day history when starting\r\n ```\r\n\r\nThe only difference is that TWS runs on the second, older machine where it works. Can this be the reason?\r\n\r\nThank,\r\nErnst\r\n"},"comment":{"url":"https://api.github.com/repos/ranaroussi/qtpylib/issues/comments/264379306","html_url":"https://github.com/ranaroussi/qtpylib/issues/31#issuecomment-264379306","issue_url":"https://api.github.com/repos/ranaroussi/qtpylib/issues/31","id":264379306,"user":{"login":"ranaroussi","id":1185458,"avatar_url":"https://avatars.githubusercontent.com/u/1185458?v=3","gravatar_id":"","url":"https://api.github.com/users/ranaroussi","html_url":"https://github.com/ranaroussi","followers_url":"https://api.github.com/users/ranaroussi/followers","following_url":"https://api.github.com/users/ranaroussi/following{/other_user}","gists_url":"https://api.github.com/users/ranaroussi/gists{/gist_id}","starred_url":"https://api.github.com/users/ranaroussi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ranaroussi/subscriptions","organizations_url":"https://api.github.com/users/ranaroussi/orgs","repos_url":"https://api.github.com/users/ranaroussi/repos","events_url":"https://api.github.com/users/ranaroussi/events{/privacy}","received_events_url":"https://api.github.com/users/ranaroussi/received_events","type":"User","site_admin":false},"created_at":"2016-12-02T05:51:36Z","updated_at":"2016-12-02T05:51:36Z","body":"You're not getting data because you don't have TWS/GW running and you're not in backtesting mode either - but you shouldn't get these errors neither. I'm not sure why is `on_bar()` being called when no bars actually exist.\r\n\r\nPlease change the `on_bar()` logic to this and run it twice (with and without TWS running) and let me know what was the output:\r\n\r\n```python\r\ndef on_bar(self, instrument):\r\n    print(\"--- INSTRUMENT BARS ---\")\r\n    print( instrument.bars )\r\n    print(\"-----------------------\")\r\n\r\n    print(\"------ ALL BARS -------\")\r\n    print( self.bars )\r\n    print(\"-----------------------\")\r\n```"}}
{"actor":{"display_login":"ranaroussi"}}