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

in utopian-io •  7 years ago  (edited)

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



coinlogo.png

Project Overview


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

Link to fourth update here

Link to fifth update here

New Features


home.png

Coinguide now has market data from Tradesatoshi exchange. So the big update is Tradesatoshi market data is now available on coinguide. Traders can now view Tradesatoshi market data on coinguide as well as market data from other exchanges.

trade.png

How I implemented this.


I started by fetching all available coins from Tradesatoshi using the API endpoint https://tradesatoshi.com/api/public/getcurrencies , then i got the market summary for each for the coins using the endpoint https://tradesatoshi.com/api/public/getmarkethistory?market='.$currencypair.'&count=200

I analyzed and processed the data to produce the table above

function.php

<?php

function getCoins () {

    $coins = file_get_contents('https://tradesatoshi.com/api/public/getcurrencies');

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

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

    return $coins['result'];

}

function getSummary ($currencypair) {

    $coins = file_get_contents('https://tradesatoshi.com/api/public/getmarkethistory?market='.$currencypair.'&count=200');

    // 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 tradesatoshi (coin, currencypair) values (:coin, :currencypair)  ');
    $query->bindParam(':coin' , $coin);
    $query->bindParam(':currencypair' , $currencypair);

    if ($query->execute()) {

      return true;

    }else {

      return false;

    }

}

function getAll ()
{
    require '../database/database.php';
    $query = $pdo->prepare('SELECT * FROM tradesatoshi ORDER BY buy DESC');

    if ($query->execute()) {
      $data = $query->fetchAll(PDO::FETCH_ASSOC);
    }

      return $data;

}

function getAllByLimit ()
{
    require '../database/database.php';
    $query = $pdo->prepare('SELECT * FROM tradesatoshi ORDER BY buy DESC LIMIT 40');

    if ($query->execute()) {
      $data = $query->fetchAll(PDO::FETCH_ASSOC);
    }

      return $data;

}


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

function updateTotalBuy ($total_buy_trade)
{
    require '../database/database.php';
    $query = $pdo->prepare('UPDATE tradesatoshi SET total_buy_trade = :total_buy_trade');
    $query->bindParam(':total_buy_trade' , $total_buy_trade);
    if ($query->execute()) {
        return true;
    }else {
      return false;
    }
}

?>

I processed the fetched data in the process.php page

<?php

include '../function/tradesatoshi.php';

$coins = getCoins();
$all = getAll();

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

    if ($coin['status'] == "OK") {

        $coin_name = $coin['currencyLong'];
        $currencypair = $coin['currency']."_BTC";

        saveData ($coin_name, $currencypair);

    }

}

$total_buy_trade = 0;

foreach ($all as $key => $all) {

    $currencypair = $all['currencypair'];
    $summary = getSummary($currencypair);
    $result = $summary['result'];

    $buy = 0;

    foreach ($result as $key => $summary) {

      if ($summary['orderType'] == "Buy") {

          $buy = $buy + 1;

      }

    }

    $update = updateBuy ($buy, $currencypair);
    $total_buy_trade = $total_buy_trade + $buy;

}

updateTotalBuy ($total_buy_trade);

 ?>

Links to commits:

Link 1

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:  

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!

Utopian Witness!

Participate on Discord. Lets GROW TOGETHER!

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

Thank you for your contribution.


Need help? Write a ticket on https://support.utopian.io.
Chat with us on Discord.

[utopian-moderator]