def load(self): print 'Loading data file', self.filename if os.path.exists(self.filename): self.scid = ScidFile() self.scid.load(self.filename) else: self.scid = ScidFile.create(self.filename) self.scid.seek(self.scid.length)
parser.add_option("-b", "--bootstrap", dest="bootstrap", default=None, metavar="FILE", help="Bootstrap history from a .csv file") (options, args) = parser.parse_args() if options.bootstrap: base_filename, _, _ = options.bootstrap.rpartition('.') scid_filename = "%s.scid" % base_filename if os.path.exists(scid_filename): print "{} already exists, aborting bootstrap.".format(scid_filename) sys.exit() with open(options.bootstrap) as f: data = f.read().split("\n") scid = ScidFile.create(scid_filename) for rec in scid_from_csv(data, base_filename, options.precision): scid.write(rec.to_struct()) scid.fp.flush() scid.close() print "Bootstrap finished." sys.exit() if options.precision < 0 or options.precision > 8: print "Precision must be between 0 and 8" sys.exit() # Symbols to watch symbols = options.symbols.split(',') scids = ScidLoader(options.datadir, options.disable_history, options.precision, options.length)