示例#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
示例#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
示例#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
示例#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