def env(cls, code): from fxdayu_sinta.IO import ENV_TAG from fxdayu_sinta.IO.master import Master env = globals()[ENV_TAG] return cls( Master(env.file_root, code), env.db_manager[code] )
def create_stock(code, start, end, cover): master = Master.env(code) freq = Freq.env(code) if not os.path.exists(master.dir): os.makedirs(master.dir) if (not master.exist) or cover: master.create(start, end) master.flush() click.echo("Create master %s" % code) if (not freq.exist) or cover: freq.create() freq.flush() click.echo("Create freq %s" % code)
def check(self): if not os.path.exists(self.env.file_root): click.echo('File root dir: %s does not exist' % self.env.file_root) return else: for code in self.env.stocks: if Master.env(code).exist: click.echo("%s master OK" % code) else: click.echo("%s master missing" % code) if Freq.env(code).exist: click.echo("%s freq OK" % code) else: click.echo("%s freq missing" % code)
def save_stock(self, code, start, end): master = Master(self.root, code) for date in master.find(0, start, end): result = self.save_tick(master, date) self.logger.info("tick %s %s %s" % result) sleep(1)
def env(cls, code): env = get_env() return cls( Master(env.file_root, code), env.db_manager[code] )
def config(cls, code): from fxdayu_sinta.IO.master import Master from fxdayu_sinta.IO.db_manager import DBManager return cls(Master.config(code), DBManager.config()[code])
def iter_freq(self, freq): for code in self.field: yield Freq.env(code), self.env.db_manager[code, freq], Master.env( code), self.env.db_manager[code]
def iter_main(self): for code in self.field: yield Master.env(code), self.env.db_manager[code]