X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FCryptoportfolio%2FTrader.git;a=blobdiff_plain;f=tests%2Ftest_market.py;fp=tests%2Ftest_market.py;h=07188aca1d7c7344d315d0501f1740fe0ed4511b;hp=c89025be021383625a810a5eb8e33efb82bed6dd;hb=3d6f74ee1a8b061e4b274dad70125ab6388f4d83;hpb=e24df7cffc01937a211db2d29f44bccc3d740bd5 diff --git a/tests/test_market.py b/tests/test_market.py index c89025b..07188ac 100644 --- a/tests/test_market.py +++ b/tests/test_market.py @@ -186,14 +186,17 @@ class MarketTest(WebMockTestCase): return { "average": D("0.000001") } if c1 == "ETH" and c2 == "BTC": return { "average": D("0.1") } + if c1 == "FOO" and c2 == "BTC": + return { "average": D("0.1") } self.fail("Should not be called with {}, {}".format(c1, c2)) get_ticker.side_effect = _get_ticker repartition.return_value = { - "DOGE": (D("0.25"), "short"), - "BTC": (D("0.25"), "long"), - "ETH": (D("0.25"), "long"), - "XMR": (D("0.25"), "long"), + "DOGE": (D("0.20"), "short"), + "BTC": (D("0.20"), "long"), + "ETH": (D("0.20"), "long"), + "XMR": (D("0.20"), "long"), + "FOO": (D("0.20"), "long"), } m = market.Market(self.ccxt, self.market_args()) self.ccxt.fetch_all_balances.return_value = { @@ -210,12 +213,12 @@ class MarketTest(WebMockTestCase): "total": D("5.0") }, "BTC": { - "exchange_free": D("0.075"), + "exchange_free": D("0.065"), "exchange_used": D("0.02"), - "exchange_total": D("0.095"), - "margin_available": D("0.025"), + "exchange_total": D("0.085"), + "margin_available": D("0.035"), "margin_in_position": D("0.01"), - "margin_total": D("0.035"), + "margin_total": D("0.045"), "total": D("0.13") }, "ETH": { @@ -224,6 +227,12 @@ class MarketTest(WebMockTestCase): "exchange_total": D("1.0"), "total": D("1.0") }, + "FOO": { + "exchange_free": D("0.1"), + "exchange_used": D("0.0"), + "exchange_total": D("0.1"), + "total": D("0.1"), + }, } m.balances.fetch_balances(tag="tag") @@ -236,12 +245,13 @@ class MarketTest(WebMockTestCase): self.assertEqual(portfolio.Amount("BTC", "-0.025"), new_repartition["DOGE"] - values_in_base["DOGE"]) - self.assertEqual(portfolio.Amount("BTC", "0.025"), - new_repartition["ETH"] - values_in_base["ETH"]) self.assertEqual(0, - new_repartition["ZRC"] - values_in_base["ZRC"]) + new_repartition["ETH"] - values_in_base["ETH"]) + self.assertIsNone(new_repartition.get("ZRC")) self.assertEqual(portfolio.Amount("BTC", "0.025"), new_repartition["XMR"]) + self.assertEqual(portfolio.Amount("BTC", "0.015"), + new_repartition["FOO"] - values_in_base["FOO"]) compute_trades.reset_mock() with self.subTest(available_balance_only=True, balance=0),\