MCPcopy Create free account
hub / github.com/dabeaz-course/practical-python / reset

Method reset

Work/Data/stocksim.py:71–86  ·  view source on GitHub ↗
(self,time)

Source from the content-addressed store, hash-verified

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

Callers 2

resetMethod · 0.45
stocksim.pyFile · 0.45

Calls 1

updateMethod · 0.95

Tested by

no test coverage detected