MAINT: Use searchsorted instead of bisect on treasury curves.

Remove use of .keys() and creation of a new list of the curve
Series's values.
This commit is contained in:
Eddie Hebert
2013-04-03 15:55:04 -04:00
parent bb3e9727dc
commit a66d6866f5
+2 -3
View File
@@ -58,7 +58,6 @@ Risk Report
import logbook
import datetime
import math
import bisect
import numpy as np
import numpy.linalg as la
from dateutil.relativedelta import relativedelta
@@ -242,10 +241,10 @@ def choose_treasury(treasury_curves, start_date, end_date):
if not search_day:
# in case end date is not a trading day or there is no treasury
# data, search for the previous day with an interest rate.
search_days = treasury_curves.keys()
search_days = treasury_curves.index
# Find rightmost value less than or equal to end_day
i = bisect.bisect_right(search_days, end_day)
i = search_days.searchsorted(end_day)
for prev_day in search_days[i - 1::-1]:
rate = get_treasury_rate(treasury_curves,
treasury_duration,