Permalink
Browse files

Implemented mass AutoRenew feature, set when bot stops and clear when…

… bot starts.
  • Loading branch information...
1 parent 58902f7 commit f3ff23abbc7e829139c1702b00ab24760909a148 @rnevet rnevet committed Feb 7, 2016
Showing with 44 additions and 2 deletions.
  1. +6 −0 README.md
  2. +34 −2 lendingbot.py
  3. +4 −0 poloniex.py
View
@@ -54,6 +54,9 @@ gaptop = 200
#If set to 0 all offers will be placed for a 2 day period
sixtydaythreshold = 0.2
+# AutoRenew - if set to 1 the bot will set the AutoRenew flag for the loans when you stop it (Ctrl+C) and clear the AutoRenew flag when on started
+autorenew = 0
+
#custom config per coin, useful when closing positions etc.
#syntax: ["COIN:mindailyrate:maxactiveamount",...]
#if maxactive amount is 0 - stop lending this coin. in the future you'll be able to limit amount to be lent.
@@ -62,6 +65,9 @@ sixtydaythreshold = 0.2
If `spreadlend = 1` and `gapbottom = 0`, it will behave as simple lending bot lending at lowest possible offer.
+## Command Line Parameters
+--clearAutoRenew - will clear the AutoRenew flag on all exising loans
+
##Donations
If you find it useful, please consider donating some bitcoins: 1MikadW4iKTJ54GVrj7xS1SrZAhLUyZk38
View
@@ -30,6 +30,8 @@
gaptop = 100
#Daily lend rate threshold after which we offer lends for 60 days as opposed to 2. If set to 0 all offers will be placed for a 2 day period
sixtydaythreshold = 0.2
+# AutoRenew - if set to 1 the bot will toggle the AutoRenew flag for the loans when you stop it (Ctrl+C) and clear the AutoRenew flag when started
+autorenew = 0
#custom config per coin, useful when closing positions etc.
#syntax: [COIN:mindailyrate:maxactiveamount, ... COIN:mindailyrate:maxactiveamount]
#if maxactive amount is 0 - stop lending this coin. in the future you'll be able to limit amount to be lent.
@@ -53,6 +55,7 @@
gapBottom = Decimal(config.get("BOT","gapbottom"))
gapTop = Decimal(config.get("BOT","gaptop"))
sixtyDayThreshold = float(config.get("BOT","sixtydaythreshold"))/100
+autorenew = int(config.get("BOT","autorenew"))
try:
coincfg = {} #parsed
@@ -202,17 +205,46 @@ def cancelAndLoanAll():
if i == len(loans['offers']): #end of the offers lend at max
createLoanOffer(activeCur,Decimal(activeBal)-lent,maxDailyRate)
+def setAutoRenew(auto):
+ cryptoLended = bot.returnActiveLoans()
+ i = int(0) #counter
+
+ for item in cryptoLended["provided"]:
+ if int(item["autoRenew"]) != auto:
+ bot.toggleAutoRenew(int(item["id"]))
+ i += 1
+ return i
+
+
log.log('Welcome to Poloniex Lending Bot')
+try:
+ if sys.argv.index('--clearAutoRenew') > 0:
+ log.log('Clearing AutoRenew...(Please Wait)')
+ i = setAutoRenew(0);
+ log.log('Cleared AutoRenew for ' + str(i) + ' items')
+ exit(0)
+except:
+ pass
+
+
+if autorenew == 1:
+ log.log('Clearing AutoRenew...(Please Wait)')
+ i = setAutoRenew(0);
+ log.log('Cleared AutoRenew for ' + str(i) + ' items')
while True:
try:
refreshTotalLended()
log.refreshStatus(stringifyTotalLended())
cancelAndLoanAll()
+ time.sleep(sleepTime)
except Exception as e:
log.log("ERROR: " + str(e))
pass
except KeyboardInterrupt:
- print '\nbye'
+ if autorenew == 1:
+ log.log('AutoRenew loans... (Please Wait)')
+ i = setAutoRenew(1);
+ log.log(str(i) + ' loans set to AutoRenew')
+ log.log('bye')
exit(0)
- time.sleep(sleepTime)
View
@@ -154,3 +154,7 @@ def withdraw(self, currency, amount, address):
def returnLoanOrders(self,currency):
return self.api_query('returnLoanOrders',{"currency":currency})
+
+ # Toggles the auto renew setting for the specified orderNumber
+ def toggleAutoRenew(self, orderNumber):
+ return self.api_query('toggleAutoRenew',{"orderNumber":orderNumber})

0 comments on commit f3ff23a

Please sign in to comment.