Skip to content

Commit

Permalink
Merge pull request #115 from fuzzyhandle/master
Browse files Browse the repository at this point in the history
Special situations where weekend is a working day
  • Loading branch information
swapniljariwala authored Feb 18, 2020
2 parents 76b1f5a + fb851d4 commit b3a9f3d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
20 changes: 19 additions & 1 deletion nsepy/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,23 @@ def getworkingdays(dtfrom, dtto):
stweekends.add(dt)

# pdb.set_trace()
stspecial = set(
[datetime.date(2020,2,1) # Budget day
]
)

#Remove special weekend working days from weekends set
stweekends -= stspecial
stworking = (stalldays - stweekends) - set(dfholiday.index.values)
return sorted(stworking)
# stworking = (stalldays - stweekends) - set(dfholiday.index.values)

# #Special cases where market was open on weekends
# stspecial = set(
# [datetime.date(2020,2,1) # Budget day
# ]
# )
# for dtspecial in stspecial:
# if (dtspecial >= dtfrom and dtspecial <= dtto):
# stworking.add(dtspecial)

return sorted(stworking)
6 changes: 6 additions & 0 deletions tests/test_live.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,9 @@ def test_working_day(self):
workingdays = getworkingdays(datetime.date(
2019, 3, 1), datetime.date(2019, 3, 31))
self.assertEqual(len(workingdays), 19)

# working day for special dates on weekend
workingdays = getworkingdays(datetime.date(
2020, 1, 31), datetime.date(2020, 2, 3))
self.assertEqual(len(workingdays), 3)

0 comments on commit b3a9f3d

Please sign in to comment.