Adjust initial balance in live tests
This commit is contained in:
parent
8bb5c2c91b
commit
a840be3834
|
@ -103,7 +103,7 @@ If you have done this, please see the following line for more information:
|
|||
exchange=exchange,
|
||||
api_key=api_key,
|
||||
api_secret=api_secret,
|
||||
initial_balance=100,
|
||||
initial_balance=100000,
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
|
|
|
@ -135,24 +135,24 @@ class LiveTradingTestCase(ElasticMock, LiveBase, TestCase):
|
|||
)
|
||||
return complex_trade
|
||||
|
||||
@patch("core.exchanges.oanda.OANDAExchange.get_balance", return_value=100)
|
||||
@patch("core.exchanges.oanda.OANDAExchange.get_balance", return_value=100000)
|
||||
def test_check_risk_max_risk_pass(self, mock_balance):
|
||||
# SL of 19% on a 10 trade on a 100 account is 1.8 loss
|
||||
# SL of 19% on a 10000 trade on a 100000 account is 1.8 loss
|
||||
# Should be comfortably under 2% risk
|
||||
trade = self.create_complex_trade("buy", 10, "EUR_USD", 1, 18)
|
||||
trade = self.create_complex_trade("buy", 10000, "EUR_USD", 1, 18)
|
||||
allowed = risk.check_risk(self.risk_model, self.account, trade)
|
||||
self.assertTrue(allowed["allowed"])
|
||||
|
||||
@patch("core.exchanges.oanda.OANDAExchange.get_balance", return_value=100)
|
||||
@patch("core.exchanges.oanda.OANDAExchange.get_balance", return_value=100000)
|
||||
def test_check_risk_max_risk_fail(self, mock_balance):
|
||||
# SL of 21% on a 10 trade on a 100 account is 2.2 loss
|
||||
# SL of 21% on a 10000 trade on a 100000 account is 2.2 loss
|
||||
# Should be over 2% risk
|
||||
trade = self.create_complex_trade("buy", 10, "EUR_USD", 1, 22)
|
||||
trade = self.create_complex_trade("buy", 10000, "EUR_USD", 1, 22)
|
||||
allowed = risk.check_risk(self.risk_model, self.account, trade)
|
||||
self.assertFalse(allowed["allowed"])
|
||||
self.assertEqual(allowed["reason"], "Maximum risk exceeded.")
|
||||
|
||||
@patch("core.exchanges.oanda.OANDAExchange.get_balance", return_value=94)
|
||||
@patch("core.exchanges.oanda.OANDAExchange.get_balance", return_value=94000)
|
||||
# We have lost 6% of our account
|
||||
def test_check_risk_max_loss_fail(self, mock_balance):
|
||||
# Doesn't matter, shouldn't get as far as the trade
|
||||
|
@ -161,7 +161,7 @@ class LiveTradingTestCase(ElasticMock, LiveBase, TestCase):
|
|||
self.assertFalse(allowed["allowed"])
|
||||
self.assertEqual(allowed["reason"], "Maximum loss exceeded.")
|
||||
|
||||
@patch("core.exchanges.oanda.OANDAExchange.get_balance", return_value=100)
|
||||
@patch("core.exchanges.oanda.OANDAExchange.get_balance", return_value=100000)
|
||||
def test_check_risk_max_open_trades_fail(self, mock_balance):
|
||||
# The maximum open trades is 3. Let's open 2 trades
|
||||
# This would not be allowed by the risk model but we're doing it
|
||||
|
@ -184,7 +184,7 @@ class LiveTradingTestCase(ElasticMock, LiveBase, TestCase):
|
|||
self.close_trade(trade1)
|
||||
self.close_trade(trade2)
|
||||
|
||||
@patch("core.exchanges.oanda.OANDAExchange.get_balance", return_value=100)
|
||||
@patch("core.exchanges.oanda.OANDAExchange.get_balance", return_value=100000)
|
||||
def test_check_risk_max_open_trades_per_symbol_fail(self, mock_balance):
|
||||
trade1 = self.create_complex_trade("buy", 1, "EUR_USD", 1, 1)
|
||||
self.open_trade(trade1)
|
||||
|
|
Loading…
Reference in New Issue