BitBotFactory / MikaLendingBot

Automated lending on Cryptocurrency exchanges Poloniex and Bitfinex
http://poloniexlendingbot.readthedocs.io/en/latest/index.html
MIT License
1.11k stars 345 forks source link

[Error] Offer amount must be positive #612

Open JCBauza opened 6 years ago

JCBauza commented 6 years ago

I keep running into these errors and it is driving me crazy. The worse part is that it stops there so many currencies are not being lent:

2018-02-19 17:32:43 Error API Error 400: {"message":"Offer amount must be positive."} Requesting https://api.bitfinex.com/v1/offer/new
Caught API Error 400: {"message":"Offer amount must be positive."} Requesting https://api.bitfinex.com/v1/offer/new reading from exchange API, ignoring.

2018-02-19 17:32:43 Error API Error 400: {"message":"Offer amount must be positive."} Requesting https://api.bitfinex.com/v1/offer/new
--
2018-02-19 17:32:40 Not lending ETP due to rate below 0.0500% (actual: 0.0000%)
2018-02-19 17:32:37 Not lending LTC due to rate below 0.0500% (actual: 0.0277%)
Evanito commented 6 years ago

Looks like it tried to do 0.0000% - 0.0001%

Could be fixed by hard coding in a minimum that it will never attempt to go below.

JCBauza commented 6 years ago

Still happening. It also stops running when the error happens.

python lendingbot.py 
Welcome to Lending Bot on BITFINEX
2018-04-29 10:31:41 Error API Error 400: {"message":"Offer amount must be positive."} Requesting https://api.bitfinex.com/v1/offer/new
Caught API Error 400: {"message":"Offer amount must be positive."} Requesting https://api.bitfinex.com/v1/offer/new reading from exchange API, ignoring.
2018-04-29 10:34:14 Error API Error 400: {"message":"Offer amount must be positive."} Requesting https://api.bitfinex.com/v1/offer/new
Caught API Error 400: {"message":"Offer amount must be positive."} Requesting https://api.bitfinex.com/v1/offer/new reading from exchange API, ignoring.

Log (Reversed ordered):
--
2018-04-29 10:34:14 Error API Error 400: {"message":"Offer amount must be positive."} Requesting https://api.bitfinex.com/v1/offer/new
2018-04-29 10:34:12 Not lending ETP due to rate below 0.0050% (actual: 0.0004%)
JCBauza commented 6 years ago

Still having this issue non stop:

2018-06-11 12:48:40 Error API Error 400: {"message":"Offer amount must be positive."} Requesting https://api.bitfinex.com/v1/offer/new
--

The problem is that when it happens it stops execution and the rest of the coins never get to be lent. Please help!

Evanito commented 6 years ago

@JCBauza Please post your config (with API keys and Notifications section removed) so we can check if there are any configuration options that may be causing this

JCBauza commented 6 years ago

Thanks, I'll post it once I regain access... the server lost it's internet connection and they are fixing it in 2 days. I'll reply with it as soon as it comes back up. Thank you for the fast response!

JCBauza commented 6 years ago
# Need help configuring? View the Documentation: https://poloniexlendingbot.readthedocs.io/en/latest/configuration.html

[API]
# Where to work? "Poloniex" or "Bitfinex". Default is "Poloniex"
exchange = Bitfinex
apikey = removed
secret = removed

[POLONIEX]
# Full list of supported currencies
#all_currencies = STR,BTC,BTS,CLAM,DOGE,DASH,LTC,MAID,XMR,XRP,ETH,FCT

[BITFINEX]
# Full list of supported currencies
#all_currencies = USD,BTC,ETH,ETC,ZEC,XMR,LTC,DSH,IOT,EOS,BCH,XRP,OMG
#all_currencies = EUR,USD,BTC,ETH,BCH,XRP,IOT,XMR,LTC,OMG,ETC,EOS,DSH,ZEC,NEO,SAN,ETP
#all_currencies = BCH,XRP,IOT,XMR,OMG,ETC,EOS,ZEC
all_currencies = EUR,USD,BTC,LTC,ETH,ZEC,DSH,XRP,EOS,SAN,OMG,NEO,ETP,EDO

[BOT]
#Custom name of the bot, that will be displayed in html page
label = Lending Bot

#Sleeps between active iterations, time in seconds (1-3600)
sleeptimeactive = 60

#Sleeps between inactive iterations, time in seconds (1-3600)
#Set to the same value as sleeptimeactive to disable
sleeptimeinactive = 300

