예제 #1
0
def test_evaluate_profitable():
    market = Market('test', 0, '', 'SingleMarket')
    c1 = Contract('test', 'test1', '')
    c2 = Contract('test', 'test2', '')
    c3 = Contract('test', 'test3', '')

    c1.short_offers = [ Offer(c1, 'NO', .4, 10) ]
    c2.short_offers = [ Offer(c2, 'NO', .6, 10) ]
    c3.short_offers = [ Offer(c3, 'NO', .8, 10) ]


    market.contracts = [ c1, c2, c3 ]

    r = buy_no.evaluate(market)
    
    assert r is not None

    ret = r[0]
    gain = r[1]
    cost = r[2]
    shares = r[3]

    assert cost == 18
    assert shares == 10
    assert round(ret, 2) == .1
    assert round(gain, 2) == 1.8
def test_evaluate_profitable():
    market = Market("test", 0, "", "SingleMarket")
    c1 = Contract("test", "test1", "")
    c2 = Contract("test", "test2", "")
    c3 = Contract("test", "test3", "")

    c1.long_offers = [Offer(c1, "YES", 0.1, 10)]
    c2.long_offers = [Offer(c2, "YES", 0.2, 10)]
    c3.long_offers = [Offer(c3, "YES", 0.3, 10)]

    market.contracts = [c1, c2, c3]

    r = buy_yes.evaluate(market)

    assert r is not None

    ret = r[0]
    gain = r[1]
    cost = r[2]
    shares = r[3]

    assert cost == 6
    assert shares == 10
    assert round(ret, 2) == 0.6
    assert round(gain, 2) == 4
def test_evaluate_notprofitable():
    market = Market('test', 0, '', 'SingleMarket')
    c1 = Contract('test', 'test1', '')

    c1.long_offers = [ Offer(c1, 'YES', .52, 10) ]
    c1.short_offers = [ Offer(c1, 'NO', .54, 5)]


    market.contracts = [ c1 ]

    r = buy_yes_no.evaluate(market)
    
    assert r is None
def test_evaluate_notprofitable():
    market = Market("test", 0, "", "SingleMarket")
    c1 = Contract("test", "test1", "")
    c2 = Contract("test", "test2", "")
    c3 = Contract("test", "test3", "")

    c1.long_offers = [Offer(c1, "YES", 0.4, 10)]
    c2.long_offers = [Offer(c2, "YES", 0.5, 10)]
    c3.long_offers = [Offer(c3, "YES", 0.6, 10)]

    market.contracts = [c1, c2, c3]

    r = buy_yes.evaluate(market)

    assert r is None
예제 #5
0
def test_evaluate_notprofitable():
    market = Market('test', 0, '', 'SingleMarket')
    c1 = Contract('test', 'test1', '')
    c2 = Contract('test', 'test2', '')
    c3 = Contract('test', 'test3', '')

    c1.short_offers = [ Offer(c1, 'NO', .9, 10) ]
    c2.short_offers = [ Offer(c2, 'NO', .95, 10) ]
    c3.short_offers = [ Offer(c3, 'NO', .99, 10) ]


    market.contracts = [ c1, c2, c3 ]

    r = buy_no.evaluate(market)
    
    assert r is None
def test_evaluate_profitable():
    market = Market('test', 0, '', 'SingleMarket')
    c1 = Contract('test', 'test1', '')

    c1.long_offers = [ Offer(c1, 'YES', .4, 10) ]
    c1.short_offers = [ Offer(c1, 'NO', .4, 5)]

    market.contracts = [ c1 ]

    r = buy_yes_no.evaluate(market)
    
    assert r is not None

    ret = r[0]
    gain = r[1]
    cost = r[2]
    shares = r[3]

    assert shares == 5
    assert cost == 4
    assert round(ret, 2) == .23
    assert round(gain, 2) == 1
def test_evaluate_empty_market():
    market = Market('test', 0, '', 'SingleMarket')
    market.contracts = []

    r = buy_yes_no.evaluate(market)
    assert (r is None)
def test_evaluate_empty_market():
    market = Market("test", 0, "", "SingleMarket")
    market.contracts = []

    r = buy_yes.evaluate(market)
    assert r is None