Bitcoin Forum

Bitcoin => Project Development => Topic started by: Decoded on October 14, 2016, 07:56:47 AM



Title: [In-Development] BitPrice.link - Live Bitcoin/Crypto Calculator! [Open-Source]
Post by: Decoded on October 14, 2016, 07:56:47 AM
I'm currently building a site based on the same idea as preev.com.

It would be awesome if you guys could come up with ideas and even help with the site!

https://www.github.com/Sir-Lagsalot/BitPrice (https://www.github.com/Sir-Lagsalot/BitPrice)

Planned Features:
 - Wide range of exchanges
 - Faster than preev
 - More exchange options than preev
 - Email updates
 - Bitcoin stats

Status

Right now it's very primitive, and only works on the default BTC to USD. Cannot choose exchanges, but is an average of 17 different exchanges.


Title: Re: Making an open-source preev-like site. Anyone interested in helping out?
Post by: MartinL on October 14, 2016, 08:43:50 AM
I suggest releasing the source code now if your goal is to do that eventually anyways. That way anyone interested in helping can go right ahead and submit patches without any commitment.


Title: Re: Making an open-source preev-like site. Anyone interested in helping out?
Post by: batesresearch on October 14, 2016, 09:41:18 AM
I am actually building a similar site but for personal use only (family and friends) my end goal is to have a site much like Preev but auto converting the cryptos I trade and possibly having a portfolio section.

Not sure I will be any help but am happy to help where I can.


Title: Re: Making an open-source preev-like site. Anyone interested in helping out?
Post by: cloverme on October 14, 2016, 03:02:39 PM
It's not working for me at the moment, but maybe you're working it today.  The site loads but I don't think the javascript is firing correctly on your key event. Your bitcoinprices variable may need to be initialized before using it in a calculation.


