Exemplo n.º 1
0
def test_is_able_to_close_via_reduce_postion_too():
    set_up()

    p = Position(exchanges.SANDBOX, 'BTC-USD', {
        'entry_price': 50,
        'current_price': 50,
        'qty': 2,
    })

    p._reduce(2, 50)

    assert p.qty == 0
Exemplo n.º 2
0
def test_reduce_a_short_position():
    set_up()

    p = Position(exchanges.SANDBOX, 'BTC-USD', {
        'entry_price': 50,
        'current_price': 50,
        'qty': -2,
    })

    p._reduce(1, 50)

    assert p.qty == -1
Exemplo n.º 3
0
def test_is_able_to_close_via_reduce_postion_too():
    set_up()

    p = Position(exchanges.SANDBOX, 'BTCUSD', {
        'entry_price': 50,
        'current_price': 50,
        'qty': 2,
    })
    e = selectors.get_exchange('Sandbox')

    p._reduce(2, 50)

    assert p.qty == 0
    assert e.balance == 1100
Exemplo n.º 4
0
def test_reduce_a_short_position():
    set_up()

    p = Position(exchanges.SANDBOX, 'BTCUSD', {
        'entry_price': 50,
        'current_price': 50,
        'qty': -2,
    })
    e = selectors.get_exchange('Sandbox')

    p._reduce(1, 50)

    assert p.qty == -1
    assert e.balance == 1050