Esempio n. 1
0
def test_expensebeforelastTrade():
    t = Trades()
    t.buy(Trade(0.0, 1, "S", 1.0))
    t.buy(Trade(1.0, 1, "S", 1.0))

    assert 1.0 == t.expense(0.1)
Esempio n. 2
0
def test_buyOne_expenseIsOne():
    t = Trades()
    t.buy(Trade(0.0, 1, "S", 1.0))

    assert 1.0 == t.expense(0.1)
Esempio n. 3
0
def test_buyTwodifferent_expenseTwo():
    t = Trades()
    t.buy(Trade(0.0, 1, "S", 1.0))
    t.buy(Trade(0.0, 1, "D", 1.0))

    assert 2.0 == t.expense(1)
Esempio n. 4
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)
Esempio n. 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)
Esempio n. 6
0
def test_buyOne_expenseIsZeroBeforeBuy():
    t = Trades()
    t.buy(Trade(0.0, 1, "S", 1.0))

    assert 0.0 == t.expense(date=-1)