#Timeout in seconds, the bot shall wait for a response during each request
#timeout = 30

#Minimum daily lend rate in percent (0.0031-5)
#Setting to 0.0031 is about 1% a year, not worth it.
mindailyrate = 0.005

#Maximum lending rate. 2% is good choice because it's default at margin trader interface.
#5% is the maximum rate accepted by the exchange (0.003-5)
maxdailyrate = 5

#The number of offers to split the available balance across the [gaptop, gapbottom] range. (1-20)
spreadlend = 20

#The depth of lendbook to move through before placing the first (gapbottom) and last (gaptop) offer.
#If gapbottom is set to 0, the first offer will be at the lowest possible rate.
#However some low value is recommended to skip dust offers.
# Gap modes: Raw, RawBTC, Relative
gapMode = Relative
gapbottom = 18
gaptop = 1300

#Daily lend rate threshold after which we offer lends for x days as opposed to 2.
#If set to 0 all offers will be placed for a 2 day period (0.003-5)
# Poloniex max lending period: 60 days
# Bitfinex max lending period: 30 days
xdaythreshold = 0.20
xdays = 30
#When xdayspread is set, lending days will be incremented linear from 2 days at (xdaythreshold/xdayspread) lent rate to (xdays) days at (xdaythreshold) lent rate. (0-10)
xdayspread = 10

#Auto-transfer of funds from exchange to lending balance.
#Enter ALL to transfer all coins, enter ACTIVE to transfer any coins you have in your lending account when the bot starts, these can be mixed.
#The currencies you enter below (comment it out to disable entirely, just leaving empty will result in an error) will be automatically transferred from your exchange balance to your lending balance whenever you deposit them.
#transferableCurrencies = STR,BTC,BTS,CLAM,DOGE,DASH,LTC,MAID,XMR,XRP,ETH,FCT
#transferableCurrencies = USD,BTC,ETH,ETC,ZEC,XMR,LTC,DSH,IOT,EOS
#transferableCurrencies = USD,BTC,ETH,ETC,ZEC,XMR,DSH,IOT,EOS,OMG,XRP
#transferableCurrencies = USD,BTC,BCH,ETH,XRP,IOT,XMR,LTC,OMG,ETC,EOS,DSH,ZEC
#transferableCurrencies = USD,BTC,ETH,ETC,ZEC,XMR,LTC,DSH,IOT,EOS
#transferableCurrencies = ACTIVE

#Minimum loan size, the minimum size of offers to make, bigger values prevent the bot from loaning small available amounts but reduce loan fragmentation.
minloansize = 0.01

#Keep Stuck Orders - Sometimes an order gets partially filled. When this happens it may leave the remainder of your coin under the set minloansize.
#If this happens, KeepStuckOrders will keep your order where it is so maybe it can be filled. Otherwise it will be canceled and held until orders expire.
keepstuckorders = True

#Hide coins - Instead of keeping your coins lent out at minlendrate when it is not met, the bot will hold them and wait for the rate to surpass it.
hideCoins = True

#End date for lending, bot will try to make sure all your loans are done by this date so you can withdraw or do whatever you need.
#Uncomment to enable.
#Format: YEAR,MONTH,DAY
#endDate = 2016,12,25

#Raw maximum amount to lend if under maxtolendrate.
#If set to 0 or commented: the bot will check for maxpercenttolend.(0+)
#maxtolend = 0

#FRR as min, tells the bot whether or not to use the flash return rate (https://support.bitfinex.com/hc/en-us/articles/213919009-What-is-the-Flash-Return-Rate-)
#instead of mindailyrate. This only works on bitfinex.
frrasmin = False

# The Flash Return Rate Delta (frrdelta) is a dynamic funding rate option that allows you to specify an offset from the Flash Return Rate. This only works on bitfinex and ffrasmin = TRUE
frrdelta = 0.0000

#Maximum percent to lend if under maxtolendrate.
#If set to 0 or commented: the bot will lend 100% of your balance regardless of rate. (0-100)
#maxpercenttolend = 0

#Max to lend conditional rate.
#If set to more than 0: the maxtolend or maxpercenttolend will be used when the rate is less than or equal to the maxtolendrate.
#If set to 0 or commented: the bot will use the maxtolend or maxpercenttolend all the time. (0.0031-5)
#maxtolendrate = 0

# Local Market Analysis: Choose which coins to record the market of in order to analyse them and compute a recommended lending rate.
# Enter ALL to analyse all coins, enter ACTIVE to analyse the markets of any coins you have in your lending account when the bot starts, these can be mixed.
#analyseCurrencies = STR,BTC,BTS,CLAM,DOGE,DASH,LTC,MAID,XMR,XRP,ETH,FCT
#analyseCurrencies = ALL
# Choose how long to keep market data. (In days) (1-365)
#analyseMaxAge = 2
# Choose how often to record a market's rate. (In seconds.) (10-3600)
#analyseUpdateInterval = 60
# Choose how aggressive to lend at based on a market's performance. (As a percentile of the market's rate.) (1-99)
# Recommendations: Conservative = 50, Moderate = 75, Aggressive = 90, Very Aggressive = 99
#lendingStyle = 39

#Syntax: ["COIN:mindailyrate:maxactiveamount:maxtolend:maxpercenttolend:maxtolendrate",...]
#If maxactive amount is 0: stop lending this coin. in the future you'll be able to limit amount to be lent.
#If maxtolend is 0: check for maxpercenttolend.
#If maxpercenttolend is 0: 100% is going to be lent.
#If maxtolendrate is set to more than 0: the maxtolend or maxpercenttolend will be used when then rate is less or equal to the maxtolendrate. if set to 0 the bot will use the maxtolend or maxpercenttolend all the time.
# Please configure via the coinconfig line below OR individual coins in the [BTC], [CLAM], etc section. NOT both.
# coinconfig takes precedence
#coinconfig = ["BTC:0.18:1:0:0:0","CLAM:0.6:1:0:0:0"]

#This option creates a json log file instead of console output which includes the most recent status.
#Uncomment both jsonfile and jsonlogsize to enable.
#Keep this in the default location if you want to use the webserver.
jsonfile = www/botlog.json

#Limits the amount of log lines to save.
jsonlogsize = 250

#Enables a webserver for the www folder, in order to easily use the lendingbot.html with the .json log.
#startWebServer = true

#Customize the IP and port that the webserver is hosted on. Defaults respectively to 0.0.0.0 and 8000
#0.0.0.0 will point to your default IP (Local IP on LAN as well as localhost), set to 127.0.0.1 if you want it to be only accessible by host computer.
#Do not set to a reserved port
#Advanced users only.
#customWebServerAddress = 0.0.0.0
#customWebServerPort = 8000

#Customize or select the desired template for the webserver. Default to 'www'.
#customWebServerTemplate = www

#The currency that the HTML Overview will present the earnings summary in.
#Options are BTC, USDT (USD on Bitfinex), ETH or anything as long as it has a direct BTC market. The default is BTC.
outputCurrency = USD

#Plugins allow extending Bot functionality with extra features.
plugins = AccountStats,Charts

[ACCOUNTSTATS]
ReportInterval = 1800

[CHARTS]
DumpInterval = 2600
HistoryFile = www/history.json

# Currencies can be configured here, or in the coinconfig. Coinconfig takes precedence.
[BTC]
mindailyrate = 0.005
maxactiveamount = 1
maxtolend = 0
maxpercenttolend = 0
maxtolendrate = 0
gapmode = raw
gapbottom = 39
gaptop = 2026

# Ethereum opportunities
[ETH]
mindailyrate = 0.005
maxactiveamount = 1
maxtolend = 0
maxpercenttolend = 0
maxtolendrate = 0
gapmode = raw
gapbottom = 39
gaptop = 1300

# Dash rates are great, lend it!
[DSH]
mindailyrate = 0.005
maxactiveamount = 1
maxtolend = 0
maxpercenttolend = 0
maxtolendrate = 0
gapmode = raw
gapbottom = 13
gaptop = 850

[EUR]
mindailyrate = 0.005
maxactiveamount = 1
maxtolend = 0
maxpercenttolend = 0
maxtolendrate = 0
gapmode = raw
gapbottom = 52000
gaptop = 5200000

# Skip around 50k USD worth of dust. Wall is at 40M USD, use 1M USD
[USD]
mindailyrate = 0.01
maxactiveamount = 1
maxtolend = 0
maxpercenttolend = 0
maxtolendrate = 0
gapmode = raw
gapbottom = 130000
gaptop = 13000000

[EOS]
mindailyrate = 0.005
maxactiveamount = 1
maxtolend = 0
maxpercenttolend = 0
maxtolendrate = 0
gapmode = raw
gapbottom = 300
gaptop = 300000

[NEO]
mindailyrate = 0.005
maxactiveamount = 1
maxtolend = 0
maxpercenttolend = 0
maxtolendrate = 0
gapmode = raw
gapbottom = 300
gaptop = 300000

# Santiment small amount of available finance
[SAN]
mindailyrate = 0.005
maxactiveamount = 1
maxtolend = 0
maxpercenttolend = 0
maxtolendrate = 0
gapmode = raw
gapbottom = 52
gaptop = 1024

[notifications]
notify_new_loans = True
notify_tx_coins = True
notify_xday_threshold = True
notify_summary_minutes = 15
notify_caught_exception = True

email = False
email_login_address = me@gmail.com
email_login_password = secretPassword
email_smtp_server = smtp.gmail.com
email_smtp_port = 465
email_smtp_starttls = False
email_to_addresses = me@gmail.com,you@gmail.com

#slack = False
#slack_token = 1234567890abcdef
#slack_channels = #cryptocurrency,@someUser

telegram = False
telegram_bot_id = 1234567890abcdef
telegram_chat_ids = @polopolo,@cryptocurrency

pushbullet = False
pushbullet_token = 1234567890abcdef
pushbullet_deviceid = 1234567890abcdef

irc = False
irc_host = irc.freenode.net
irc_port = 6667
irc_nick = LendingBot
irc_ident = ledningbot
irc_realname = Poloniex lending bot
irc_target = #bitbotfactory

#[MarketAnalysis]
# PLEASE refer to the docs before attempting to use any of this. There are a lot of things here that will not work
# correctly unless you understand what you are doing.
#analyseCurrencies = STR,BTC,BTS,CLAM,DOGE,DASH,LTC,MAID,XMR,XRP,ETH,FCT
analyseCurrencies = ACTIVE
lendingStyle = 39
MACD_long_win_seconds = 1800
#MACD_short_win_seconds = 150
# 3 days = 60 * 60 * 24 * 3 = 259200
percentile_seconds = 259200
# keep_history_seconds > (greater of (percentile_seconds, MACD_long_win_seconds) * 1.1)
#keep_history_seconds = 285120
#recorded_levels = 10
# 15 %  means we need one data point every 9 seconds. You probably don't need to change this.
#data_tolerance = 15
#delete_thread_sleep = 60
ma_debug_log = True

[Daily_min]
# This defaults to percentile, MACD is the moving average calc and should give better rates
method = MACD
multiplier = 1.05
Evanito commented 6 years ago

@rnevet @laxdog I don't see anything wrong with their config. Could there be some Bitfinex-specific problem?

JCBauza commented 6 years ago

maybe some dust or something making an overflow causing the error? Could there be a way to include additional debugging information?

rnevet commented 6 years ago

@JCBauza You could change the message here: https://github.com/BitBotFactory/MikaLendingBot/blob/fcd3fbb83797cb636a55b9059d8273b071c2beaa/modules/Bitfinex.py#L276

to:

msg = str(e) + " payload:" + str(payload)
self.log.log_error(msg)

This way we will get the payload sent to Bitfinex.

rnevet commented 6 years ago

@JCBauza any updates?

JCBauza commented 6 years ago

Sorry, it didn't happen again but now that I rebooted the server it is happening. I just changed the code and hope it comes back with something! Thanks for letting me know what to change in the code. I might suggest having a debug flag or something that does this as part of the main branch.

JCBauza commented 6 years ago

2018-06-20 21:13:09 Error API Error 400: {"message":"Offer amount must be positive."} payload:{'nonce': '152954718915603', 'direction': 'lend', 'request': '/v1/offer/new', 'rate': '7.9935', 'period': 2, 'currency': u'BTC', 'amount': '0.00000000'} 2018-06-20 21:13:09 Error API Error 400: {"message":"Offer amount must be positive."} Requesting https://api.bitfinex.com/v1/offer/new Caught API Error 400: {"message":"Offer amount must be positive."} Requesting https://api.bitfinex.com/v1/offer/new reading from exchange API, ignoring.

rnevet commented 6 years ago

ok, so it seems we are trying to place a zero size loan.

JCBauza commented 6 years ago

Yeah, probably Bitfinex has logic that says amount must be greater than 0 which makes sense.

JCBauza commented 5 years ago

Any updates on this? Still got issues :(

2019-02-12 17:15:54 Error API Error 400: {"message":"Offer amount must be positive."} Requesting https://api.bitfinex.com/v1/offer/new

2019-02-12 17:15:54 Error API Error 400: {"message":"Offer amount must be positive."} payload:{'nonce': '155001335407012', 'direction': 'lend', 'request': '/v1/offer/new', 'rate': '15.35117', 'period': 9, 'currency': u'USD', 'amount': '0.00000000'}