Skip to content

Commit

Permalink
Add error handling for verify_min_times function.
Browse files Browse the repository at this point in the history
  • Loading branch information
camisatx committed Mar 18, 2016
1 parent c5c23f4 commit 920ddc4
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions pySecMaster/utilities/verify_min_times.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,20 +212,25 @@ def split_day(row, column):
prior_date = price_df.iloc[(index - 1), price_df.columns.get_loc('day')]
if prior_date != row['day']:
# This is the first time for this day
next_time = price_df.iloc[(index + 1),
price_df.columns.get_loc('date_obj')]
# -60 indicates the next period is 1 min away (normal).
# +3480, +3300 indicates the the next period is behind this time
# by roughly an hour.
next_time_delta = row['date_obj'] - next_time

if int(next_time_delta.total_seconds()) >= (10*60):
# This time period was not effected by the unix bug, but needs
# to be moved back by the next time period delta (plus 1 min)
# so it will be aligned with the other times so that when the
# adjustment occurs below, all times will be aligned.
price_df.loc[index, 'date_obj'] -= \
timedelta(seconds=next_time_delta.total_seconds() + 60)
try:
next_time = price_df.iloc[(index + 1),
price_df.columns.get_loc('date_obj')]
except IndexError:
pass
finally:
# -60 indicates the next period is 1 min away (normal).
# +3480, +3300 indicates the the next period is behind this time
# by roughly an hour.
next_time_delta = row['date_obj'] - next_time

if int(next_time_delta.total_seconds()) >= (10*60):
# This time period was not effected by the unix bug, but
# needs to be moved back by the next time period delta
# (plus 1 min) so it will be aligned with the other times
# so that when the adjustment occurs below, all times
# will be aligned.
price_df.loc[index, 'date_obj'] -= \
timedelta(seconds=next_time_delta.total_seconds() + 60)

day_time_delta = day_adjustments[row['day']]
cur_time = {}
Expand Down

0 comments on commit 920ddc4

Please sign in to comment.