X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=portfolio.py;h=9b27e261d0bfa93ab511e2c692cfc10f3ecd61f8;hb=4ae84fb7861938f7d98802a5621b1bbd6745c914;hp=d8a546584afc4549be442e1593030ec82c5f0eef;hpb=bb127bc87c2b2880469bfab230415c85e589421a;p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FCryptoportfolio%2FTrader.git 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: