def __init__(self, period, db_model=None, table_name=None, save_tick=False): """ 接收数据,并插入到对应数据库 :param period: 周期 :param db_model: 模型 :param table_name: 表名 """ self.period = period self.save_tick = save_tick if db_model is not None: self.table_name = db_model.__tablename__ self.md_orm_table = db_model.__table__ elif table_name is not None: self.table_name = table_name self.md_orm_table = Table(table_name, MetaData(engine_md), autoload=True) baseHandler.__init__(self, 'DB[%s]' % self.table_name) self.session_maker = sessionmaker(bind=engine_md) self.session = None self.logger = logging.getLogger(f'DBHandler->{self.table_name}') self.md_orm_table_insert = self.md_orm_table.insert( on_duplicate_key_update=True) self.last_tick, self.ts_start_last_tick = {}, {}
def __init__(self, market=Config.MARKET_NAME): baseHandler.__init__(self, name=self.__class__.__name__) self.market = market self.logger = logging.getLogger(self.__class__.__name__) self.r = get_redis() # 记录上一个tick的 st_start 用于判断是否开始分钟切换,key 是 (period, pair) self.last_ts_start_pair_tick = {} self.last_tick_pair_tick = {}
def __init__(self, market='huobi'): baseHandler.__init__(self, name=self.__class__.__name__) self.market = market self.logger = logging.getLogger(self.__class__.__name__) self.r = get_redis() # 记录上一个tick的 st_start 用于判断是否开始分钟切换,key 是 (period, pair) self.last_ts_start_pair_tick = {} self.last_tick_pair_tick = {}
def __init__(self, period, db_model=None, table_name=None, save_tick=False): """ 接收数据,并插入到对应数据库 :param period: 周期 :param db_model: 模型 :param table_name: 表名 """ self.period = period self.save_tick = save_tick if db_model is not None: self.table_name = db_model.__tablename__ self.md_orm_table = db_model.__table__ elif table_name is not None: self.table_name = table_name self.md_orm_table = Table(table_name, MetaData(engine_md), autoload=True) baseHandler.__init__(self, 'DB[%s]' % self.table_name) self.session_maker = sessionmaker(bind=engine_md) self.session = None self.logger = logging.getLogger(f'DBHandler->{self.table_name}') self.md_orm_table_insert = self.md_orm_table.insert(on_duplicate_key_update=True) self.last_tick, self.ts_start_last_tick = {}, {}
def __init__(self): baseHandler.__init__(self, name=self.__class__.__name__) self.time = datetime.now()