]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Trader.git/blobdiff - portfolio.py
Merge branch 'dev'
[perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Trader.git] / portfolio.py
index 9b27e261d0bfa93ab511e2c692cfc10f3ecd61f8..94472a3636de776d0724c6484fd7dbd85c406566 100644 (file)
@@ -4,6 +4,10 @@ from decimal import Decimal as D, ROUND_DOWN
 from ccxt import ExchangeError, InsufficientFunds, ExchangeNotAvailable, InvalidOrder, OrderNotCached, OrderNotFound, RequestTimeout, InvalidNonce
 
 class Computation:
+    @staticmethod
+    def eat_several(market):
+        return lambda x, y: market.ccxt.fetch_nth_order_book(x["symbol"], y, 15)
+
     computations = {
             "default": lambda x, y: x[y],
             "average": lambda x, y: x["average"],
@@ -288,8 +292,12 @@ class Trade:
         if tick in self.tick_actions:
             update, compute_value = self.tick_actions[tick]
         elif tick % 3 == 1:
-            update = "market_adjust"
-            compute_value = "default"
+            if tick < 20:
+                update = "market_adjust"
+                compute_value = "default"
+            else:
+                update = "market_adjust_eat"
+                compute_value = Computation.eat_several(self.market)
         else:
             update = "waiting"
             compute_value = None
@@ -582,7 +590,7 @@ class Order:
         self.mark_finished_order()
 
     def mark_dust_amount_remaining_order(self):
-        if self.market.ccxt.is_dust_trade(self.remaining_amount().value, self.rate):
+        if self.status == "open" and self.market.ccxt.is_dust_trade(self.remaining_amount().value, self.rate):
             self.status = "closed_dust_remaining"
 
     def remaining_amount(self, refetch=False):