2nd Crypto Portfolio

[insert_php] $myCoins = array( ‘BRD’ => array ( ‘balance’ => 17000 ), ‘NANO’ => array ( ‘balance’ => 17000 ), ‘PAX’ => array ( ‘balance’ => 17000 ), ‘ANT’ => array ( ‘balance’ => 17000 ), ‘ADA’ => array ( ‘balance’ => 17000 ), ‘DRGN’ => array ( ‘balance’ => 17000 ), ‘BAT’ => array ( ‘balance’ => 17000 ), ‘MFT’ => array ( ‘balance’ => 17000 ), ‘LOOM’ => array ( ‘balance’ => 17000 ), ‘LRC’ => array ( ‘balance’ => 17000 ), ‘BKX’ => array ( ‘balance’ => 17000 ), ‘KMD’ => array ( ‘balance’ => 1000 ), ‘AE’ => array ( ‘balance’ => 17000 ), ‘CVC’ => array ( ‘balance’ => 17000 ), ‘POWR’ => array ( ‘balance’ => 17000 ), ‘KNC’ => array ( ‘balance’ => 17000 ), ‘GNT’ => array ( ‘balance’ => 17000 ), ‘REP’ => array ( ‘balance’ => 1000 ), ‘KNC’ => array ( ‘balance’ => 1000 ), ‘NEO’ => array ( ‘balance’ => 1000 ), ‘MKR’ => array ( ‘balance’ => 10 ), ‘QKC’ => array ( ‘balance’ => 17000 ), ‘REQ’ => array ( ‘balance’ => 17000 ), ‘SNT’ => array ( ‘balance’ => 17000 ), ‘STORJ’ => array ( ‘balance’ => 17000 ), ); // ok now hit the api… $coinbasePublicAPI = ‘https://api.coinmarketcap.com/v1/ticker/?convert=$curr&limit=0’; $coinData = file_get_contents($coinbasePublicAPI); $coinData = json_decode($coinData, true); echo ‘‘; echo ‘‘; echo ‘‘; echo ‘‘; echo ‘‘; echo ‘‘; echo ‘‘; echo ‘‘; echo ‘‘; echo ‘‘; echo ‘‘; echo ‘‘; $numCoinbaseCoins = sizeof ($coinData); $portfolioValue = 0; for ( $xx=0; $xx<$numCoinbaseCoins; $xx++) { // this part compares your coins to the data... $thisCoinSymbol = $coinData[$xx]['symbol']; // if you have it, this var is true... $coinHeld = array_key_exists($thisCoinSymbol, $myCoins); // comment the next line out & you will see ALL of the coins // returned (not just the ones you own): if ( !$coinHeld ) { continue; } echo '‘; // name: echo ‘‘; // symbol: echo ‘‘; // symbol: echo ‘‘; // price: $thisCoinPrice = $coinData[$xx][‘price_usd’]; echo ‘‘; // holdings: echo ‘‘; // track running total value of coins: if ($coinHeld) { $myBalance_USD = $myBalance_units * $thisCoinPrice; $portfolioValue += $myBalance_USD; } // value: echo ‘‘; // 1h market change: echo ‘‘; // 24h market change: echo ‘‘; // 7d market change: echo ‘‘; echo ‘‘; } echo ‘‘; echo ‘‘; echo ‘‘; echo ‘‘; echo ‘
NAMESYMBOLRANKPRICEHOLDINGSVALUE1hr24hr7day
‘ . $coinData[$xx][‘name’] .’‘ . $thisCoinSymbol .’‘ . $coinData[$xx][‘rank’] .’$’ . number_format($thisCoinPrice,2) .’‘; if ($coinHeld) { $myBalance_units = $myCoins[$thisCoinSymbol][‘balance’]; echo number_format($myBalance_units,10); } echo ‘$’. number_format($myBalance_USD,2) .’‘ . $coinData[$xx][‘percent_change_1h’] .’%‘ . $coinData[$xx][‘percent_change_24h’] .’%‘ . $coinData[$xx][‘percent_change_7d’] .’%
TOTAL$’ . number_format($portfolioValue,2) . ‘
‘; [/insert_php]