aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--portfolio.py10
1 files 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:
247 self.value_from = value_from 247 self.value_from = value_from
248 self.value_to = value_to 248 self.value_to = value_to
249 self.orders = [] 249 self.orders = []
250 self.market = market
250 assert self.value_from.currency == self.value_to.currency 251 assert self.value_from.currency == self.value_to.currency
251 assert self.value_from.linked_to is not None and self.value_from.linked_to.currency == self.currency 252 assert self.value_from.linked_to is not None and self.value_from.linked_to.currency == self.currency
252 self.base_currency = self.value_from.currency 253 self.base_currency = self.value_from.currency
253 254
254 if market is not None:
255 self.market = market
256 self.prepare_order(market)
257
258 fees_cache = {} 255 fees_cache = {}
259 @classmethod 256 @classmethod
260 def fetch_fees(cls, market): 257 def fetch_fees(cls, market):
@@ -310,6 +307,7 @@ class Trade:
310 currency, 307 currency,
311 market=market 308 market=market
312 ) 309 )
310 cls.trades[currency].prepare_order()
313 return cls.trades 311 return cls.trades
314 312
315 @property 313 @property
@@ -330,7 +328,7 @@ class Trade:
330 else: 328 else:
331 return "bid" if not inverted else "ask" 329 return "bid" if not inverted else "ask"
332 330
333 def prepare_order(self, market): 331 def prepare_order(self):
334 if self.action is None: 332 if self.action is None:
335 return 333 return
336 ticker = self.value_from.ticker 334 ticker = self.value_from.ticker
@@ -338,7 +336,7 @@ class Trade:
338 336
339 if not inverted: 337 if not inverted:
340 value_from = self.value_from.linked_to 338 value_from = self.value_from.linked_to
341 value_to = self.value_to.in_currency(self.currency, market) 339 value_to = self.value_to.in_currency(self.currency, self.market)
342 delta = abs(value_to - value_from) 340 delta = abs(value_to - value_from)
343 currency = self.base_currency 341 currency = self.base_currency
344 else: 342 else: