From 17598517c544a3dda8b9f773dfeb669c886ea92b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Sun, 4 Mar 2018 12:59:57 +0100 Subject: Add close trades action --- portfolio.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'portfolio.py') diff --git a/portfolio.py b/portfolio.py index b77850b..f27e84f 100644 --- a/portfolio.py +++ b/portfolio.py @@ -290,6 +290,7 @@ class Trade: self.value_to = value_to self.orders = [] self.market = market + self.closed = False assert self.value_from.value * self.value_to.value >= 0 assert self.value_from.currency == self.value_to.currency if self.value_from != 0: @@ -327,6 +328,13 @@ class Trade: else: return "long" + @property + def pending(self): + return not (self.is_fullfiled or self.closed) + + def close(self): + self.closed = True + @property def is_fullfiled(self): return abs(self.filled_amount(in_base_currency=True)) >= abs(self.delta) -- cgit v1.2.3