Example #1
0
def test_simple():
    db = init()
    futures.download_data(downloader=fake_download_1,
                          today=fake_today_1,
                          db=testdb,
                          years=(1984, 1985),
                          fin="futures.csv")
    res = futures.get(market="CME",
                      sym="CL",
                      month="F",
                      year=1984,
                      dt=19831205,
                      db=testdb)
    assert (res[0]['oi'] == 5027.0)
    res = futures.get(market="CME",
                      sym="CL",
                      month="G",
                      year=1984,
                      dt=19830624,
                      db=testdb)
    assert (res[0]['oi'] == 5.0)
    res = futures.last_contract("CL", "CME", db)
    assert (res[0]['_id']['month'] == 'G')
    res = futures.existing_nonexpired_contracts("CL", "CME", fake_today_1(),
                                                db)
    assert (len(res) == 0)
    res = futures.existing_nonexpired_contracts("CL", "CME", fake_today_2(),
                                                db)
    assert (len(res) > 0)
    res = futures.get_contract(market="CME",
                               sym="CL",
                               month="G",
                               year=1984,
                               db=testdb)
    assert (len(res) == 143)
Example #2
0
def test_incremental():
    db = init()
    futures.download_data(downloader=fake_download_2, today=fake_today_726, db=testdb, years=(1984, 1985))
    print futures.last_date_in_contract("CL", "CME", "F", 1984, db)
    assert futures.last_date_in_contract("CL", "CME", "F", 1984, db) == 19830726
    futures.download_data(downloader=fake_download_3, today=fake_today_727, db=testdb, years=(1984, 1985))
    assert futures.last_date_in_contract("CL", "CME", "F", 1984, db) == 19830727
Example #3
0
def test_incremental():
    db = init()
    futures.download_data(downloader=fake_download_2,today=fake_today_726,
                          db=testdb, years=(1984,1985))
    print futures.last_date_in_contract("CL","CME","F", 1984, db)
    assert futures.last_date_in_contract("CL","CME","F", 1984, db) == 19830726    

    futures.download_data(downloader=fake_download_3,today=fake_today_727,
                          db=testdb, years=(1984,1985))
    assert futures.last_date_in_contract("CL","CME","F", 1984, db) == 19830727
Example #4
0
def test_missing_contract():
    db = init()
    futures.download_data(downloader=fake_download_1,
                          today=fake_today_1,
                          db=testdb,
                          years=(1984, 1985))
    res = futures.get_contract(market="CME",
                               sym="CL",
                               month="Z",
                               year=1984,
                               db=testdb)
    assert (res == None)
Example #5
0
def test_simple():
    db = init()
    futures.download_data(downloader=fake_download_1,today=fake_today_1,
                          db=testdb, years=(1984,1985))
    res = futures.get(market="CME", sym="CL", month="F", year=1984, dt=19831205, db=testdb)
    assert res[0]['oi'] == 5027.0
    res = futures.get(market="CME", sym="CL", month="G", year=1984, dt=19830624, db=testdb)
    assert res[0]['oi'] == 5.0
    res = futures.last_contract("CL","CME", db)
    assert res[0]['_id']['month'] == 'G'

    res = futures.existing_nonexpired_contracts("CL","CME", fake_today_1(), db)
    assert len(res) == 0
    res = futures.existing_nonexpired_contracts("CL","CME", fake_today_2(), db)
    assert len(res) > 0
Example #6
0
def test_missing_contract():
    db = init()
    futures.download_data(downloader=fake_download_1, today=fake_today_1, db=testdb, years=(1984, 1985))
    res = futures.get_contract(market="CME", sym="CL", month="Z", year=1984, db=testdb)
    assert res == None