Beispiel #1
0
def test_revenuebeforelastTrade():
    t = Trades()
    t.sell(Trade(0.0, -1, "S", 1.0))
    t.sell(Trade(1.0, -1, "S", 1.0))

    assert -1.0 == t.revenue(0.1)
Beispiel #2
0
def test_sellTwodifferent_revenueminusTwo():
    t = Trades()
    t.sell(Trade(0.0, -1, "S", 1.0))
    t.sell(Trade(0.0, -1, "D", 1.0))

    assert -2.0 == t.revenue(1)
Beispiel #3
0
def test_buyOnesellOne_sameDate():
    t = Trades()
    t.buy(Trade(0.0, 1, "S", 1.0))
    t.sell(Trade(0.0, -1, "S", 1.0))

    assert 0.0 == t.expense(1) + t.revenue(1)
Beispiel #4
0
def test_buyOneSellOne_revenueIsminusOne():
    t = Trades()
    t.buy(Trade(0.0, 1, "S", 1.0))
    t.sell(Trade(1.0, -1, "S", 1.0))

    assert -1.0 == t.revenue(2)
Beispiel #5
0
def test_buyOneSellOne_expenseIsOne():
    t = Trades()
    t.buy(Trade(0.0, 1, "S", 1.0))
    t.sell(Trade(1.0, -1, "S", 1.0))

    assert 1.0 == t.expense(2)
Beispiel #6
0
def test_sellAtLeastOne():
    t = Trades()
    with pytest.raises(Exception):
        t.sell(Trade(0.0, 0, "S", 1.0))