From 089d5d9df3d9d93e3ce789be16ee6cdd99dc2b52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Thu, 18 Jan 2018 09:57:23 +0100 Subject: Don't autoprepare the orders when creating trade --- portfolio.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/portfolio.py b/portfolio.py index 576a228..b0f9256 100644 --- a/portfolio.py +++ b/portfolio.py @@ -247,14 +247,11 @@ class Trade: self.value_from = value_from self.value_to = value_to self.orders = [] + self.market = market assert self.value_from.currency == self.value_to.currency assert self.value_from.linked_to is not None and self.value_from.linked_to.currency == self.currency self.base_currency = self.value_from.currency - if market is not None: - self.market = market - self.prepare_order(market) - fees_cache = {} @classmethod def fetch_fees(cls, market): @@ -310,6 +307,7 @@ class Trade: currency, market=market ) + cls.trades[currency].prepare_order() return cls.trades @property @@ -330,7 +328,7 @@ class Trade: else: return "bid" if not inverted else "ask" - def prepare_order(self, market): + def prepare_order(self): if self.action is None: return ticker = self.value_from.ticker @@ -338,7 +336,7 @@ class Trade: if not inverted: value_from = self.value_from.linked_to - value_to = self.value_to.in_currency(self.currency, market) + value_to = self.value_to.in_currency(self.currency, self.market) delta = abs(value_to - value_from) currency = self.base_currency else: -- cgit v1.2.3