Created
April 16, 2014 10:29
-
-
Save bigprof/10849285 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* use this code as a guide for how to fetch bitcoin historical trade data from bitcoincharts, based on Bitstamp.net */ | |
/* historical interval in hours */ | |
define('AVERAGE_INTERVAL', 6); | |
$hist = file("http://api.bitcoincharts.com/v1/trades.csv?symbol=bitstampUSD&start=" . (time() - AVERAGE_INTERVAL * 3600)); | |
if(!is_array($hist)) die("Unable to fetch data .. Try again later!"); | |
$trades = array(); | |
foreach($hist as $entry){ | |
$trades[] = explode(',', trim($entry)); | |
} | |
?><pre dir="ltr"><? print_r($trades); ?></pre><? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment