{"action":"created","comment":{"url":"https://api.github.com/repos/DeviaVir/zenbot/pulls/comments/158970138","pull_request_review_id":85850396,"id":158970138,"diff_hunk":"@@ -69,6 +111,30 @@ module.exports = function container (get, set, clear) {\n         // move cursor into the past\n         args.after = opts.to\n       }\n+      // check for locally cached trades from the websocket feed\n+      var cache = websocket_cache[opts.product_id]\n+      var max_trade_id = cache.trade_ids.reduce(function(a, b) {\n+        return Math.max(a, b)\n+      }, -1)\n+      if (opts.from && max_trade_id >= opts.from) {\n+        var fromIndex = cache.trades.findIndex((value)=> {return value.trade_id == opts.from})\n+        var newTrades = cache.trades.slice(fromIndex + 1)\n+        newTrades = newTrades.map(function (trade) {\n+          return {\n+            trade_id: trade.trade_id,\n+            time: new Date(trade.time).getTime(),\n+            size: Number(trade.size),\n+            price: Number(trade.price),\n+            side: trade.side\n+          }\n+        })\n+        newTrades.reverse()\n+        cb(null, newTrades)\n+        // trim cache\n+        cache.trades = cache.trades.slice(fromIndex)\n+        cache.trade_ids = cache.trade_ids.slice(fromIndex)\n+        return\n+      }\n       client.getProductTrades(args, function (err, resp, body) {","path":"extensions/exchanges/gdax/exchange.js","position":102,"original_position":102,"commit_id":"74085ad19c6509eb6336c9d503e997ebb0c2b57a","original_commit_id":"22c569e08a14ec2657daadf572296e19595ad1b2","user":{"login":"krystophv","id":187294,"avatar_url":"https://avatars1.githubusercontent.com/u/187294?v=4","gravatar_id":"","url":"https://api.github.com/users/krystophv","html_url":"https://github.com/krystophv","followers_url":"https://api.github.com/users/krystophv/followers","following_url":"https://api.github.com/users/krystophv/following{/other_user}","gists_url":"https://api.github.com/users/krystophv/gists{/gist_id}","starred_url":"https://api.github.com/users/krystophv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krystophv/subscriptions","organizations_url":"https://api.github.com/users/krystophv/orgs","repos_url":"https://api.github.com/users/krystophv/repos","events_url":"https://api.github.com/users/krystophv/events{/privacy}","received_events_url":"https://api.github.com/users/krystophv/received_events","type":"User","site_admin":false},"body":"@DeviaVir it's not an issue any longer since we pinned the dependency instead","created_at":"2017-12-28T16:49:22Z","updated_at":"2017-12-28T16:49:22Z","html_url":"https://github.com/DeviaVir/zenbot/pull/970#discussion_r158970138","pull_request_url":"https://api.github.com/repos/DeviaVir/zenbot/pulls/970","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/DeviaVir/zenbot/pulls/comments/158970138"},"html":{"href":"https://github.com/DeviaVir/zenbot/pull/970#discussion_r158970138"},"pull_request":{"href":"https://api.github.com/repos/DeviaVir/zenbot/pulls/970"}},"in_reply_to_id":158854408},"pull_request":{"url":"https://api.github.com/repos/DeviaVir/zenbot/pulls/970","id":159763007,"html_url":"https://github.com/DeviaVir/zenbot/pull/970","diff_url":"https://github.com/DeviaVir/zenbot/pull/970.diff","patch_url":"https://github.com/DeviaVir/zenbot/pull/970.patch","issue_url":"https://api.github.com/repos/DeviaVir/zenbot/issues/970","number":970,"state":"open","locked":false,"title":"Add basic websocket support for GDAX","user":{"login":"krystophv","id":187294,"avatar_url":"https://avatars1.githubusercontent.com/u/187294?v=4","gravatar_id":"","url":"https://api.github.com/users/krystophv","html_url":"https://github.com/krystophv","followers_url":"https://api.github.com/users/krystophv/followers","following_url":"https://api.github.com/users/krystophv/following{/other_user}","gists_url":"https://api.github.com/users/krystophv/gists{/gist_id}","starred_url":"https://api.github.com/users/krystophv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krystophv/subscriptions","organizations_url":"https://api.github.com/users/krystophv/orgs","repos_url":"https://api.github.com/users/krystophv/repos","events_url":"https://api.github.com/users/krystophv/events{/privacy}","received_events_url":"https://api.github.com/users/krystophv/received_events","type":"User","site_admin":false},"body":"This PR makes a first step into reading data from the websocket stream for GDAX instead of continually polling their REST APIs. It doesn't feed the websocket reports directly into the system, but rather sets up a couple of objects/arrays that will act as a buffer or cache for the incoming websocket data and then when the `exchange` level API functions run, they're set to check the websocket cache (or websocket fed live orderbook) before making a REST call. This should initially alleviate REST calls from `getTrades` and `getQuote`. At a minimum, should also be able to write a little more processing code and set up a similar cache for `getOrder` in the near future.","created_at":"2017-12-21T22:24:14Z","updated_at":"2017-12-28T16:49:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1d33740c6362a99c78f667a1e1d8c047c806e4dc","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/DeviaVir/zenbot/pulls/970/commits","review_comments_url":"https://api.github.com/repos/DeviaVir/zenbot/pulls/970/comments","review_comment_url":"https://api.github.com/repos/DeviaVir/zenbot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DeviaVir/zenbot/issues/970/comments","statuses_url":"https://api.github.com/repos/DeviaVir/zenbot/statuses/74085ad19c6509eb6336c9d503e997ebb0c2b57a","head":{"label":"krystophv:gdax_websocket","ref":"gdax_websocket","sha":"74085ad19c6509eb6336c9d503e997ebb0c2b57a","user":{"login":"krystophv","id":187294,"avatar_url":"https://avatars1.githubusercontent.com/u/187294?v=4","gravatar_id":"","url":"https://api.github.com/users/krystophv","html_url":"https://github.com/krystophv","followers_url":"https://api.github.com/users/krystophv/followers","following_url":"https://api.github.com/users/krystophv/following{/other_user}","gists_url":"https://api.github.com/users/krystophv/gists{/gist_id}","starred_url":"https://api.github.com/users/krystophv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krystophv/subscriptions","organizations_url":"https://api.github.com/users/krystophv/orgs","repos_url":"https://api.github.com/users/krystophv/repos","events_url":"https://api.github.com/users/krystophv/events{/privacy}","received_events_url":"https://api.github.com/users/krystophv/received_events","type":"User","site_admin":false},"repo":{"id":114944683,"name":"zenbot","full_name":"krystophv/zenbot","owner":{"login":"krystophv","id":187294,"avatar_url":"https://avatars1.githubusercontent.com/u/187294?v=4","gravatar_id":"","url":"https://api.github.com/users/krystophv","html_url":"https://github.com/krystophv","followers_url":"https://api.github.com/users/krystophv/followers","following_url":"https://api.github.com/users/krystophv/following{/other_user}","gists_url":"https://api.github.com/users/krystophv/gists{/gist_id}","starred_url":"https://api.github.com/users/krystophv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krystophv/subscriptions","organizations_url":"https://api.github.com/users/krystophv/orgs","repos_url":"https://api.github.com/users/krystophv/repos","events_url":"https://api.github.com/users/krystophv/events{/privacy}","received_events_url":"https://api.github.com/users/krystophv/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/krystophv/zenbot","description":"Zenbot is a command-line cryptocurrency trading bot using Node.js and MongoDB.","fork":true,"url":"https://api.github.com/repos/krystophv/zenbot","forks_url":"https://api.github.com/repos/krystophv/zenbot/forks","keys_url":"https://api.github.com/repos/krystophv/zenbot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/krystophv/zenbot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/krystophv/zenbot/teams","hooks_url":"https://api.github.com/repos/krystophv/zenbot/hooks","issue_events_url":"https://api.github.com/repos/krystophv/zenbot/issues/events{/number}","events_url":"https://api.github.com/repos/krystophv/zenbot/events","assignees_url":"https://api.github.com/repos/krystophv/zenbot/assignees{/user}","branches_url":"https://api.github.com/repos/krystophv/zenbot/branches{/branch}","tags_url":"https://api.github.com/repos/krystophv/zenbot/tags","blobs_url":"https://api.github.com/repos/krystophv/zenbot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/krystophv/zenbot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/krystophv/zenbot/git/refs{/sha}","trees_url":"https://api.github.com/repos/krystophv/zenbot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/krystophv/zenbot/statuses/{sha}","languages_url":"https://api.github.com/repos/krystophv/zenbot/languages","stargazers_url":"https://api.github.com/repos/krystophv/zenbot/stargazers","contributors_url":"https://api.github.com/repos/krystophv/zenbot/contributors","subscribers_url":"https://api.github.com/repos/krystophv/zenbot/subscribers","subscription_url":"https://api.github.com/repos/krystophv/zenbot/subscription","commits_url":"https://api.github.com/repos/krystophv/zenbot/commits{/sha}","git_commits_url":"https://api.github.com/repos/krystophv/zenbot/git/commits{/sha}","comments_url":"https://api.github.com/repos/krystophv/zenbot/comments{/number}","issue_comment_url":"https://api.github.com/repos/krystophv/zenbot/issues/comments{/number}","contents_url":"https://api.github.com/repos/krystophv/zenbot/contents/{+path}","compare_url":"https://api.github.com/repos/krystophv/zenbot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/krystophv/zenbot/merges","archive_url":"https://api.github.com/repos/krystophv/zenbot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/krystophv/zenbot/downloads","issues_url":"https://api.github.com/repos/krystophv/zenbot/issues{/number}","pulls_url":"https://api.github.com/repos/krystophv/zenbot/pulls{/number}","milestones_url":"https://api.github.com/repos/krystophv/zenbot/milestones{/number}","notifications_url":"https://api.github.com/repos/krystophv/zenbot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/krystophv/zenbot/labels{/name}","releases_url":"https://api.github.com/repos/krystophv/zenbot/releases{/id}","deployments_url":"https://api.github.com/repos/krystophv/zenbot/deployments","created_at":"2017-12-21T00:41:33Z","updated_at":"2017-12-21T00:41:35Z","pushed_at":"2017-12-27T19:01:54Z","git_url":"git://github.com/krystophv/zenbot.git","ssh_url":"git@github.com:krystophv/zenbot.git","clone_url":"https://github.com/krystophv/zenbot.git","svn_url":"https://github.com/krystophv/zenbot","homepage":"","size":9379,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"DeviaVir:master","ref":"master","sha":"4e1578351fbba99cb46e23e8145f8bcfe8513d1d","user":{"login":"DeviaVir","id":777823,"avatar_url":"https://avatars2.githubusercontent.com/u/777823?v=4","gravatar_id":"","url":"https://api.github.com/users/DeviaVir","html_url":"https://github.com/DeviaVir","followers_url":"https://api.github.com/users/DeviaVir/followers","following_url":"https://api.github.com/users/DeviaVir/following{/other_user}","gists_url":"https://api.github.com/users/DeviaVir/gists{/gist_id}","starred_url":"https://api.github.com/users/DeviaVir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DeviaVir/subscriptions","organizations_url":"https://api.github.com/users/DeviaVir/orgs","repos_url":"https://api.github.com/users/DeviaVir/repos","events_url":"https://api.github.com/users/DeviaVir/events{/privacy}","received_events_url":"https://api.github.com/users/DeviaVir/received_events","type":"User","site_admin":false},"repo":{"id":62025838,"name":"zenbot","full_name":"DeviaVir/zenbot","owner":{"login":"DeviaVir","id":777823,"avatar_url":"https://avatars2.githubusercontent.com/u/777823?v=4","gravatar_id":"","url":"https://api.github.com/users/DeviaVir","html_url":"https://github.com/DeviaVir","followers_url":"https://api.github.com/users/DeviaVir/followers","following_url":"https://api.github.com/users/DeviaVir/following{/other_user}","gists_url":"https://api.github.com/users/DeviaVir/gists{/gist_id}","starred_url":"https://api.github.com/users/DeviaVir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DeviaVir/subscriptions","organizations_url":"https://api.github.com/users/DeviaVir/orgs","repos_url":"https://api.github.com/users/DeviaVir/repos","events_url":"https://api.github.com/users/DeviaVir/events{/privacy}","received_events_url":"https://api.github.com/users/DeviaVir/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DeviaVir/zenbot","description":"Zenbot is a command-line cryptocurrency trading bot using Node.js and MongoDB.","fork":false,"url":"https://api.github.com/repos/DeviaVir/zenbot","forks_url":"https://api.github.com/repos/DeviaVir/zenbot/forks","keys_url":"https://api.github.com/repos/DeviaVir/zenbot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DeviaVir/zenbot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DeviaVir/zenbot/teams","hooks_url":"https://api.github.com/repos/DeviaVir/zenbot/hooks","issue_events_url":"https://api.github.com/repos/DeviaVir/zenbot/issues/events{/number}","events_url":"https://api.github.com/repos/DeviaVir/zenbot/events","assignees_url":"https://api.github.com/repos/DeviaVir/zenbot/assignees{/user}","branches_url":"https://api.github.com/repos/DeviaVir/zenbot/branches{/branch}","tags_url":"https://api.github.com/repos/DeviaVir/zenbot/tags","blobs_url":"https://api.github.com/repos/DeviaVir/zenbot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DeviaVir/zenbot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DeviaVir/zenbot/git/refs{/sha}","trees_url":"https://api.github.com/repos/DeviaVir/zenbot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DeviaVir/zenbot/statuses/{sha}","languages_url":"https://api.github.com/repos/DeviaVir/zenbot/languages","stargazers_url":"https://api.github.com/repos/DeviaVir/zenbot/stargazers","contributors_url":"https://api.github.com/repos/DeviaVir/zenbot/contributors","subscribers_url":"https://api.github.com/repos/DeviaVir/zenbot/subscribers","subscription_url":"https://api.github.com/repos/DeviaVir/zenbot/subscription","commits_url":"https://api.github.com/repos/DeviaVir/zenbot/commits{/sha}","git_commits_url":"https://api.github.com/repos/DeviaVir/zenbot/git/commits{/sha}","comments_url":"https://api.github.com/repos/DeviaVir/zenbot/comments{/number}","issue_comment_url":"https://api.github.com/repos/DeviaVir/zenbot/issues/comments{/number}","contents_url":"https://api.github.com/repos/DeviaVir/zenbot/contents/{+path}","compare_url":"https://api.github.com/repos/DeviaVir/zenbot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DeviaVir/zenbot/merges","archive_url":"https://api.github.com/repos/DeviaVir/zenbot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DeviaVir/zenbot/downloads","issues_url":"https://api.github.com/repos/DeviaVir/zenbot/issues{/number}","pulls_url":"https://api.github.com/repos/DeviaVir/zenbot/pulls{/number}","milestones_url":"https://api.github.com/repos/DeviaVir/zenbot/milestones{/number}","notifications_url":"https://api.github.com/repos/DeviaVir/zenbot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DeviaVir/zenbot/labels{/name}","releases_url":"https://api.github.com/repos/DeviaVir/zenbot/releases{/id}","deployments_url":"https://api.github.com/repos/DeviaVir/zenbot/deployments","created_at":"2016-06-27T04:38:18Z","updated_at":"2017-12-28T16:26:58Z","pushed_at":"2017-12-28T15:15:41Z","git_url":"git://github.com/DeviaVir/zenbot.git","ssh_url":"git@github.com:DeviaVir/zenbot.git","clone_url":"https://github.com/DeviaVir/zenbot.git","svn_url":"https://github.com/DeviaVir/zenbot","homepage":"","size":9422,"stargazers_count":2933,"watchers_count":2933,"language":"HTML","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":835,"mirror_url":null,"archived":false,"open_issues_count":212,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":835,"open_issues":212,"watchers":2933,"default_branch":"unstable"}},"_links":{"self":{"href":"https://api.github.com/repos/DeviaVir/zenbot/pulls/970"},"html":{"href":"https://github.com/DeviaVir/zenbot/pull/970"},"issue":{"href":"https://api.github.com/repos/DeviaVir/zenbot/issues/970"},"comments":{"href":"https://api.github.com/repos/DeviaVir/zenbot/issues/970/comments"},"review_comments":{"href":"https://api.github.com/repos/DeviaVir/zenbot/pulls/970/comments"},"review_comment":{"href":"https://api.github.com/repos/DeviaVir/zenbot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DeviaVir/zenbot/pulls/970/commits"},"statuses":{"href":"https://api.github.com/repos/DeviaVir/zenbot/statuses/74085ad19c6509eb6336c9d503e997ebb0c2b57a"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"krystophv"}}