File tree Expand file tree Collapse file tree 3 files changed +28
-3
lines changed Expand file tree Collapse file tree 3 files changed +28
-3
lines changed Original file line number Diff line number Diff line change 1+ # extrapolate backward:
2+ loc_linear = _date_to_iloc_linear (dtseries ,date )
3+ first = _date_to_mdate (dtseries .index [0 ])
4+ last = _date_to_mdate (dtseries .index [- 1 ])
5+ avg_days_between_points = (last - first )/ float (len (dtseries ))
6+ if avg_days_between_points > 0.33 : # daily (not intraday)
7+ delta = _date_to_mdate (dtseries .index [0 ]) - _date_to_mdate (date )
8+ loc_5_7ths = - (5. / 7. )* delta
9+ loc = (loc_linear + loc_5_7ths )/ 2.0
10+ else :
11+ loc = loc_linear
12+ return loc
Original file line number Diff line number Diff line change 1+ # extrapolate forward:
2+ loc_linear = _date_to_iloc_linear (dtseries ,date )
3+ first = _date_to_mdate (dtseries .index [0 ])
4+ last = _date_to_mdate (dtseries .index [- 1 ])
5+ avg_days_between_points = (last - first )/ float (len (dtseries ))
6+ if avg_days_between_points > 0.33 : # daily (not intraday)
7+ delta = _date_to_mdate (date ) - _date_to_mdate (dtseries .index [- 1 ])
8+ loc_5_7ths = len (dtseries ) - 1 + (5 / 7. )* delta
9+ loc = (loc_linear + loc_5_7ths )/ 2.0
10+ else :
11+ loc = loc_linear
12+ return loc
Original file line number Diff line number Diff line change @@ -224,9 +224,10 @@ def _date_to_iloc(dtseries,date):
224224
225225def _date_to_iloc_linear (dtseries ,date ,trace = False ):
226226 '''Find the location of a date using linear extrapolation.
227- Use the endpoints of `dtseriews` to the slope and yintercept
228- for the line: iloc = (slope)*(dtseries) + (yintercept)
229- The use them to calculate the location of `date`
227+ Use the endpoints of `dtseries` to calculate the slope
228+ and yintercept for the line:
229+ iloc = (slope)*(dtseries) + (yintercept)
230+ Then use them to calculate the location of `date`
230231 '''
231232 d1 = _date_to_mdate (dtseries .index [0 ])
232233 d2 = _date_to_mdate (dtseries .index [- 1 ])
You can’t perform that action at this time.
0 commit comments