]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Trader.git/blobdiff - ccxt_wrapper.py
Eat several positions in the order book after some time spent
[perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Trader.git] / ccxt_wrapper.py
index f30c7d20fd6434e2ae36a22e11676ba27da5235b..aaccc612ba036ff92123d377aed2ff208c02725d 100644 (file)
@@ -66,6 +66,13 @@ class poloniexE(poloniex):
     def nanoseconds():
         return int(time.time() * 1000000000)
 
+    def is_dust_trade(self, amount, rate):
+        if abs(amount) < decimal.Decimal("0.000001"):
+            return True
+        if abs(amount * rate) < decimal.Decimal("0.0001"):
+            return True
+        return False
+
     def fetch_margin_balance(self):
         """
         portfolio.market.privatePostGetMarginPosition({"currencyPair": "BTC_DASH"})
@@ -292,6 +299,10 @@ class poloniexE(poloniex):
                 "total": decimal.Decimal(summary["totalValue"]),
                 }
 
+    def fetch_nth_order_book(self, symbol, action, number):
+        book = self.fetch_order_book(symbol, limit=number)
+        return decimal.Decimal(book[action + "s"][-1][0])
+
     def nonce(self):
         """
         Wrapped to allow nonce with other libraries