{"action":"created","comment":{"url":"https://api.github.com/repos/quantopian/zipline/pulls/comments/59884619","id":59884619,"diff_hunk":"@@ -443,6 +443,18 @@ def calculate_start_and_end(self, dt, env):\n             )\n         )\n \n+        # If after applying the offset to the start/end day of the week, we get\n+        # day in a different week, skip this week and go on to the next\n+        while next_trading_day.date().isocalendar()[1] != \\","path":"zipline/utils/events.py","position":6,"original_position":6,"commit_id":"1ee3c5f04968ab2b1ab4ff334c1cdefe487e7927","original_commit_id":"1ee3c5f04968ab2b1ab4ff334c1cdefe487e7927","user":{"login":"richafrank","id":2123660,"avatar_url":"https://avatars.githubusercontent.com/u/2123660?v=3","gravatar_id":"","url":"https://api.github.com/users/richafrank","html_url":"https://github.com/richafrank","followers_url":"https://api.github.com/users/richafrank/followers","following_url":"https://api.github.com/users/richafrank/following{/other_user}","gists_url":"https://api.github.com/users/richafrank/gists{/gist_id}","starred_url":"https://api.github.com/users/richafrank/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/richafrank/subscriptions","organizations_url":"https://api.github.com/users/richafrank/orgs","repos_url":"https://api.github.com/users/richafrank/repos","events_url":"https://api.github.com/users/richafrank/events{/privacy}","received_events_url":"https://api.github.com/users/richafrank/received_events","type":"User","site_admin":false},"body":"How about `next_trading_day.weekday()`?","created_at":"2016-04-15T14:40:59Z","updated_at":"2016-04-15T14:40:59Z","html_url":"https://github.com/quantopian/zipline/pull/1131#discussion_r59884619","pull_request_url":"https://api.github.com/repos/quantopian/zipline/pulls/1131","_links":{"self":{"href":"https://api.github.com/repos/quantopian/zipline/pulls/comments/59884619"},"html":{"href":"https://github.com/quantopian/zipline/pull/1131#discussion_r59884619"},"pull_request":{"href":"https://api.github.com/repos/quantopian/zipline/pulls/1131"}}},"pull_request":{"url":"https://api.github.com/repos/quantopian/zipline/pulls/1131","id":66536297,"html_url":"https://github.com/quantopian/zipline/pull/1131","diff_url":"https://github.com/quantopian/zipline/pull/1131.diff","patch_url":"https://github.com/quantopian/zipline/pull/1131.patch","issue_url":"https://api.github.com/repos/quantopian/zipline/issues/1131","number":1131,"state":"closed","locked":false,"title":"BUG: week_end rule with offset=0 skips every other week","user":{"login":"lianga888","id":10404037,"avatar_url":"https://avatars.githubusercontent.com/u/10404037?v=3","gravatar_id":"","url":"https://api.github.com/users/lianga888","html_url":"https://github.com/lianga888","followers_url":"https://api.github.com/users/lianga888/followers","following_url":"https://api.github.com/users/lianga888/following{/other_user}","gists_url":"https://api.github.com/users/lianga888/gists{/gist_id}","starred_url":"https://api.github.com/users/lianga888/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lianga888/subscriptions","organizations_url":"https://api.github.com/users/lianga888/orgs","repos_url":"https://api.github.com/users/lianga888/repos","events_url":"https://api.github.com/users/lianga888/events{/privacy}","received_events_url":"https://api.github.com/users/lianga888/received_events","type":"User","site_admin":false},"body":"- previously, we calculated the new trigger period (9:30 to 16:00 EST for a given date) after the current trigger period has passed. We fast-forward 7 calendar days from the current dt and calculate the new period for that week\r\n- however, if the trigger is the last day of the week, we recalculate on the first bar of the following week, and after fast-forwarding 7 calendar days, we end up in the week following that (effectively skipping a week)\r\n- to fix this, we recalculate every time we trigger, because of the assumption in Q2 that we run handle_data every minute (and thus we will never miss a trigger)\r\n- accompanying fixes to address shortened weeks:\r\n  - when finding the first or last day of the week, if it is not a trading day, adjust accordingly\r\n  - when applying the offset, if there's not enough days in the week, skip and go onto the next week\r\n- existing tests are modified to reflect that every time a trigger hits, it is recalculated\r\n- new test for week_end and week_start on shortened weeks\r\n","created_at":"2016-04-14T19:01:15Z","updated_at":"2016-04-15T14:40:59Z","closed_at":"2016-04-15T14:32:40Z","merged_at":"2016-04-15T14:32:40Z","merge_commit_sha":"b7d9723a545531ae14f91ac4fae8082bf3041888","assignee":{"login":"jbredeche","id":487622,"avatar_url":"https://avatars.githubusercontent.com/u/487622?v=3","gravatar_id":"","url":"https://api.github.com/users/jbredeche","html_url":"https://github.com/jbredeche","followers_url":"https://api.github.com/users/jbredeche/followers","following_url":"https://api.github.com/users/jbredeche/following{/other_user}","gists_url":"https://api.github.com/users/jbredeche/gists{/gist_id}","starred_url":"https://api.github.com/users/jbredeche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbredeche/subscriptions","organizations_url":"https://api.github.com/users/jbredeche/orgs","repos_url":"https://api.github.com/users/jbredeche/repos","events_url":"https://api.github.com/users/jbredeche/events{/privacy}","received_events_url":"https://api.github.com/users/jbredeche/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/quantopian/zipline/pulls/1131/commits","review_comments_url":"https://api.github.com/repos/quantopian/zipline/pulls/1131/comments","review_comment_url":"https://api.github.com/repos/quantopian/zipline/pulls/comments{/number}","comments_url":"https://api.github.com/repos/quantopian/zipline/issues/1131/comments","statuses_url":"https://api.github.com/repos/quantopian/zipline/statuses/1ee3c5f04968ab2b1ab4ff334c1cdefe487e7927","head":{"label":"quantopian:week_schedule","ref":"week_schedule","sha":"1ee3c5f04968ab2b1ab4ff334c1cdefe487e7927","user":{"login":"quantopian","id":1393215,"avatar_url":"https://avatars.githubusercontent.com/u/1393215?v=3","gravatar_id":"","url":"https://api.github.com/users/quantopian","html_url":"https://github.com/quantopian","followers_url":"https://api.github.com/users/quantopian/followers","following_url":"https://api.github.com/users/quantopian/following{/other_user}","gists_url":"https://api.github.com/users/quantopian/gists{/gist_id}","starred_url":"https://api.github.com/users/quantopian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quantopian/subscriptions","organizations_url":"https://api.github.com/users/quantopian/orgs","repos_url":"https://api.github.com/users/quantopian/repos","events_url":"https://api.github.com/users/quantopian/events{/privacy}","received_events_url":"https://api.github.com/users/quantopian/received_events","type":"Organization","site_admin":false},"repo":{"id":6297520,"name":"zipline","full_name":"quantopian/zipline","owner":{"login":"quantopian","id":1393215,"avatar_url":"https://avatars.githubusercontent.com/u/1393215?v=3","gravatar_id":"","url":"https://api.github.com/users/quantopian","html_url":"https://github.com/quantopian","followers_url":"https://api.github.com/users/quantopian/followers","following_url":"https://api.github.com/users/quantopian/following{/other_user}","gists_url":"https://api.github.com/users/quantopian/gists{/gist_id}","starred_url":"https://api.github.com/users/quantopian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quantopian/subscriptions","organizations_url":"https://api.github.com/users/quantopian/orgs","repos_url":"https://api.github.com/users/quantopian/repos","events_url":"https://api.github.com/users/quantopian/events{/privacy}","received_events_url":"https://api.github.com/users/quantopian/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/quantopian/zipline","description":"Zipline, a Pythonic Algorithmic Trading Library","fork":false,"url":"https://api.github.com/repos/quantopian/zipline","forks_url":"https://api.github.com/repos/quantopian/zipline/forks","keys_url":"https://api.github.com/repos/quantopian/zipline/keys{/key_id}","collaborators_url":"https://api.github.com/repos/quantopian/zipline/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/quantopian/zipline/teams","hooks_url":"https://api.github.com/repos/quantopian/zipline/hooks","issue_events_url":"https://api.github.com/repos/quantopian/zipline/issues/events{/number}","events_url":"https://api.github.com/repos/quantopian/zipline/events","assignees_url":"https://api.github.com/repos/quantopian/zipline/assignees{/user}","branches_url":"https://api.github.com/repos/quantopian/zipline/branches{/branch}","tags_url":"https://api.github.com/repos/quantopian/zipline/tags","blobs_url":"https://api.github.com/repos/quantopian/zipline/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/quantopian/zipline/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/quantopian/zipline/git/refs{/sha}","trees_url":"https://api.github.com/repos/quantopian/zipline/git/trees{/sha}","statuses_url":"https://api.github.com/repos/quantopian/zipline/statuses/{sha}","languages_url":"https://api.github.com/repos/quantopian/zipline/languages","stargazers_url":"https://api.github.com/repos/quantopian/zipline/stargazers","contributors_url":"https://api.github.com/repos/quantopian/zipline/contributors","subscribers_url":"https://api.github.com/repos/quantopian/zipline/subscribers","subscription_url":"https://api.github.com/repos/quantopian/zipline/subscription","commits_url":"https://api.github.com/repos/quantopian/zipline/commits{/sha}","git_commits_url":"https://api.github.com/repos/quantopian/zipline/git/commits{/sha}","comments_url":"https://api.github.com/repos/quantopian/zipline/comments{/number}","issue_comment_url":"https://api.github.com/repos/quantopian/zipline/issues/comments{/number}","contents_url":"https://api.github.com/repos/quantopian/zipline/contents/{+path}","compare_url":"https://api.github.com/repos/quantopian/zipline/compare/{base}...{head}","merges_url":"https://api.github.com/repos/quantopian/zipline/merges","archive_url":"https://api.github.com/repos/quantopian/zipline/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/quantopian/zipline/downloads","issues_url":"https://api.github.com/repos/quantopian/zipline/issues{/number}","pulls_url":"https://api.github.com/repos/quantopian/zipline/pulls{/number}","milestones_url":"https://api.github.com/repos/quantopian/zipline/milestones{/number}","notifications_url":"https://api.github.com/repos/quantopian/zipline/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/quantopian/zipline/labels{/name}","releases_url":"https://api.github.com/repos/quantopian/zipline/releases{/id}","deployments_url":"https://api.github.com/repos/quantopian/zipline/deployments","created_at":"2012-10-19T15:50:29Z","updated_at":"2016-04-15T07:47:43Z","pushed_at":"2016-04-15T14:32:44Z","git_url":"git://github.com/quantopian/zipline.git","ssh_url":"git@github.com:quantopian/zipline.git","clone_url":"https://github.com/quantopian/zipline.git","svn_url":"https://github.com/quantopian/zipline","homepage":"","size":17697,"stargazers_count":3090,"watchers_count":3090,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":915,"mirror_url":null,"open_issues_count":153,"forks":915,"open_issues":153,"watchers":3090,"default_branch":"master"}},"base":{"label":"quantopian:master","ref":"master","sha":"c9c956124a81eed2f52bad8dd88892cd0b638f18","user":{"login":"quantopian","id":1393215,"avatar_url":"https://avatars.githubusercontent.com/u/1393215?v=3","gravatar_id":"","url":"https://api.github.com/users/quantopian","html_url":"https://github.com/quantopian","followers_url":"https://api.github.com/users/quantopian/followers","following_url":"https://api.github.com/users/quantopian/following{/other_user}","gists_url":"https://api.github.com/users/quantopian/gists{/gist_id}","starred_url":"https://api.github.com/users/quantopian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quantopian/subscriptions","organizations_url":"https://api.github.com/users/quantopian/orgs","repos_url":"https://api.github.com/users/quantopian/repos","events_url":"https://api.github.com/users/quantopian/events{/privacy}","received_events_url":"https://api.github.com/users/quantopian/received_events","type":"Organization","site_admin":false},"repo":{"id":6297520,"name":"zipline","full_name":"quantopian/zipline","owner":{"login":"quantopian","id":1393215,"avatar_url":"https://avatars.githubusercontent.com/u/1393215?v=3","gravatar_id":"","url":"https://api.github.com/users/quantopian","html_url":"https://github.com/quantopian","followers_url":"https://api.github.com/users/quantopian/followers","following_url":"https://api.github.com/users/quantopian/following{/other_user}","gists_url":"https://api.github.com/users/quantopian/gists{/gist_id}","starred_url":"https://api.github.com/users/quantopian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quantopian/subscriptions","organizations_url":"https://api.github.com/users/quantopian/orgs","repos_url":"https://api.github.com/users/quantopian/repos","events_url":"https://api.github.com/users/quantopian/events{/privacy}","received_events_url":"https://api.github.com/users/quantopian/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/quantopian/zipline","description":"Zipline, a Pythonic Algorithmic Trading Library","fork":false,"url":"https://api.github.com/repos/quantopian/zipline","forks_url":"https://api.github.com/repos/quantopian/zipline/forks","keys_url":"https://api.github.com/repos/quantopian/zipline/keys{/key_id}","collaborators_url":"https://api.github.com/repos/quantopian/zipline/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/quantopian/zipline/teams","hooks_url":"https://api.github.com/repos/quantopian/zipline/hooks","issue_events_url":"https://api.github.com/repos/quantopian/zipline/issues/events{/number}","events_url":"https://api.github.com/repos/quantopian/zipline/events","assignees_url":"https://api.github.com/repos/quantopian/zipline/assignees{/user}","branches_url":"https://api.github.com/repos/quantopian/zipline/branches{/branch}","tags_url":"https://api.github.com/repos/quantopian/zipline/tags","blobs_url":"https://api.github.com/repos/quantopian/zipline/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/quantopian/zipline/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/quantopian/zipline/git/refs{/sha}","trees_url":"https://api.github.com/repos/quantopian/zipline/git/trees{/sha}","statuses_url":"https://api.github.com/repos/quantopian/zipline/statuses/{sha}","languages_url":"https://api.github.com/repos/quantopian/zipline/languages","stargazers_url":"https://api.github.com/repos/quantopian/zipline/stargazers","contributors_url":"https://api.github.com/repos/quantopian/zipline/contributors","subscribers_url":"https://api.github.com/repos/quantopian/zipline/subscribers","subscription_url":"https://api.github.com/repos/quantopian/zipline/subscription","commits_url":"https://api.github.com/repos/quantopian/zipline/commits{/sha}","git_commits_url":"https://api.github.com/repos/quantopian/zipline/git/commits{/sha}","comments_url":"https://api.github.com/repos/quantopian/zipline/comments{/number}","issue_comment_url":"https://api.github.com/repos/quantopian/zipline/issues/comments{/number}","contents_url":"https://api.github.com/repos/quantopian/zipline/contents/{+path}","compare_url":"https://api.github.com/repos/quantopian/zipline/compare/{base}...{head}","merges_url":"https://api.github.com/repos/quantopian/zipline/merges","archive_url":"https://api.github.com/repos/quantopian/zipline/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/quantopian/zipline/downloads","issues_url":"https://api.github.com/repos/quantopian/zipline/issues{/number}","pulls_url":"https://api.github.com/repos/quantopian/zipline/pulls{/number}","milestones_url":"https://api.github.com/repos/quantopian/zipline/milestones{/number}","notifications_url":"https://api.github.com/repos/quantopian/zipline/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/quantopian/zipline/labels{/name}","releases_url":"https://api.github.com/repos/quantopian/zipline/releases{/id}","deployments_url":"https://api.github.com/repos/quantopian/zipline/deployments","created_at":"2012-10-19T15:50:29Z","updated_at":"2016-04-15T07:47:43Z","pushed_at":"2016-04-15T14:32:44Z","git_url":"git://github.com/quantopian/zipline.git","ssh_url":"git@github.com:quantopian/zipline.git","clone_url":"https://github.com/quantopian/zipline.git","svn_url":"https://github.com/quantopian/zipline","homepage":"","size":17697,"stargazers_count":3090,"watchers_count":3090,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":915,"mirror_url":null,"open_issues_count":153,"forks":915,"open_issues":153,"watchers":3090,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/quantopian/zipline/pulls/1131"},"html":{"href":"https://github.com/quantopian/zipline/pull/1131"},"issue":{"href":"https://api.github.com/repos/quantopian/zipline/issues/1131"},"comments":{"href":"https://api.github.com/repos/quantopian/zipline/issues/1131/comments"},"review_comments":{"href":"https://api.github.com/repos/quantopian/zipline/pulls/1131/comments"},"review_comment":{"href":"https://api.github.com/repos/quantopian/zipline/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/quantopian/zipline/pulls/1131/commits"},"statuses":{"href":"https://api.github.com/repos/quantopian/zipline/statuses/1ee3c5f04968ab2b1ab4ff334c1cdefe487e7927"}}}}