dutu / poloLender

Free, open source, high performance bot for lending funds on Poloniex exchange
https://github.com/dutu/poloLender
Other
160 stars 47 forks source link

Add support for minimum lend rates for #5. #7

Closed denravonska closed 8 years ago

denravonska commented 8 years ago

Here is a proposal fix for specifying minimum lend rates.

The rates are specified in percent and later on converted to rates to match the internal rate. So, for example, a configured rate of "0.015" equals an internal rate of "0.00015". While this enforces some divisions by 100.0 in the code, I wanted to make it easy to configure.

When the bot wants to make an offer it will automatically set it to the specified min rate if the best return rate is lower. So, for example, if the bot would ordinarily offer a loan at 0.01% but I have set the min rate for that coin to 0.015%, it will instead make the offer at 0.015%. Similarly, if it is about to cancel a loan but the new loan would be placed lower than the min rate, the loan will not be cancelled. This could perhaps be improved so we only cancel if the new load would be > min AND the current loan is not the min rate.

denravonska commented 8 years ago

Do not merge yet. Spotted a bug.

dutu commented 8 years ago

Thanks you for this PR, @denravonska .

Did you mange to test this commit? I see a few places config.offerMinRate[currency] / 100.0, but the config.offerMinRate[currency] seems to be a string.

Can you please doublecheck?

dutu commented 8 years ago

@denravonska, With the initial issue you have raised you wanted the bot to stop lending when the bestReturnRate is lower.

this PR seems to let the place a lend offer at MINRATE when bestReturnRate is lower (instead of no lending). In this situation you would still not be able to "trade your coins to another currency" as initially mentioned.

denravonska commented 8 years ago

Adressing your comments all at once since there's no reply function.

1) Yup, those where the bugs I spotted. I have replaced the string comparisons.

2) I capped the lend rate to the specified min rate after I noticed that there is a possibility that someone picks your loan anyway. It happened to me when the going loan rate was 0.024% but I capped and set my loan rate to 0.025%. I figured it would be better to have an cancellable, open loan with a minimum rate than no loan at all.

3) Hmmm, I did test it under the assumption that Math.max used the > operator and that it's available in Big, but I might be wrong here? JS isn't my native language :) EDIT: I can't find operator traces in big.js so I'll change back to explicit comparisons.

dutu commented 8 years ago

@denravonska, for your point 2) need to be aware that even if the loan offer is cancellable, if you cancel it manually, a new loan offer would immediately be placed.

Hence, the initial objective to keep funds available to be transferred out of the lending account is not reached.

denravonska commented 8 years ago

Ah, I meant cancellable by the bot, not by the user.

But you are right, it does not solve my initial issue request, and the initial request actually does makes sense. I'll change my implementation after fixing the Math issue. Sit tight.

dutu commented 8 years ago

Please address some small issues and do another PR when these are addressed and PR has been tested successfully. Please also update the revision number in file CHANGELOG.md and package.json.

Thanks a lot for your contribution, @denravonska!!