aboutsummaryrefslogtreecommitdiff
path: root/tests/test_market.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_market.py')
-rw-r--r--tests/test_market.py32
1 files changed, 21 insertions, 11 deletions
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):
186 return { "average": D("0.000001") } 186 return { "average": D("0.000001") }
187 if c1 == "ETH" and c2 == "BTC": 187 if c1 == "ETH" and c2 == "BTC":
188 return { "average": D("0.1") } 188 return { "average": D("0.1") }
189 if c1 == "FOO" and c2 == "BTC":
190 return { "average": D("0.1") }
189 self.fail("Should not be called with {}, {}".format(c1, c2)) 191 self.fail("Should not be called with {}, {}".format(c1, c2))
190 get_ticker.side_effect = _get_ticker 192 get_ticker.side_effect = _get_ticker
191 193
192 repartition.return_value = { 194 repartition.return_value = {
193 "DOGE": (D("0.25"), "short"), 195 "DOGE": (D("0.20"), "short"),
194 "BTC": (D("0.25"), "long"), 196 "BTC": (D("0.20"), "long"),
195 "ETH": (D("0.25"), "long"), 197 "ETH": (D("0.20"), "long"),
196 "XMR": (D("0.25"), "long"), 198 "XMR": (D("0.20"), "long"),
199 "FOO": (D("0.20"), "long"),
197 } 200 }
198 m = market.Market(self.ccxt, self.market_args()) 201 m = market.Market(self.ccxt, self.market_args())
199 self.ccxt.fetch_all_balances.return_value = { 202 self.ccxt.fetch_all_balances.return_value = {
@@ -210,12 +213,12 @@ class MarketTest(WebMockTestCase):
210 "total": D("5.0") 213 "total": D("5.0")
211 }, 214 },
212 "BTC": { 215 "BTC": {
213 "exchange_free": D("0.075"), 216 "exchange_free": D("0.065"),
214 "exchange_used": D("0.02"), 217 "exchange_used": D("0.02"),
215 "exchange_total": D("0.095"), 218 "exchange_total": D("0.085"),
216 "margin_available": D("0.025"), 219 "margin_available": D("0.035"),
217 "margin_in_position": D("0.01"), 220 "margin_in_position": D("0.01"),
218 "margin_total": D("0.035"), 221 "margin_total": D("0.045"),
219 "total": D("0.13") 222 "total": D("0.13")
220 }, 223 },
221 "ETH": { 224 "ETH": {
@@ -224,6 +227,12 @@ class MarketTest(WebMockTestCase):
224 "exchange_total": D("1.0"), 227 "exchange_total": D("1.0"),
225 "total": D("1.0") 228 "total": D("1.0")
226 }, 229 },
230 "FOO": {
231 "exchange_free": D("0.1"),
232 "exchange_used": D("0.0"),
233 "exchange_total": D("0.1"),
234 "total": D("0.1"),
235 },
227 } 236 }
228 237
229 m.balances.fetch_balances(tag="tag") 238 m.balances.fetch_balances(tag="tag")
@@ -236,12 +245,13 @@ class MarketTest(WebMockTestCase):
236 245
237 self.assertEqual(portfolio.Amount("BTC", "-0.025"), 246 self.assertEqual(portfolio.Amount("BTC", "-0.025"),
238 new_repartition["DOGE"] - values_in_base["DOGE"]) 247 new_repartition["DOGE"] - values_in_base["DOGE"])
239 self.assertEqual(portfolio.Amount("BTC", "0.025"),
240 new_repartition["ETH"] - values_in_base["ETH"])
241 self.assertEqual(0, 248 self.assertEqual(0,
242 new_repartition["ZRC"] - values_in_base["ZRC"]) 249 new_repartition["ETH"] - values_in_base["ETH"])
250 self.assertIsNone(new_repartition.get("ZRC"))
243 self.assertEqual(portfolio.Amount("BTC", "0.025"), 251 self.assertEqual(portfolio.Amount("BTC", "0.025"),
244 new_repartition["XMR"]) 252 new_repartition["XMR"])
253 self.assertEqual(portfolio.Amount("BTC", "0.015"),
254 new_repartition["FOO"] - values_in_base["FOO"])
245 255
246 compute_trades.reset_mock() 256 compute_trades.reset_mock()
247 with self.subTest(available_balance_only=True, balance=0),\ 257 with self.subTest(available_balance_only=True, balance=0),\