aboutsummaryrefslogtreecommitdiff
path: root/portfolio.py
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2018-05-06 23:04:40 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2018-05-06 23:04:40 +0200
commit4ae84fb7861938f7d98802a5621b1bbd6745c914 (patch)
tree594e32be3c5bcc34e812d483fc662992f10c395c /portfolio.py
parentbb127bc87c2b2880469bfab230415c85e589421a (diff)
downloadTrader-4ae84fb7861938f7d98802a5621b1bbd6745c914.tar.gz
Trader-4ae84fb7861938f7d98802a5621b1bbd6745c914.tar.zst
Trader-4ae84fb7861938f7d98802a5621b1bbd6745c914.zip
Fix infinite recursion during fetch
Diffstat (limited to 'portfolio.py')
-rw-r--r--portfolio.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/portfolio.py b/portfolio.py
index d8a5465..9b27e26 100644
--- a/portfolio.py
+++ b/portfolio.py
@@ -261,12 +261,12 @@ class Trade:
261 261
262 @property 262 @property
263 def is_fullfiled(self): 263 def is_fullfiled(self):
264 return abs(self.filled_amount(in_base_currency=(not self.inverted))) >= abs(self.delta) 264 return abs(self.filled_amount(in_base_currency=(not self.inverted), refetch=True)) >= abs(self.delta)
265 265
266 def filled_amount(self, in_base_currency=False): 266 def filled_amount(self, in_base_currency=False, refetch=False):
267 filled_amount = 0 267 filled_amount = 0
268 for order in self.orders: 268 for order in self.orders:
269 filled_amount += order.filled_amount(in_base_currency=in_base_currency) 269 filled_amount += order.filled_amount(in_base_currency=in_base_currency, refetch=refetch)
270 return filled_amount 270 return filled_amount
271 271
272 tick_actions = { 272 tick_actions = {
@@ -585,11 +585,11 @@ class Order:
585 if self.market.ccxt.is_dust_trade(self.remaining_amount().value, self.rate): 585 if self.market.ccxt.is_dust_trade(self.remaining_amount().value, self.rate):
586 self.status = "closed_dust_remaining" 586 self.status = "closed_dust_remaining"
587 587
588 def remaining_amount(self): 588 def remaining_amount(self, refetch=False):
589 return self.amount - self.filled_amount() 589 return self.amount - self.filled_amount(refetch=refetch)
590 590
591 def filled_amount(self, in_base_currency=False): 591 def filled_amount(self, in_base_currency=False, refetch=False):
592 if self.status == "open": 592 if refetch and self.status == "open":
593 self.fetch() 593 self.fetch()
594 filled_amount = 0 594 filled_amount = 0
595 for mouvement in self.mouvements: 595 for mouvement in self.mouvements: