BitBotFactory / MikaLendingBot

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

Not enough XXX available to offer. #165

Closed rnevet closed 7 years ago

rnevet commented 7 years ago

I'm seeing several errors like this one, I'm not sure if this is because of recent logic changes. Running on develop branch, but I think they also happen on master.

Example:

2016-12-22 16:27:14 Error: Not enough FCT available to offer. Requesting createLoanOffer 2016-12-22 16:27:14 Placing 2.07942785 FCT at 0.019899% for 2 days... Loan order placed. 2016-12-22 16:27:13 Placing 1.03971393 FCT at 0.019799% for 2 days... Loan order placed.

laxdog commented 7 years ago

I'm seeing the similar behaviour on master, I'm on commit 7e799cef39e3e1751e14cf77b9ae6a155f887fc5

Log isn't exactly the same, I have this backtrace though:

Traceback (most recent call last):
  File "/home/dog/poloniexlendingbot_new/lendingbot.py", line 91, in <module>
    Lending.lend_all()
  File "/home/dog/poloniexlendingbot_new/modules/Lending.py", line 137, in lend_all
    usable_currencies += lend_cur(cur, total_lended, lending_balances)
  File "/home/dog/poloniexlendingbot_new/modules/Lending.py", line 203, in lend_cur
    create_lend_offer(active_cur, Decimal(active_bal) - lent, offer['rate'])
  File "/home/dog/poloniexlendingbot_new/modules/Lending.py", line 91, in create_lend_offer
    msg = api.create_loan_offer(currency, amt, days, 0, rate)
  File "/home/dog/poloniexlendingbot_new/modules/Poloniex.py", line 168, in create_loan_offer
    "lendingRate": lending_rate, })
  File "/home/dog/poloniexlendingbot_new/modules/Poloniex.py", line 79, in api_query
    json_ret = _read_response(ret)
  File "/home/dog/poloniexlendingbot_new/modules/Poloniex.py", line 46, in _read_response
    raise PoloniexApiError(data['error'])
PoloniexApiError: Not enough BTC available to offer.
rnevet commented 7 years ago

@laxdog, this is the same issue, logs have been changed in develop branch.

laxdog commented 7 years ago

OK, cheers. Trying to recreate it now. Any idea what's triggering it?

laxdog commented 7 years ago

@rnevet it looks like when you are doing a spread lend that it doesn't take into account the minimum you can lend. So sometimes when you get to the last spread_step, the amount left to loan is too low.

There's actually a TODO in Lending.py about it:

--> 180     step_pct = (gap_top - gap_bottom) / spread_lend
    181     # TODO check for minimum lendable amount, and try to decrease the spread.
    182     # e.g. at the moment balances lower than 0.001 won't be lent
    183     # in case of empty lendbook, lend at max
Evanito commented 7 years ago

@rnevet @laxdog I have created a potential fix in #166, please test it if you have an opportunity to. It is based off master.

laxdog commented 7 years ago

Been running it for the last 4 hours without seeing anything. I'll leave it overnight and get back to you.

laxdog commented 7 years ago

@Evanito I accidentally closed the window with the log in it, but I don't think the patch has solved it. I had two instances of "Not enough BTC" blah blah, overnight.

I've kicked it off again to try and get you the backtrace, but I think it's just in the same place as last time.

laxdog commented 7 years ago

Here we go:

2016-12-30 13:11:43
Traceback (most recent call last):
  File "/home/dog/poloniexlendingbot_new/lendingbot.py", line 91, in <module>
    Lending.lend_all()
  File "/home/dog/poloniexlendingbot_new/modules/Lending.py", line 137, in lend_all
    usable_currencies += lend_cur(cur, total_lended, lending_balances)
  File "/home/dog/poloniexlendingbot_new/modules/Lending.py", line 207, in lend_cur
    create_lend_offer(active_cur, Decimal(active_bal) - lent, offer['rate'])
  File "/home/dog/poloniexlendingbot_new/modules/Lending.py", line 91, in create_lend_offer
    msg = api.create_loan_offer(currency, amt, days, 0, rate)
  File "/home/dog/poloniexlendingbot_new/modules/Poloniex.py", line 168, in create_loan_offer
    "lendingRate": lending_rate, })
  File "/home/dog/poloniexlendingbot_new/modules/Poloniex.py", line 79, in api_query
    json_ret = _read_response(ret)
  File "/home/dog/poloniexlendingbot_new/modules/Poloniex.py", line 46, in _read_response
    raise PoloniexApiError(data['error'])
PoloniexApiError: Not enough BTC available to offer.
laxdog commented 7 years ago

I've found putting the spreadlend up to 20 increases the chances of it happening, so you can try that if you're testing.

Evanito commented 7 years ago

Reopened until we can confirm previous commit fixed problem, it was merged because it is an improvement in logic that we should include whether or not it resolves this specific issue.

laxdog commented 7 years ago

Agreed, the code you put in is correct and an improvement. It just doesn't resolve this issue.

Evanito commented 7 years ago

This error was due to splitting a satoshi in half, and they both wanted to round up. Fixed in lending-rewrite branch.

utdrmac commented 7 years ago

Would this solve this recent issue I'm experiencing? Was away from home all weekend, but left bot running. Came home to bunches of errors like this:

Error: Amount must be at least 0.01. Requesting createLoanOffer
Evanito commented 7 years ago

@utdrmac It is a different error but yes, #174 fixes it.