def __init__(self): """ """ self._csv = CsvSource(''.join([os.getcwd(), os.sep, 'data', os.sep])) self._sql = SqlLiteSource(''.join( [os.getcwd(), os.sep, 'data', os.sep, 'digger.db'])) self._db = self._csv # 设置数据源
def __init__(self): """ """ self._csv = CsvSource(os.path.join(os.getcwd(), 'data')) self._sql = SqlLiteSource( os.path.join(os.getcwd(), 'data', 'digger.db')) self._src = self._csv # 设置数据源
def set_source(self, settings): if settings['source'] == 'sqlite': try: import sqlite3 path = os.path.join(settings['data_path'], 'digger.db') self._src = SqlLiteSource(path) except sqlite3.OperationalError: raise FileDoesNotExist(file=path) elif settings['source'] == 'csv': self._src = CsvSource(settings['data_path']) try: Contract.info = self.get_contracts() except Exception, e: ## @TODO pass
class LocalData(object): """ 本地数据代理根据配置决定数据源的类型, 比如sqlite, csv, pytable """ def __init__(self): """ """ self._csv = CsvSource(''.join([os.getcwd(), os.sep, 'data', os.sep])) self._sql = SqlLiteSource(''.join([os.getcwd(), os.sep, 'data', os.sep, 'digger.db'])) def load_bars(self, pcontract, dt_start, dt_end): dt_start = pd.to_datetime(dt_start) dt_end = pd.to_datetime(dt_end) if pcontract.contract.exch_type == 'stock': return [] else: return self._csv.load_bars(pcontract, dt_start, dt_end); def loadTickData(self): raise NotImplementedError def loadContractsInfo(self): """ 合约信息 """ raise NotImplementedError
def __init__(self): """ """ self._csv = CsvSource(''.join([os.getcwd(), os.sep, 'data', os.sep])) self._sql = SqlLiteSource(''.join([os.getcwd(), os.sep, 'data', os.sep, 'digger.db']))