def __init__(self, str_contract): info = str_contract.split('.') if len(info) == 2: code = info[0].upper() exchange = info[1].upper() else: logger.error('错误的合约格式!') assert (False) self.exchange = exchange self.code = code if self.exchange == 'SZ' or self.exchange == 'SH': self.is_stock = True elif self.exchange == 'SHFE': self.is_stock = False elif self.exchange == 'TEST' and self.code == 'STOCK': self.is_stock = True elif self.exchange == 'TEST': self.is_stock = False
def __init__(self, str_contract): ## @TODO 修改参数为(code, exchange) info = str_contract.split('.') if len(info) == 2: code = info[0].upper() exchange = info[1].upper() else: logger.error('错误的合约格式: %s' % str_contract) logger.exception() self.exchange = exchange self.code = code if self.exchange == 'SZ' or self.exchange == 'SH': self.is_stock = True elif self.exchange == 'SHFE': self.is_stock = False elif self.exchange == 'TEST' and self.code == 'STOCK': self.is_stock = True elif self.exchange == 'TEST': self.is_stock = False else: logger.error('Unknown exchange: {0}', self.exchange) assert (False)
def __init__(self, str_contract): ## @TODO 修改参数为(code, exchange) info = str_contract.split('.') if len(info) == 2: code = info[0].upper() exchange = info[1].upper() else: logger.error('错误的合约格式: %s' % str_contract) logger.exception() self.exchange = exchange self.code = code if self.exchange == 'SZ' or self.exchange == 'SH': self.is_stock = True elif self.exchange == 'SHFE': self.is_stock = False elif self.exchange == 'TEST' and self.code == 'STOCK': self.is_stock = True elif self.exchange == 'TEST': self.is_stock = False else: logger.error('Unknown exchange: {0}', self.exchange) assert(False)