From 4ae84fb7861938f7d98802a5621b1bbd6745c914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Sun, 6 May 2018 23:04:40 +0200 Subject: Fix infinite recursion during fetch --- portfolio.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'portfolio.py') diff --git a/portfolio.py b/portfolio.py index d8a5465..9b27e26 100644 --- a/portfolio.py +++ b/portfolio.py @@ -261,12 +261,12 @@ class Trade: @property def is_fullfiled(self): - return abs(self.filled_amount(in_base_currency=(not self.inverted))) >= abs(self.delta) + return abs(self.filled_amount(in_base_currency=(not self.inverted), refetch=True)) >= abs(self.delta) - def filled_amount(self, in_base_currency=False): + def filled_amount(self, in_base_currency=False, refetch=False): filled_amount = 0 for order in self.orders: - filled_amount += order.filled_amount(in_base_currency=in_base_currency) + filled_amount += order.filled_amount(in_base_currency=in_base_currency, refetch=refetch) return filled_amount tick_actions = { @@ -585,11 +585,11 @@ class Order: if self.market.ccxt.is_dust_trade(self.remaining_amount().value, self.rate): self.status = "closed_dust_remaining" - def remaining_amount(self): - return self.amount - self.filled_amount() + def remaining_amount(self, refetch=False): + return self.amount - self.filled_amount(refetch=refetch) - def filled_amount(self, in_base_currency=False): - if self.status == "open": + def filled_amount(self, in_base_currency=False, refetch=False): + if refetch and self.status == "open": self.fetch() filled_amount = 0 for mouvement in self.mouvements: -- cgit v1.2.3