MikaLendingBot icon indicating copy to clipboard operation
MikaLendingBot copied to clipboard

Show estimated earning rates on html page

Open Fornax96 opened this issue 10 years ago • 21 comments

I tried submitting a pull request for this but couldn't get the github commandline client working. Anyway, you can view my implementation here: http://fornax96.me/lendingbot.html. Feel free to use. It currently only shows BTC rates, but I guess you could add a loop to support others too.

I also modified the lendingbot.py script to show one more decimal so it's more accurate.

Fornax96 avatar Apr 26 '16 15:04 Fornax96

Very interested in this.

wza avatar Apr 30 '16 20:04 wza

I second this, would you mind sharing the code?

ghost avatar May 04 '16 12:05 ghost

It's in the source of the page I added to the OP: view-source:http://fornax96.me/lendingbot.html

Basically what I did was write this function:

function updateRates(data){
    console.log(/(\d+\.\d+) BTC/i.exec(data));

    var btc = /(\d+\.\d+) BTC/i.exec(data)[1];
    var percent = /BTC @ (\d+.\d+)\%/i.exec(data)[1];
    var rate = +percent / 100;

    var btchourly = (+btc * +rate) / 24;
    var btcdaily = (+btc * +rate);
    var btcweekly = (+btc * +rate) * 7;
    var btcmonthly = (+btc * +rate) * 30;

    var text = (Math.round(btcmonthly * 100000000) / 100000000) + " BTC per Month<br/>"
            + (Math.round(btcweekly * 100000000) / 100000000) + " BTC per Week<br/>"
            + (Math.round(btcdaily * 100000000) / 100000000) + " BTC per Day<br/>"
            + Math.round(btchourly * 100000000) + " Satoshi per Hour<br/>";

    $("#rate").html(text);
}

which gets called in updateJson after updating the last_update text like this: updateRates(data.last_status);

And I added a table row to show the information: <tr><th class="col-xs-2" style="vertical-align: text-top;">BTC Rate</th><th class="col-xs-10" id="rate">N/A</th></tr>

Fornax96 avatar May 04 '16 14:05 Fornax96

Github's markdown code highlighting is not too well, I'll just try committing again

Fornax96 avatar May 04 '16 14:05 Fornax96

Can u add the other coins pls for us non coders

m33Lucky avatar May 04 '16 14:05 m33Lucky

Sure, I'll work on it a bit more and add it to this repo. It may not be done before Saturday.

Fornax96 avatar May 04 '16 14:05 Fornax96

So far I see btc , Xmr , maid , Eth , and doge user mostly , have not heard any other coins yet

m33Lucky avatar May 04 '16 14:05 m33Lucky

This is excellent, thank you.

AlexMinty avatar May 04 '16 14:05 AlexMinty

how to use where are the files

m33Lucky avatar May 04 '16 15:05 m33Lucky

m33Lucky: open http://fornax96.me/lendingbot.html in your browser save locally rename to lendingbot.html

in www folder remove original lendingbot.html copy/move new downloaded lendingbot.html into www folder restart lendingbot.py

AlexMinty avatar May 05 '16 01:05 AlexMinty

Easy as pie, you don't even need to restart your bot

Fornax96 avatar May 05 '16 07:05 Fornax96

You also don't need to name it the same... as the logging is done in the json file you can have different html files interpreting it.

rnevet avatar May 05 '16 08:05 rnevet

not working class not specified and cant get json

m33Lucky avatar May 05 '16 21:05 m33Lucky

For anyone having an issue extracting the source: https://gist.github.com/Evanito/ca7281340a6171402c6f0855073e78a9#file-lendingbot-html

Evanito avatar May 07 '16 06:05 Evanito

Hi,

I've used Fornax96's html file and it works good. I have a little different implantation of this feature and my calculations are about 15% lower. I suppose that those calculations are gross, before reducing the exchange fees.

I would suggest to change it to the net values, as those are the numbers we are interested in.

Kili4ka avatar May 07 '16 09:05 Kili4ka

@Kili4ka Yep, lending fees are actually 15%

Evanito avatar May 07 '16 19:05 Evanito

Added the 15% fee deduction. I'm now patching my own fork. It involves a lot of spacebar mashing.

Fornax96 avatar May 08 '16 14:05 Fornax96

Thanks. works as expected.

Kili4ka avatar May 08 '16 15:05 Kili4ka

check at https://github.com/Mikadily/poloniexlendingbot/pull/58 for update and display all currencies

Kurairaito avatar May 08 '16 17:05 Kurairaito

Closed by #58

Evanito avatar May 11 '16 02:05 Evanito