예제 #1
0
class tmp_assets_db(object):
    """Create a temporary assets sqlite database.
    This is meant to be used as a context manager.

    Parameters
    ----------
    data : pd.DataFrame, optional
        The data to feed to the writer. By default this maps:
        ('A', 'B', 'C') -> map(ord, 'ABC')
    """
    def __init__(self, **frames):
        self._eng = None
        if not frames:
            frames = {
                'equities': make_simple_equity_info(
                    list(map(ord, 'ABC')),
                    pd.Timestamp(0),
                    pd.Timestamp('2015'),
                )
            }
        self._data = AssetDBWriterFromDataFrame(**frames)

    def __enter__(self):
        self._eng = eng = create_engine('sqlite://')
        self._data.write_all(eng)
        return eng

    def __exit__(self, *excinfo):
        assert self._eng is not None, '_eng was not set in __enter__'
        self._eng.dispose()
예제 #2
0
 def __init__(self, data=None):
     self._eng = None
     self._data = AssetDBWriterFromDataFrame(
         data if data is not None else make_simple_asset_info(
             list(map(ord, 'ABC')),
             pd.Timestamp(0),
             pd.Timestamp('2015'),
         ))
예제 #3
0
 def __init__(self, **frames):
     self._eng = None
     if not frames:
         frames = {
             'equities': make_simple_equity_info(
                 list(map(ord, 'ABC')),
                 pd.Timestamp(0),
                 pd.Timestamp('2015'),
             )
         }
     self._data = AssetDBWriterFromDataFrame(**frames)
예제 #4
0
파일: trading.py 프로젝트: minghui/lquant
 def _write_data_dataframes(self,
                            equities=None,
                            futures=None,
                            exchanges=None,
                            root_symbols=None):
     AssetDBWriterFromDataFrame(equities, futures, exchanges, root_symbols)\
         .write_all(self.engine)
예제 #5
0
 def __init__(self, data=None):
     self._eng = None
     self._data = AssetDBWriterFromDataFrame(
         data if data is not None else make_simple_asset_info(
             list(map(ord, 'ABC')),
             pd.Timestamp(0),
             pd.Timestamp('2015'),
         )
     )