Skip to content

Commit

Permalink
Merge pull request #23 from mostafahadian/improve-nearest-time-perfor…
Browse files Browse the repository at this point in the history
…mance

Improve performance of nearest_time method
  • Loading branch information
AminHP authored Mar 15, 2022
2 parents 240b705 + 0c27d4d commit 561fb69
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gym_mtsim/simulator/mt_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ def nearest_time(self, symbol: str, time: datetime) -> datetime:
if time in df.index:
return time
try:
i = df.index.get_loc(time, method='ffill')
i, = df.index.get_indexer([time], method='ffill')
except KeyError:
i = df.index.get_loc(time, method='bfill')
i, = df.index.get_indexer([time], method='bfill')
return df.index[i]


Expand Down

0 comments on commit 561fb69

Please sign in to comment.