Chrome Version 54.0.2840.59 beta-m (64-bit)
Code:
Uncaught ReferenceError: bitcoinprices is not defined
    at update (http://52.62.67.167/Assets/JS/update.js:4:24)
    at HTMLInputElement.onkeyup (http://52.62.67.167/:20:86)



Title: Re: Making an open-source preev-like site. Anyone interested in helping out?
Post by: tyz on October 14, 2016, 04:12:14 PM
Fetching the prices of different exchanges is not really a big deal. This can be done by writing a few lines of code. Everyone major exchanges offers a public to use API for fetching the current price and / or order books. Then, you just need to get the fiat rates. You may use the free API of Yahoo finance for that. I do not really see why there must set up an open source project for this kind of project.


Title: Re: Making an open-source preev-like site. Anyone interested in helping out?
Post by: Patatas on October 14, 2016, 06:12:23 PM
I do not really see why there must set up an open source project for this kind of project.
Yeah,what if someone just wants to experiment with stuff? Or maybe learn the basics ? If it all works out like it's suppose to be,I think the project does have the potential to become the most used or accurate price ticker for trades.

Op,like the UI,what framework are you using? Pretty sleek!I can help you with the UI/Javascript,please update the code on github and inbox me once it's done.I've too much time on my hands lately.


Title: Re: Making an open-source preev-like site. Anyone interested in helping out?
Post by: coinableS on October 15, 2016, 03:40:00 AM
I need help with the JavaScript. I have already set up backend price chaching. I just need help with innerhtml.

What parts of the JavaScript do you need help with? By innerhtml, do you mean doing the live interaction with the user? Here's a super basic barebones example I put together with just BTC/USD that might help.

https://github.com/coinables/Bitcoin-USD-Price-Conversion-Tool/blob/master/js/price.js



Title: Re: Making an open-source preev-like site. Anyone interested in helping out?
Post by: Decoded on October 15, 2016, 05:59:43 AM
Nice to see all this interest.

Yeah, I got a friend to write some example code for me that I tested out, but unfortunately is slightly broken. Soon I'm going to stop it from running on my VPS and make the git repo public. Will edit the OP.

I need help with the JavaScript. I have already set up backend price chaching. I just need help with innerhtml.

What parts of the JavaScript do you need help with? By innerhtml, do you mean doing the live interaction with the user? Here's a super basic barebones example I put together with just BTC/USD that might help.

https://github.com/coinables/Bitcoin-USD-Price-Conversion-Tool/blob/master/js/price.js

I know the js to get the price to auto-update into a div, however for me it refuses it auto-update in the input box.

For now, I've set up a weighted average of multiple different exchanges and their bitcoin valurs, you can find it at /api/btc/usd.php and /api/usd/eur.php.

What I want the JS to do is to read the dropdown of the left text box and the value of the right dropdoen, and then get the output value from 52.62.67.167/api/*leftdropdown*/*rightdropdown*.php, multiply it by the left text box and spit it out into the right text box.

For example, to get 1 BTC = *** USD:

Fetch output from 52.62.67.167/api/btc/usd.php, multiply it by 1, then print it out where *** is.


I do not really see why there must set up an open source project for this kind of project.
Yeah,what if someone just wants to experiment with stuff? Or maybe learn the basics ? If it all works out like it's suppose to be,I think the project does have the potential to become the most used or accurate price ticker for trades.

Op,like the UI,what framework are you using? Pretty sleek!I can help you with the UI/Javascript,please update the code on github and inbox me once it's done.I've too much time on my hands lately.


Semantic UI for the dropdowns, everything else is my own.



Title: Re: Making an open-source preev-like site. Anyone interested in helping out?
Post by: Decoded on October 15, 2016, 06:10:09 AM
Added source to OP. Please feel free to make a pull request! What I really need most is help with JavaScript!

(If you have any ideas at all, please suggest! Don't care if they're bad!)


Title: Re: Making an open-source preev-like site. Anyone interested in helping out?
Post by: Patatas on October 15, 2016, 07:17:30 AM
Added source to OP. Please feel free to make a pull request! What I really need most is help with JavaScript!

(If you have any ideas at all, please suggest! Don't care if they're bad!)
Bro,literally you've too much of dependencies for a app as simple as this.Correct me if I'm wrong but what are the node modules for ? Perhaps the python lib for the price ticker that is
Code:
         response = urllib2.urlopen('https://api.cryptonator.com/api/ticker/btc-usd') 
is more than enough,no ? I'd suggest you we start from scratch again.Are you connected with the account SirLagsAlot anyway ? Nevermind your gh,says that.


Title: Re: Making an open-source preev-like site. Anyone interested in helping out?
Post by: Decoded on October 15, 2016, 11:14:59 AM
Added source to OP. Please feel free to make a pull request! What I really need most is help with JavaScript!

(If you have any ideas at all, please suggest! Don't care if they're bad!)
Bro,literally you've too much of dependencies for a app as simple as this.Correct me if I'm wrong but what are the node modules for ? Perhaps the python lib for the price ticker that is
Code:
         response = urllib2.urlopen('https://api.cryptonator.com/api/ticker/btc-usd') 
is more than enough,no ? I'd suggest you we start from scratch again.Are you connected with the account SirLagsAlot anyway ? Nevermind your gh,says that.

Not SirLagsalot, but Sir_Lagsalot.

I do agree that currently the system for getting the exchange rate is primitive. It was just a test to get the JavaScript working. I aim to have all the processing and retrieving done on the backend and not using an external api.


Title: Re: Making an open-source preev-like site. Anyone interested in helping out?
Post by: coinableS on October 15, 2016, 04:55:49 PM
Added source to OP. Please feel free to make a pull request! What I really need most is help with JavaScript!

(If you have any ideas at all, please suggest! Don't care if they're bad!)
Bro,literally you've too much of dependencies for a app as simple as this.Correct me if I'm wrong but what are the node modules for ? Perhaps the python lib for the price ticker that is
Code:
         response = urllib2.urlopen('https://api.cryptonator.com/api/ticker/btc-usd') 
is more than enough,no ? I'd suggest you we start from scratch again.Are you connected with the account SirLagsAlot anyway ? Nevermind your gh,says that.

Holy smokes! Python, PHP and NodeJS? There really is no reason to have 3 different server-side languages running at once. If you want one of your features to be "faster than preev" you'll need to cut down on the bloat. For example your node_modules directory is full of modules you aren't using.

What are you most experienced in? I'm guessing PHP based on the current source... My suggestion is you pick one server-side language and go with that, don't jump back and forth.

You can create one file that grabs all the necessary prices every N seconds and then stores them in a database. Then when doing the calculations for the users just pull from the database. You'll have the speed you want, and you won't have to worry about exceeding API request limits with the exchanges you are hitting.

Quote
I know the js to get the price to auto-update into a div, however for me it refuses it auto-update in the input box

For updating a div you typically do something like:

Code:
var myTarget = document.getElementById("myDiv");
myTarget.innerHTML = "My Text";

For updating an input box you need to change it from innerhtml to value.

Code:
var myTarget = document.getElementById("myInputBox");
myInputBox.value = "My Text";


Title: Re: Making an open-source preev-like site. Anyone interested in helping out?
Post by: arunka71 on October 15, 2016, 08:14:18 PM
I wrote something similar a while ago to run as an app (should also work on a server, since it's using phonegap):

https://bitcointalk.org/index.php?topic=135392.0

Just some JS to fetch the data and create a HTML table from it.


Title: Re: Making an open-source preev-like site. Anyone interested in helping out?
Post by: Decoded on October 15, 2016, 10:42:19 PM
Added source to OP. Please feel free to make a pull request! What I really need most is help with JavaScript!

(If you have any ideas at all, please suggest! Don't care if they're bad!)
Bro,literally you've too much of dependencies for a app as simple as this.Correct me if I'm wrong but what are the node modules for ? Perhaps the python lib for the price ticker that is
Code:
         response = urllib2.urlopen('https://api.cryptonator.com/api/ticker/btc-usd') 
is more than enough,no ? I'd suggest you we start from scratch again.Are you connected with the account SirLagsAlot anyway ? Nevermind your gh,says that.

Holy smokes! Python, PHP and NodeJS? There really is no reason to have 3 different server-side languages running at once. If you want one of your features to be "faster than preev" you'll need to cut down on the bloat. For example your node_modules directory is full of modules you aren't using.

What are you most experienced in? I'm guessing PHP based on the current source... My suggestion is you pick one server-side language and go with that, don't jump back and forth.

You can create one file that grabs all the necessary prices every N seconds and then stores them in a database. Then when doing the calculations for the users just pull from the database. You'll have the speed you want, and you won't have to worry about exceeding API request limits with the exchanges you are hitting.

Quote
I know the js to get the price to auto-update into a div, however for me it refuses it auto-update in the input box

For updating a div you typically do something like:

Code:
var myTarget = document.getElementById("myDiv");
myTarget.innerHTML = "My Text";

For updating an input box you need to change it from innerhtml to value.

Code:
var myTarget = document.getElementById("myInputBox");
myInputBox.value = "My Text";


I figured as much. I was told by a friend that PHP when compared to others is extremely slow, so I figured i'd make the base site out of php, then use javascript for clientside.

My python bot basically saves the output into a json. I could make a PHP bot but essentially it would be the same thing.

I know how to change the value of the input, but i've tried putting it into a function and getting json to call it repeatedly. It doesnt work. Maybe i'm missing something? Would you like me to make a jsfiddle?


Title: Re: Making an open-source preev-like site. Anyone interested in helping out?
Post by: coinableS on October 16, 2016, 03:07:01 AM
Added source to OP. Please feel free to make a pull request! What I really need most is help with JavaScript!

(If you have any ideas at all, please suggest! Don't care if they're bad!)
Bro,literally you've too much of dependencies for a app as simple as this.Correct me if I'm wrong but what are the node modules for ? Perhaps the python lib for the price ticker that is
Code:
         response = urllib2.urlopen('https://api.cryptonator.com/api/ticker/btc-usd') 
is more than enough,no ? I'd suggest you we start from scratch again.Are you connected with the account SirLagsAlot anyway ? Nevermind your gh,says that.

Holy smokes! Python, PHP and NodeJS? There really is no reason to have 3 different server-side languages running at once. If you want one of your features to be "faster than preev" you'll need to cut down on the bloat. For example your node_modules directory is full of modules you aren't using.

What are you most experienced in? I'm guessing PHP based on the current source... My suggestion is you pick one server-side language and go with that, don't jump back and forth.

You can create one file that grabs all the necessary prices every N seconds and then stores them in a database. Then when doing the calculations for the users just pull from the database. You'll have the speed you want, and you won't have to worry about exceeding API request limits with the exchanges you are hitting.

Quote
I know the js to get the price to auto-update into a div, however for me it refuses it auto-update in the input box

For updating a div you typically do something like:

Code:
var myTarget = document.getElementById("myDiv");
myTarget.innerHTML = "My Text";

For updating an input box you need to change it from innerhtml to value.

Code:
var myTarget = document.getElementById("myInputBox");
myInputBox.value = "My Text";


I figured as much. I was told by a friend that PHP when compared to others is extremely slow, so I figured i'd make the base site out of php, then use javascript for clientside.

My python bot basically saves the output into a json. I could make a PHP bot but essentially it would be the same thing.

I know how to change the value of the input, but i've tried putting it into a function and getting json to call it repeatedly. It doesnt work. Maybe i'm missing something? Would you like me to make a jsfiddle?

Yea if you can put it in a JSfiddle I can help you get it working.


Title: Re: Making an open-source preev-like site. Anyone interested in helping out?
Post by: Decoded on October 16, 2016, 06:20:25 AM
Added source to OP. Please feel free to make a pull request! What I really need most is help with JavaScript!

(If you have any ideas at all, please suggest! Don't care if they're bad!)
Bro,literally you've too much of dependencies for a app as simple as this.Correct me if I'm wrong but what are the node modules for ? Perhaps the python lib for the price ticker that is
Code:
         response = urllib2.urlopen('https://api.cryptonator.com/api/ticker/btc-usd') 
is more than enough,no ? I'd suggest you we start from scratch again.Are you connected with the account SirLagsAlot anyway ? Nevermind your gh,says that.

Holy smokes! Python, PHP and NodeJS? There really is no reason to have 3 different server-side languages running at once. If you want one of your features to be "faster than preev" you'll need to cut down on the bloat. For example your node_modules directory is full of modules you aren't using.

What are you most experienced in? I'm guessing PHP based on the current source... My suggestion is you pick one server-side language and go with that, don't jump back and forth.

You can create one file that grabs all the necessary prices every N seconds and then stores them in a database. Then when doing the calculations for the users just pull from the database. You'll have the speed you want, and you won't have to worry about exceeding API request limits with the exchanges you are hitting.

Quote
I know the js to get the price to auto-update into a div, however for me it refuses it auto-update in the input box

For updating a div you typically do something like:

Code:
var myTarget = document.getElementById("myDiv");
myTarget.innerHTML = "My Text";

For updating an input box you need to change it from innerhtml to value.

Code:
var myTarget = document.getElementById("myInputBox");
myInputBox.value = "My Text";


I figured as much. I was told by a friend that PHP when compared to others is extremely slow, so I figured i'd make the base site out of php, then use javascript for clientside.

My python bot basically saves the output into a json. I could make a PHP bot but essentially it would be the same thing.

I know how to change the value of the input, but i've tried putting it into a function and getting json to call it repeatedly. It doesnt work. Maybe i'm missing something? Would you like me to make a jsfiddle?

Yea if you can put it in a JSfiddle I can help you get it working.

Here's a jsfiddle I put together. The best way to do this is to get the value to keep updating from a page, right?

http://jsfiddle.net/T7cZU/121/


Title: Re: Making an open-source preev-like site. Anyone interested in helping out?
Post by: MartinL on October 16, 2016, 06:29:34 AM
Here's a jsfiddle I put together. The best way to do this is to get the value to keep updating from a page, right?

http://jsfiddle.net/T7cZU/121/

There are two errors in that example. See a corrected version here (http://jsfiddle.net/T7cZU/122/). In general periodically polling for price updates is fine, but every 1.5 seconds is likely too frequent and might get you throttled.

What purpose does the back end fulfill? It seems you could forgo that and do everything you want to do on the client.


Title: Re: Making an open-source preev-like site. Anyone interested in helping out?
Post by: Decoded on October 16, 2016, 06:32:03 AM
Here's a jsfiddle I put together. The best way to do this is to get the value to keep updating from a page, right?

http://jsfiddle.net/T7cZU/121/

There are two errors in that example. See a corrected version here (http://jsfiddle.net/T7cZU/122/). In general periodically polling for price updates is fine, but every 1.5 seconds is likely too frequent and might get you throttled.

What purpose does the back end fulfill? It seems you could forgo that and do everything you want to do on the client.

Speed. The back end retrieves the exchange rates, crops of the unnecessary information, while the frontend simply gets it from the server and multiplies it by the amount.

I've already moved onto the live site, almost done with the live updating.


Title: Re: Making an open-source preev-like site. Anyone interested in helping out?
Post by: MartinL on October 16, 2016, 06:35:33 AM
Speed. The back end retrieves the exchange rates, crops of the unnecessary information, while the frontend simply gets it from the server and multiplies it by the amount.

Those are relatively inexpensive operations. Letting the client handle them would not lead to any noticeable performance losses.

It does significantly simplify your project and allow you to easily host it for free, however.


Title: Re: Making an open-source preev-like site. Anyone interested in helping out?
Post by: Decoded on October 16, 2016, 07:07:33 AM
Speed. The back end retrieves the exchange rates, crops of the unnecessary information, while the frontend simply gets it from the server and multiplies it by the amount.

Those are relatively inexpensive operations. Letting the client handle them would not lead to any noticeable performance losses.

It does significantly simplify your project and allow you to easily host it for free, however.

You make a compelling case. Another reason is that i'm much much more familiar with PHP than JavaScript. In fact, everything I know about it I just crammed in three hours.

I've made a push to github. After some testing, I can see that it's successfully querying the /api/btc/usd.php page, however the output shows NaN.

After further testing, it seems that what the js is returning from the page is [object Object]... working on this now.

Er... i've got it working for now, however it's still primitive, it get's the value after every keypress.


Title: Re: Making an open-source preev-like site. Anyone interested in helping out?
Post by: MartinL on October 16, 2016, 09:50:02 AM
A few more general observations: Checking dependencies into version control is unnecessary outside of a few exceptions and even considered bad practice. With Node.js, dependencies are often platform-specific, so they may not even be functional on architectures besides your own. Instead, specify your Node.js dependencies in a package.json (https://docs.npmjs.com/getting-started/using-a-package.json) file. Analogous tools exist for other languages and platforms.

The same goes for files such as logs, stack traces, configuration files and databases. These files are only meaningful in a narrow context, e.g. in a bug report, and therefore should not be checked in. You can use a .gitignore (https://git-scm.com/docs/gitignore) file to prevent these files from being shown in git and being accidentally committed.


Title: Re: Making an open-source preev-like site. Anyone interested in helping out?
Post by: coinableS on October 16, 2016, 03:27:04 PM
Er... i've got it working for now, however it's still primitive, it get's the value after every keypress.

Looks to be working for the BTC/USD. Only one direction, it doesn't reverse if the user enters in a USD amount.

Here's a very simple version that just uses javascript for everything and runs on the client side.
https://jsfiddle.net/yb4ot795/
Seems pretty fast without having to cache or store anything in a database. 


Title: Re: Making an open-source preev-like site. Anyone interested in helping out?
Post by: Decoded on October 19, 2016, 12:01:04 AM
Er... i've got it working for now, however it's still primitive, it get's the value after every keypress.

Looks to be working for the BTC/USD. Only one direction, it doesn't reverse if the user enters in a USD amount.

Here's a very simple version that just uses javascript for everything and runs on the client side.
https://jsfiddle.net/yb4ot795/
Seems pretty fast without having to cache or store anything in a database.  

I've updated github. Will push to my VPS. At the moment, i've done alot on my c9.io test site. Will update when bitprice.link is updated.

I also have acquired bitprice.info, so that's a plus too!

EDIT - Site is live. First page load may take about one second to get the prices, then after that the prices are cached until you refresh the page. Currently only works on USD, and will get it to auto-refresh prices.


Title: Re: [In-Development] BitPrice.link - Live Bitcoin/Crypto Calculator! [Open-Source]
Post by: Decoded on October 19, 2016, 11:38:33 PM
Could I get some help? I can't seem to understand what is wrong. Loaded straight from github, when I change the currency, I have to click it EUR three times before it changes the value. Same with changing back to USD.

Live test - bitprice.herokuapp.com


Title: Re: [In-Development] BitPrice.link - Live Bitcoin/Crypto Calculator! [Open-Source]
Post by: arunka71 on October 20, 2016, 04:14:32 PM
Why not use a a href for the menu items?


Title: Re: [In-Development] BitPrice.link - Live Bitcoin/Crypto Calculator! [Open-Source]
Post by: Decoded on October 31, 2016, 08:58:47 AM
Why not use a a href for the menu items?


I was going to get onto that, but I'm currently using a Semantic UI, which uses mainly divs.

Currently have yearlies, once they're over I'll start working on this again.


Title: Re: [In-Development] BitPrice.link - Live Bitcoin/Crypto Calculator! [Open-Source]
Post by: epson121 on October 31, 2016, 04:08:45 PM
Hey @Decoded,

it seems like semantic-UI has something to do with this. Most likely it's UI is updated after your getprices() function is called. In addition, the reload() function in update.js is not triggerred in intervals, making it unusable. The fastest I could do to try and fix this can be seen in this commit: commit (https://github.com/epson121/BitPrice/commit/2d152e86bfbc1a72369d265ad201dd09867d1d77)

I'm not sure if the code is intended to be run like this, and I would advise to remove the interval altogether, and at least use something native to semantic UI - check here (http://semantic-ui.com/modules/dropdown.html#specifying-select-action). Also, cleanup would come in very handy. There is a lot of unneeded code there, and a mix of a lot of technologies (php, sh, py, js, whole node_modules etc). I had to go through a lot of files to make sure it's safe to run it.





Title: Re: [In-Development] BitPrice.link - Live Bitcoin/Crypto Calculator! [Open-Source]
Post by: Decoded on November 01, 2016, 07:44:22 PM
Hey @Decoded,

it seems like semantic-UI has something to do with this. Most likely it's UI is updated after your getprices() function is called. In addition, the reload() function in update.js is not triggerred in intervals, making it unusable. The fastest I could do to try and fix this can be seen in this commit: commit (https://github.com/epson121/BitPrice/commit/2d152e86bfbc1a72369d265ad201dd09867d1d77)

I'm not sure if the code is intended to be run like this, and I would advise to remove the interval altogether, and at least use something native to semantic UI - check here (http://semantic-ui.com/modules/dropdown.html#specifying-select-action). Also, cleanup would come in very handy. There is a lot of unneeded code there, and a mix of a lot of technologies (php, sh, py, js, whole node_modules etc). I had to go through a lot of files to make sure it's safe to run it.
Bingo. I haven't made the push to GitHub yet, but I'm working on an entirely new drop down, without Semantic UI. What I found was that there was a lag after you clicked the button and until the div actually changed its contents.