From 7192b2e1315c3dfd1204d609d716dd07e90f3bf4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Isma=C3=ABl=20Bouya?= Date: Thu, 1 Mar 2018 15:22:58 +0100 Subject: [PATCH] Fix ticker fetcher --- market.py | 11 +++++------ test.py | 2 ++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/market.py b/market.py index 9122fc0..0d91f17 100644 --- a/market.py +++ b/market.py @@ -88,23 +88,22 @@ class Market: "inverted": False, "average": (ticker["bid"] + ticker["ask"] ) / 2, }) + return ticker tickers = self.get_tickers() if tickers is None: try: - ticker = self.ccxt.fetch_ticker("{}/{}".format(c1, c2)) - augment_ticker(ticker) + ticker = augment_ticker(self.ccxt.fetch_ticker("{}/{}".format(c1, c2))) except ExchangeError: try: - ticker = invert(self.ccxt.fetch_ticker("{}/{}".format(c2, c1))) + ticker = invert(augment_ticker(self.ccxt.fetch_ticker("{}/{}".format(c2, c1)))) except ExchangeError: ticker = None else: if "{}/{}".format(c1, c2) in tickers: - ticker = tickers["{}/{}".format(c1, c2)] - augment_ticker(ticker) + ticker = augment_ticker(tickers["{}/{}".format(c1, c2)]) elif "{}/{}".format(c2, c1) in tickers: - ticker = invert(tickers["{}/{}".format(c2, c1)]) + ticker = invert(augment_ticker(tickers["{}/{}".format(c2, c1)])) else: ticker = None return ticker diff --git a/test.py b/test.py index 37b0e88..fbc857d 100644 --- a/test.py +++ b/test.py @@ -693,6 +693,7 @@ class MarketTest(WebMockTestCase): self.assertTrue(ticker["inverted"]) self.assertIn("original", ticker) self.assertEqual(10, ticker["original"]["bid"]) + self.assertEqual(25, ticker["original"]["average"]) ticker = m.get_ticker("XVG", "XMR") self.assertIsNone(ticker) @@ -721,6 +722,7 @@ class MarketTest(WebMockTestCase): self.assertTrue(ticker["inverted"]) self.assertIn("original", ticker) self.assertEqual(10, ticker["original"]["bid"]) + self.assertEqual(25, ticker["original"]["average"]) ticker = m.get_ticker("XVG", "XMR") self.assertIsNone(ticker) -- 2.41.0