MCPcopy Index your code
hub / github.com/dabeaz-course/python-mastery / reset

Method reset

Data/stocksim.py:73–88  ·  view source on GitHub ↗
(self,time)

Source from the content-addressed store, hash-verified

71 def add_data(self,record):
72 self.history.append(record)
73 def reset(self,time):
74 self.time = time
75 # Sort the history by time
76 self.history.sort(key=lambda t:t[3])
77 # Find the first entry who's time is behind the given time
78 self.index = 0
79 while self.index < len(self.history):
80 if self.history[self.index][3] > time:
81 break
82 self.index += 1
83 self.open = self.history[0][5]
84 self.initial = self.history[0][1] - self.history[0][4]
85 self.date = self.history[0][2]
86 self.update()
87 self.low = self.price
88 self.high = self.price
89
90 # Calculate interpolated value of a given field based on
91 # current time

Callers 2

resetMethod · 0.45
stocksim.pyFile · 0.45

Calls 1

updateMethod · 0.95

Tested by

no test coverage detected