예제 #1
0
파일: test.py 프로젝트: walkacross/quant_at
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)
예제 #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
예제 #3
0
파일: test.py 프로젝트: caitouwh/quant_at
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
예제 #4
0
파일: test.py 프로젝트: walkacross/quant_at
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)
예제 #5
0
파일: test.py 프로젝트: caitouwh/quant_at
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
예제 #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