Exemple #1
0
def test_collate_data_function():
    def f(x):
        return pd.read_csv(x).iloc[:10, :3]

    df = collate_data("tests/data/NASDAQ/data", function=f)
    assert len(df) == 80
    assert df.shape == (80, 3)
Exemple #2
0
def test_collate_data():
    df = collate_data("tests/data/NASDAQ/data", parse_dates=["Date"])
    df = df.rename(lambda x: x.lower(), axis="columns")
    df = df.sort_values(by=["date", "symbol"])
    engine = create_engine("sqlite://")
    dl = DataLoader(directory="tests/data/NASDAQ/data",
                    mode="SQL",
                    engine=engine,
                    tablename="eod")
    dl.load_data()
    df2 = pd.read_sql_table("eod", engine).sort_values(by=["date", "symbol"])
    assert len(df) == len(df2)
    for i in range(100):
        assert compare(df, df2)
Exemple #3
0
def test_collate_data():
    df = collate_data('tests/data/NASDAQ/data', parse_dates=['Date'])
    df = df.rename(lambda x: x.lower(), axis='columns')
    df = df.sort_values(by=['date', 'symbol'])
    engine = create_engine('sqlite://')
    dl = DataLoader(directory='tests/data/NASDAQ/data',
                    mode='SQL',
                    engine=engine,
                    tablename='eod')
    dl.load_data()
    df2 = pd.read_sql_table('eod', engine).sort_values(by=['date', 'symbol'])
    assert len(df) == len(df2)
    for i in range(100):
        assert compare(df, df2)
Exemple #4
0
def test_collate_data_concat_false_two():
    df = collate_data("tests/data/NASDAQ/data",
                      function=lambda x: x.split("/")[-1],
                      concat=False)
    assert len(df) == 8
    assert "NASDAQ_20180731.zip" in df
Exemple #5
0
def test_collate_data_concat_false_one():
    def f(x):
        return pd.read_csv(x).iloc[:10, :3]

    df = collate_data("tests/data/NASDAQ/data", function=f, concat=False)
    assert len(df) == 8
Exemple #6
0
def test_collate_data_concat_false_two():
    df = collate_data('tests/data/NASDAQ/data',
                      function=lambda x: x.split('/')[-1],
                      concat=False)
    assert len(df) == 8
    assert 'NASDAQ_20180731.zip' in df