def test_increase_a_long_position(): set_up() p = Position(exchanges.SANDBOX, 'BTC-USDT', { 'entry_price': 50, 'current_price': 50, 'qty': 2, }) p._increase(2, 100) assert p.qty == 4 assert p.entry_price == 75
def test_increase_a_short_position(): set_up() p = Position(exchanges.SANDBOX, 'BTC-USD', { 'entry_price': 50, 'current_price': 50, 'qty': -2, }) p._increase(2, 40) assert p.qty == -4 assert p.entry_price == 45
def test_increase_a_short_position(): set_up() p = Position(exchanges.SANDBOX, 'BTCUSD', { 'entry_price': 50, 'current_price': 50, 'qty': -2, }) e = selectors.get_exchange('Sandbox') p._increase(2, 40) assert p.qty == -4 assert p.entry_price == 45 assert e.balance == 920