Author

Topic: need help with price ticker , im noob :) (Read 911 times)

legendary
Activity: 854
Merit: 1000
February 12, 2016, 10:15:24 PM
#8
You can use this example code in php:

      function getPrice($url) {
      $decode = file_get_contents($url);
      return json_decode($decode, true);
                              }

      $btcUSD = getPrice('https://api.kraken.com/0/public/Ticker?pair=XXBTZUSD');
      $btcPrice = $btcUSD["result"]["XXBTZUSD"]["c"][0];
      echo number_format (($btcPrice ), 2)." ". "USD" ;
      ?>

it follows Kraken market price for BTC if you want to do some changes in current price in USD dollars you can just write in ($btcPrice - or + how much you want to reduce or higher the price) and you are ready. It updates itself live and you have a ticker

I learned that PHP isn't the best and the most secure thing you could use.. Much better to keep up with technology and just use the javascript since it's a frontend language you could learn to use with other backend technologies Smiley
hero member
Activity: 1204
Merit: 501
Radix-The Decentralized Finance Protocol
February 12, 2016, 04:28:36 PM
#7
You can use this example code in php:

      function getPrice($url) {
      $decode = file_get_contents($url);
      return json_decode($decode, true);
                              }

      $btcUSD = getPrice('https://api.kraken.com/0/public/Ticker?pair=XXBTZUSD');
      $btcPrice = $btcUSD["result"]["XXBTZUSD"]["c"][0];
      echo number_format (($btcPrice ), 2)." ". "USD" ;
      ?>

it follows Kraken market price for BTC if you want to do some changes in current price in USD dollars you can just write in ($btcPrice - or + how much you want to reduce or higher the price) and you are ready. It updates itself live and you have a ticker
legendary
Activity: 854
Merit: 1000
February 12, 2016, 07:16:17 AM
#6

Code:
setInterval(function(){
 INSERT CODE HERE
 }, 2000);
full member
Activity: 151
Merit: 100
sr. member
Activity: 277
Merit: 250
February 11, 2016, 06:08:41 PM
#4
ok i managed to set the 5% but how do i set the interval :O
sr. member
Activity: 277
Merit: 250
February 11, 2016, 05:40:05 PM
#3
1. I recommend you don't use wix.com

2. Try using setInterval() for updating the price
read up on it on W3Schools.com or something

3. data["last"].toFixed(2) this gets the data from

https://api.bitcoinaverage.com/ticker/global/USD/
Code:
{
  "24h_avg": 381.58,
  "ask": 378.13,
  "bid": 377.6,
  "last": 378.0, // The data here is used (data["last"])
  "timestamp": "Thu, 11 Feb 2016 15:04:41 -0000",
  "volume_btc": 73598.5,
  "volume_percent": 76.12
}

now you have that, you get that value, + 5%

1 = 100%
0.01 = 1%

Therefore the value + 5% is = value * 1.05

I don't want to give you the actual code, so you can learn Smiley

Regards,
JM Erestain

i know its * 1.05 i just dont know where to put it in the code ;(
legendary
Activity: 854
Merit: 1000
February 11, 2016, 10:07:06 AM
#2
1. I recommend you don't use wix.com

2. Try using setInterval() for updating the price
read up on it on W3Schools.com or something

3. data["last"].toFixed(2) this gets the data from

https://api.bitcoinaverage.com/ticker/global/USD/
Code:
{
  "24h_avg": 381.58,
  "ask": 378.13,
  "bid": 377.6,
  "last": 378.0, // The data here is used (data["last"])
  "timestamp": "Thu, 11 Feb 2016 15:04:41 -0000",
  "volume_btc": 73598.5,
  "volume_percent": 76.12
}

now you have that, you get that value, + 5%

1 = 100%
0.01 = 1%

Therefore the value + 5% is = value * 1.05

I don't want to give you the actual code, so you can learn Smiley

Regards,
JM Erestain
sr. member
Activity: 277
Merit: 250
February 11, 2016, 07:12:49 AM
#1
Below is the code im using to show price ticker on my wix.com site.

Now I'd like to add +5% to the ticker (which is my fee for my service).

How can i print: btc price + extra 5%? and how can i print -5%?

Also this ticker only works when i refresh the website, is it also possible to do it real time?

Thanks Smiley


Quote


Jump to: