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 ‘NAME | ‘; echo ‘SYMBOL | ‘; echo ‘RANK | ‘; echo ‘PRICE | ‘; echo ‘HOLDINGS | ‘; echo ‘VALUE | ‘; echo ‘1hr | ‘; echo ‘24hr | ‘; echo ‘7day | ‘; echo ‘
‘ . $coinData[$xx][‘name’] .’ | ‘; // symbol: echo ‘‘ . $thisCoinSymbol .’ | ‘; // symbol: echo ‘‘ . $coinData[$xx][‘rank’] .’ | ‘; // price: $thisCoinPrice = $coinData[$xx][‘price_usd’]; echo ‘$’ . number_format($thisCoinPrice,2) .’ | ‘; // holdings: echo ‘‘; if ($coinHeld) { $myBalance_units = $myCoins[$thisCoinSymbol][‘balance’]; echo number_format($myBalance_units,10); } echo ‘ | ‘; // track running total value of coins: if ($coinHeld) { $myBalance_USD = $myBalance_units * $thisCoinPrice; $portfolioValue += $myBalance_USD; } // value: echo ‘$’. number_format($myBalance_USD,2) .’ | ‘; // 1h market change: echo ‘‘ . $coinData[$xx][‘percent_change_1h’] .’% | ‘; // 24h market change: echo ‘‘ . $coinData[$xx][‘percent_change_24h’] .’% | ‘; // 7d market change: echo ‘‘ . $coinData[$xx][‘percent_change_7d’] .’% | ‘; echo ‘
TOTAL | ‘; echo ‘$’ . number_format($portfolioValue,2) . ‘ | ‘; echo ‘