Coinguide Update #4: A cryptocurrency trade guide (Bittrex market data now available)

in utopian-io •  7 years ago  (edited)

Coinguide Update: A cryptocurrency trade guide (Bittrex market data now available)


Project Overview


logo.png

COINGUIDE : a webapp that aims to guide crypto traders on the most popular Cryptocurrencies. It achieves this by fetching records from poloniex using their api, rating these records according to their buy orders.

Coinguide aims to keep traders informed about the popular coins (coins which the highest number of buy orders within a specific time range). A future goal of the project is to become a reliable platform that accurately ranks coins/tokens based on how much traders and buying a selling using a mathematical algorithms. Coinguide isn't a website that gives investors financial advise on which coin to buy or not, it simply gets the required data from poloniex api processes the data using an algorithm and tells users the coins gaining popularity and those loosing popularity.

Previous Update

Link to first update here

Link to second update here

Link to third update here

New Features

  • User can now switch to view any exchange market data from any dashboard. By selecting a market in the dropdown, user will be automatically redirected to the selected market.

markethome.png

  • Coinguide now has market data from bittrex exchange. So the big update is bittrex market data is now available on coinguide. Traders can now view bittrex market data on coinguide as well as market data from other exchanges (poloniex and coinexchange ).

Screenshot_2.png

How I implemented this.

<?php

function getCoins () {

    $coins = file_get_contents('https://bittrex.com/api/v1.1/public/getmarkets');

    // Convert JSOn resource to object
    $coins = json_decode($coins);

    // Convert object to array
    $coins = json_decode(json_encode($coins) , TRUE);

    return $coins;

}

function saveData($coin, $currencypair) {

    require '../database/database.php';
    $query = $pdo->prepare('INSERT into bittrex (coin , currencypair) values (:coin , :currencypair) ');
    $query->bindParam(':coin' , $coin);
    $query->bindParam(':currencypair' , $currencypair);

    if ($query->execute()) {

      return true;

    }else {

      return false;

    }

}

function getMarketSummary ($currencypair)
{

    $market_summary = file_get_contents('https://bittrex.com/api/v1.1/public/getmarketsummary?market='.$currencypair);

    return $market_summary;

}

function updateBittrexTable ($buy, $trade_volume, $currencypair)
{
    require '../database/database.php';
    $query = $pdo->prepare('UPDATE bittrex SET current_buy = :buy, trade_volume = :trade_volume WHERE currencypair = :currencypair');
    $query->bindParam(':buy' , $buy);
    $query->bindParam(':trade_volume' , $trade_volume);
    $query->bindParam(':currencypair' , $currencypair);
    if ($query->execute()) {
        return true;
    }else {
      return false;
    }
}

?>


I processed the fetched data in the process.php page

<?php

require_once '../function/bittrex.php';

$all_coins = getAll();

if (empty($all_coins)) {

  $coins = file_get_contents('https://bittrex.com/api/v1.1/public/getmarkets');

  // Convert JsOn resource to object
  $coins = json_decode($coins);

  // Convert object to array
  $coins = json_decode(json_encode($coins) , TRUE);

  $coins = $coins['result'];

  foreach ($coins as $key => $coin) {

       $coin_inactive = $coin['IsActive'];

       if ($coin_inactive && $coin["BaseCurrency"] == "BTC") {

       $coin_name = $coin['MarketCurrencyLong'];
       $currencypair = $coin['MarketName'];

       $save_data = saveData($coin_name , $currencypair);

      }

  }

}


foreach ($all_coins as $key => $coins) {

    $currencypair = $coins['currencypair'];

    $market_summary = getMarketSummary ($currencypair);

    // Convert JSOn resource to object
    $coins_summary = json_decode($market_summary);

    // Convert object to array
    $coins_summary = json_decode(json_encode($coins_summary) , TRUE);

    $coins = $coins_summary['result'];

    $buy = $coins[0]['OpenBuyOrders'];
    $trade_volume = $coins[0]['Volume'];

    $update_bittrex_table = updateBittrexTable ($buy, $trade_volume, $currencypair);

}



?>


Links to commits:

commit 1

commit 2

commit 3

commit 4

Website can be temporarily accessed here

Please i will gladly welcome your suggestions and idea, or even an algorithm you think will suit this webapp better. I will be adding data soon from other exchanges like kraken and binance. I will have to check the algorithm again to see if it will be efficient enough to provide the right results when data comes in from other exchanges. Your suggestions are highly valued.



Posted on Utopian.io - Rewarding Open Source Contributors

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

As a follower of @followforupvotes this post has been randomly selected and upvoted! Enjoy your upvote and have a great day!

Hey @profchydon I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x