Skip to content

Instantly share code, notes, and snippets.

@bakman2
Created January 13, 2018 21:40

Revisions

  1. bakman2 created this gist Jan 13, 2018.
    53 changes: 53 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,53 @@
    <?php
    include 'functions.php';
    include platformSlashes("lib/ccxt.php");
    $allcoins = file_get_contents(platformSlashes('lib/data/coinlist.json'));
    $coinList = json_decode($allcoins, true);
    echo "debug...";
    echo sizeof($config['api']). " keys found.<br/><br/>";

    if(isset($config['api']) && sizeof($config['api'])>0){
    foreach ($config['api'] as $key => $value) {


    $c = '\ccxt\\'.$key;
    try {
    $out = new $c ( array ( 'apiKey' => $config['api'][$key]['api'], 'secret' => $config['api'][$key]['secret'] ));

    foreach ($out->fetch_balance()['total'] as $k => $v) {

    if($v>0.0009){
    if(isset($coinList['Data'][$k]['CoinName'])){
    echo $key . ": symbol: ".$k." : ". $coinList['Data'][$k]['CoinName']. " balance:". $v."<br/>";
    $coindata['coins'][$key][$k]['wallettype'] = 'exchange';
    $coindata['coins'][$key][$k]['walletname'] = $key;
    $coindata['coins'][$key][$k]['name'] = $coinList['Data'][$k]['CoinName'];
    $coindata['coins'][$key][$k]['fullname'] = $coinList['Data'][$k]['FullName'];
    $coindata['coins'][$key][$k]['owned'] = $v;
    }
    }
    }

    }
    catch (Exception $e) {
    echo $e->getMessage ();
    }
    }
    }

    if(isset($coindata) && sizeof($coindata)>0){
    foreach ($coindata['coins'] as $key => $val) {

    foreach ($val as $i => $v) {
    if($v['owned']>0.001 || $v['walletname']=='watch'){
    $output[] = array("symbol"=>$i, "name"=>$v['name'], "wallettype"=>$v['wallettype'], "walletname"=>$v['walletname'], "coinsOwned"=>$v['owned'], "fullName"=>$v['fullname'], "image"=>symbol_lookup($i));
    $coins = $output;
    }
    }

    }
    }
    echo "<br/>";
    print_r($coins);

    ?>