Bitcoin Forum
December 14, 2017, 06:53:43 AM *
News: Latest stable version of Bitcoin Core: 0.15.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: need help with price ticker , im noob :)  (Read 832 times)
deliveryman
Sr. Member
****
Offline Offline

Activity: 244


View Profile
February 11, 2016, 12:12:49 PM
 #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
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $.getJSON("https://api.bitcoinaverage.com/ticker/global/USD/", function(data){
            $("#BTCPrice").append("<center>USD/BTC " + data["last"].toFixed(2) + "</center>")
        })
    })
</script>
<div id="BTCPrice" style="height:20px;margin:auto;font-family: verdana;font-size: 13;font-weight: bold;position:absolute;color: white;top:10;left:0;bottom:0;right:0" />
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
Emerge
Hero Member
*****
Offline Offline

Activity: 770



View Profile
February 11, 2016, 03:07:06 PM
 #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

           ▄▄█████████▄▄
       ▄████▀▀       ▀▀████▄
     ▄██▀▀               ▀▀██▄
    ██▀                    ████
   ██                     ███▀██
  ██                    ▄██▀   ██
 ██                    ▄██      ██
██▀                  ▄██▀      ▄███
██                  ▄██      ▄██▀██
██                 ██▀    ▄███▀  ██
██               ▄██▀   ▄██▀     ██
██▄             ▄██  ▄███▀      ▄██
 ██           ▄██▀ ▄██▀         ██
  ██         ▄██▄███▀          ██
   ██       █████▀            ██
    ██▄   ▄████▀            ▄██
     ▀██▄███▀            ▄▄██▀
       ▀████▄▄       ▄▄████▀
           ▀▀█████████▀▀
.L I V E T R E E   A D E P T TM.
Own the future of entertainment
The World's 1st Community-Powered,
Film, TV and Content Network  ★
deliveryman
Sr. Member
****
Offline Offline

Activity: 244


View Profile
February 11, 2016, 10: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 ;(
deliveryman
Sr. Member
****
Offline Offline

Activity: 244


View Profile
February 11, 2016, 11:08:41 PM
 #4

ok i managed to set the 5% but how do i set the interval :O
1000000
Full Member
***
Offline Offline

Activity: 150



View Profile
February 11, 2016, 11:24:03 PM
 #5

ok i managed to set the 5% but how do i set the interval :O
http://www.w3schools.com/jsref/met_win_setinterval.asp Wink

“The Times 03/Jan/2009 Chancellor on brink of second bailout for banks”
Emerge
Hero Member
*****
Offline Offline

Activity: 770



View Profile
February 12, 2016, 12:16:17 PM
 #6


Code:
setInterval(function(){
 INSERT CODE HERE
 }, 2000);

           ▄▄█████████▄▄
       ▄████▀▀       ▀▀████▄
     ▄██▀▀               ▀▀██▄
    ██▀                    ████
   ██                     ███▀██
  ██                    ▄██▀   ██
 ██                    ▄██      ██
██▀                  ▄██▀      ▄███
██                  ▄██      ▄██▀██
██                 ██▀    ▄███▀  ██
██               ▄██▀   ▄██▀     ██
██▄             ▄██  ▄███▀      ▄██
 ██           ▄██▀ ▄██▀         ██
  ██         ▄██▄███▀          ██
   ██       █████▀            ██
    ██▄   ▄████▀            ▄██
     ▀██▄███▀            ▄▄██▀
       ▀████▄▄       ▄▄████▀
           ▀▀█████████▀▀
.L I V E T R E E   A D E P T TM.
Own the future of entertainment
The World's 1st Community-Powered,
Film, TV and Content Network  ★
Embat
Hero Member
*****
Offline Offline

Activity: 494



View Profile
February 12, 2016, 09:28:36 PM
 #7

You can use this example code in php:

<?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

        ETHEAL           ETHEAL
      ETHEALETHE       ETHEALETHE
    ETHEALETHEALET   ETHEALETHEALET
  ETHEALETHEALETHEA ETHEALETHEALETHEA
 ETHEALETHEALETHEALETHEALETHEALETHEALE
ETHEALETHEALETHEALETHEALETHEALETHEALETH
ETHEALETHEALETHEALETHEALETHEALETHEALETH
ETHEALETHEALETHEALETHEALETHEALETHEALETH
 ETHEALETHEALETHEALETHEALETHEALETHEALE
  ETHEALETHEALETHEALETHEALETHEALETHEA
   ETHEALETHEALETHEALETHEALETHEALETH
    ETHEALETHEALETHEALETHEALETHEALE
      ETHEALETHEALETHEALETHEALETH
        ETHEALETHEALETHEALETHEA
          ETHEALETHEALETHEALE
            ETHEALETHEALETH
              ETHEALETHEA
                ETHEALE
                  ETH
                   E


🅽🅴🆆 Operating System of $7600B+ 🏥 Healthcare industry
🕸 Website  📝 Whitepaper  Video  📢 ANN  💰 Bounty  💬 Telegram
Improving the lives of 1 billion people by making Healthcare transparent.


Emerge
Hero Member
*****
Offline Offline

Activity: 770



View Profile
February 13, 2016, 03:15:24 AM
 #8

You can use this example code in php:

<?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

           ▄▄█████████▄▄
       ▄████▀▀       ▀▀████▄
     ▄██▀▀               ▀▀██▄
    ██▀                    ████
   ██                     ███▀██
  ██                    ▄██▀   ██
 ██                    ▄██      ██
██▀                  ▄██▀      ▄███
██                  ▄██      ▄██▀██
██                 ██▀    ▄███▀  ██
██               ▄██▀   ▄██▀     ██
██▄             ▄██  ▄███▀      ▄██
 ██           ▄██▀ ▄██▀         ██
  ██         ▄██▄███▀          ██
   ██       █████▀            ██
    ██▄   ▄████▀            ▄██
     ▀██▄███▀            ▄▄██▀
       ▀████▄▄       ▄▄████▀
           ▀▀█████████▀▀
.L I V E T R E E   A D E P T TM.
Own the future of entertainment
The World's 1st Community-Powered,
Film, TV and Content Network  ★
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!