evdubs / Harmonia

Margin funding bot for Bitfinex
20 stars 8 forks source link

Stopped running with an exception #2

Closed Mikadily closed 10 years ago

Mikadily commented 10 years ago

Stopped running after more than a day with following error. Anything else I could provide in order to fix it?

Estimated total accrued interest 8.260056296146118 Comparing best ask outside best bid amount 5000.0 with our offer amount 52.09215939 Comparing currentFrr: false with newFrr: false Comparing currentAmount: 52.09215939 with newAmount: 52.09215939 Comparing currentRate: 174.835 with newRate: 174.835 Matched previous isFrr: false amount: 52.09215939 rate: 174.835 Estimated total accrued interest 8.262561755554234 Comparing currentFrr: false with newFrr: true Cancelling BitfinexOfferStatusResponse [id=2595303, currency=USD, rate=174.835, period=30, direction=lend, type=null, timestamp=1.41 305997E9, isLive=true, isCancelled=false, originalAmount=52.09215939, remainingAmount=52.09215939, executedAmount=0.0] Sending LoanOrder [type=ASK, currency=USD, tradableAmount=52.09215939, dayPeriod=30, id=, timestamp=null] Estimated total accrued interest 8.265128458193995 Comparing currentFrr: false with newFrr: true Cancelling BitfinexOfferStatusResponse [id=2595330, currency=USD, rate=0.0, period=30, direction=lend, type=null, timestamp=1.4130601E9, isLive=true, isCancelled=false, originalAmount=52.09215939, remainingAmount=52.09215939, executedAmount=0.0] Sending LoanOrder [type=ASK, currency=USD, tradableAmount=52.09215939, dayPeriod=30, id=, timestamp=null] Estimated total accrued interest 8.267701752571018 Comparing currentFrr: false with newFrr: true Cancelling BitfinexOfferStatusResponse [id=2595334, currency=USD, rate=0.0, period=30, direction=lend, type=null, timestamp=1.4130601E9, isLive=true, isCancelled=false, originalAmount=52.09215939, remainingAmount=52.09215939, executedAmount=0.0] Sending LoanOrder [type=ASK, currency=USD, tradableAmount=52.09215939, dayPeriod=30, id=, timestamp=null] Estimated total accrued interest 8.270237653820304 Comparing currentFrr: false with newFrr: true Cancelling BitfinexOfferStatusResponse [id=2595339, currency=USD, rate=0.0, period=30, direction=lend, type=null, timestamp=1.4130601E9, isLive=true, isCancelled=false, originalAmount=52.09215939, remainingAmount=52.09215939, executedAmount=0.0] Sending LoanOrder [type=ASK, currency=USD, tradableAmount=52.09215939, dayPeriod=30, id=, timestamp=null] [WARNING] java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:293) at java.lang.Thread.run(Thread.java:745) Caused by: com.xeiam.xchange.ExchangeException: Invalid offer: not enough balance at com.xeiam.xchange.bitfinex.v1.service.polling.BitfinexTradeServiceRaw.placeBitfinexFloatingRateLoanOrder(BitfinexTradeServiceRaw.java:128) at name.evdubs.harmonia.Harmonia.cancelPreviousAndSendNewOrder(Harmonia.java:278) at name.evdubs.harmonia.Harmonia.main(Harmonia.java:199) ... 6 more [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 38:56:43.998s [INFO] Finished at: Sat Oct 11 23:42:11 EEST 2014 [INFO] Final Memory: 12M/36M [INFO] ------------------------------------------------------------------------

evdubs commented 10 years ago

That's enough information. I'll need to make sure I handle the unchecked ExchangeException in the main loop. I should have a fix for this available tonight. Thanks, @mikadily.

evdubs commented 10 years ago

@mikadily please git pull and mvn compile the latest commit.

evdubs commented 10 years ago

Just so you know, this can happen when a previous offer is taken while Harmonia is retrieving swap book data and going through the book data to determine if the offer should be changed. This is expected to happen from time to time.

This exception previously had not been thrown, but some modifications a month ago by @zholmes now allow for these BitfinexTradeServiceRaw methods to throw ExchangeException.

Mikadily commented 10 years ago

Thanks, I'll give it a go.

Although your last commit is a bit weird ;)

src/main/java/name/evdubs/harmonia/Harmonia.java | 499 +++++++++++-----------
1 file changed, 241 insertions(+), 258 deletions(-)

evdubs commented 10 years ago

Right; I changed the formatting to use two spaces for a tab and to extend the line length before wrapping.

evdubs commented 10 years ago

@mikadily, have you seen any other crashes since the update?

Mikadily commented 10 years ago

No crashes since last update, it's running nice and smooth. Thanks!

evdubs commented 9 years ago

@mikadily still running it? have any comments/questions?

Mikadily commented 9 years ago

@evdubs yes and it works well.

However when BTC swap rates spiked, I tried adopting Harmonia for the purpose. It worked, but not very well I'd say. The lending rate was rapidly changing from 0.1 to 0.6 and Harmonia was always hitting 0.1, looked like I'd have done much better manually. But maybe I was just unlucky.

So here's an idea for you, implement BTC lending as well ;)

Scottiiee commented 9 years ago

@mikadily I have a working copy with BTC/LTC implemented over on my dev branch. It still needs a little work. Check it out and let me know what you think.

Mikadily commented 9 years ago

@Scottiiee not sure this is the best place to comment... but few issues.

  1. My 512M VPS crashed with out of memory and I think your dev version caused it, but I'm not sure.
  2. I was lending BTC and saw a scenario where was a tiny low offer and my bot matched it. This how lending book looked like - http://i.imgur.com/agvLeyJ.png and bot's offer was 0.021% - unacceptable.