Posts

Showing posts with the label How to get an average bitcoin to USD price from different sources

How to get an average bitcoin to USD price from different sources

How to get an average bitcoin to USD price from different sources I created a very simple php function to get the current price of bitcoin to USD here, //get from coin market $getCoinMarketPrice = getPrice('http://ift.tt/2qLq5pu'); $btcValues[1]= $getCoinMarketPrice[0]['price_usd']; //get from bitstamp // $getBitstampPrice = getPrice('http://ift.tt/29fu7gt'); $btcValues[2] = $getBitstampPrice['last']; //get from blockchain $getBlockchainPrice = getPrice('http://ift.tt/15HYrFZ'); $btcValues[3] = $getBlockchainPrice['USD']['last']; //get from cytptonator $getCtyptonatorPrice = getPrice('http://ift.tt/2kyBpkM'); $btcValues[4] = $getCtyptonatorPrice['ticker']['price']; $total=0; for ($i=0; $i < count($btcValues[$i]); $i++) { $total +=$btcValues[$i]; } $average = $total/count($btcValues[$i]); return $average; This Code here above will get bitcoin prices from different sources and add them togeth