Esempio n. 1
0
 def save_data(self, csv):
     """Save Google Finance csv to Numpy array."""
     self.preallocate(len(csv) - 7)
     for row in xrange(7, len(csv)):
         if csv[row].count(',') != 5: 
             continue
         timestamp, c, h, l, o, volume = csv[row].split(',')
         if timestamp[0] == 'a':
             day = float(timestamp[1:])
             timestamp = 0
         else:
             timestamp = float(timestamp)
         o, h, l, c = [float(x) for x in [o, h, l, c]]
         time_num = day + self.interval_s * timestamp
         self.timestamps[row - 7] = time_num
         self.oprices[row - 7] = o
         self.hprices[row - 7] = h
         self.lprices[row - 7] = l
         self.cprices[row - 7] = c
         self.volumes[row - 7] = volume
     self.first_time = posix_as_str(min(self.timestamps))
     self.end_time = posix_as_str(max(self.timestamps))
Esempio n. 2
0
 def first_day(self):
     """The earliest date as string."""
     if len(self.timestamps) is 0:
         return nan
     return cv.posix_as_str(min(self.timestamps))[:10]
Esempio n. 3
0
 def timestrings(self):
     """Get timestamps in YYYY-MM-DD HH:MM:SS.f string format."""
     return cv.posix_as_str(self.timestamps)
Esempio n. 4
0
 def last_day(self):
     """The latest date as string."""
     if len(self.timestamps) is 0:
         return nan
     return cv.posix_as_str(max(self.timestamps))[:10]