Coinguide Update: A cryptocurrency trade guide (HitBTC market data now available) by profchydon

View this thread on steempeak.com
· @profchydon · (edited)
$106.56
Coinguide Update: A cryptocurrency trade guide (HitBTC market data now available)

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



### 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](https://utopian.io/utopian-io/@profchydon/development-of-coinguide-a-cryptocurrency-trade-guide)

Link to second update [here](https://utopian.io/utopian-io/@profchydon/coinguide-update-a-cryptocurrency-trade-guide)

Link to third update [here](https://utopian.io/utopian-io/@profchydon/coinguide-update-a-cryptocurrency-trade-guide-coinexchange-market-data-now-availbe)

Link to fourth update [here](https://utopian.io/utopian-io/@profchydon/coinguide-update-4-a-cryptocurrency-trade-guide-bittrex-market-data-now-available)



### New Features

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

![hitbtc2.png](https://cdn.utopian.io/posts/4785bd4ffbda6c2bb8b04eb4952762f505achitbtc2.png)



### How I implemented this.

I started by fetching all available coins from HitBTC using the API endpoint `https://api.hitbtc.com/api/2/public/currency` , then i got the market summary for each for the coins using the endpoint `https://api.hitbtc.com/api/2/public/trades/'.$currencypair`

I analyzed and processed the data to produce the table above



function.php

    <?php
    
    function getCoins () {
    
        $coins = file_get_contents('https://api.hitbtc.com/api/2/public/currency');
    
        // Convert JSOn resource to object
        $coins = json_decode($coins);
    
        // Convert object to array
        $coins = json_decode(json_encode($coins) , TRUE);
    
        return $coins;
    
    }
    
    function getSummary () {
    
        $coins = file_get_contents('https://api.hitbtc.com/api/2/public/symbol');
    
        // Convert JSOn resource to object
        $coins = json_decode($coins);
    
        // Convert object to array
        $coins = json_decode(json_encode($coins) , TRUE);
    
        return $coins;
    
    }
    
    function getBuy ($currencypair) {
    
        $buy = file_get_contents('https://api.hitbtc.com/api/2/public/trades/'.$currencypair);
    
        // Convert JSOn resource to object
        $buy = json_decode($buy);
    
        // Convert object to array
        $buy = json_decode(json_encode($buy) , TRUE);
    
        return $buy;
    
    }
    
    
    
    
    
    function saveData ($coin, $symbol) {
    
        require '../database/database.php';
        $query = $pdo->prepare('INSERT into hibtc (coin, symbol) values (:coin, :symbol)  ');
        $query->bindParam(':coin' , $coin);
        $query->bindParam(':symbol' , $symbol);
    
        if ($query->execute()) {
    
          return true;
    
        }else {
    
          return false;
    
        }
    
    }
    
    function updateTable ($symbol, $currencypair)
    {
        require '../database/database.php';
        $query = $pdo->prepare('UPDATE hibtc SET currencypair = :currencypair WHERE symbol = :symbol');
        $query->bindParam(':currencypair' , $currencypair);
        $query->bindParam(':symbol' , $symbol);
        if ($query->execute()) {
            return true;
        }else {
          return false;
        }
    }
    
    function updateBuy ($buy, $currencypair)
    {
        require '../database/database.php';
        $query = $pdo->prepare('UPDATE hibtc 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 hibtc SET total_buy_trade = :total_buy_trade');
        $query->bindParam(':total_buy_trade' , $total_buy_trade);
        if ($query->execute()) {
            return true;
        }else {
          return false;
        }
    }
    
    function getAll ()
    {
        require '../database/database.php';
        $query = $pdo->prepare('SELECT * FROM hibtc ORDER BY buy DESC LIMIT 30');
    
        if ($query->execute()) {
          $data = $query->fetchAll(PDO::FETCH_ASSOC);
        }
    
          return $data;
    
    }
    
    
     ?>
    



I processed the fetched data in the process.php page



    <?php
    
    require_once '../function/hitbtc.php';
    
    $coins = getCoins();
    
    foreach ($coins as $key => $coin) {
    
        if ($coin['delisted'] == false) {
    
          $coin_name = $coin['fullName'];
          $symbol = $coin['id'];
    
          $save_data = saveData($coin_name , $symbol);
    
        }
    
    }
    
    $summary = getSummary();
    
    foreach ($summary as $key => $coins) {
    
      if ($coins['quoteCurrency'] == "BTC") {
    
          $symbol = $coins['baseCurrency'];
          $currencypair = $coins['id'];
    
          $update_data = updateTable ($symbol, $currencypair);
    
      }
    
    }
    
    
    $all = getAll();
    
    $total_buy_trade = 0;
    
    foreach ($all as $key => $pair) {
    
        $currencypair = $pair['currencypair'];
    
        if (!empty($currencypair)) {
    
          $trades = getBuy ($currencypair);
    
          $buy = 0;
    
          foreach ($trades as $key => $trade) {
    
              if ($trade['side'] == "buy") {
    
                  $buy = $buy + 1;
    
              }
    
          }
    
          $update = updateBuy ($buy, $currencypair);
          $total_buy_trade = $total_buy_trade + $buy;
    
        }
    
    }
    
    updateTotalBuy ($total_buy_trade);
    
    foreach ($all as $key => $value) {
    
        $total_buy_trade = $total_buy_trade + $value['current_buy'];
    
    }
    //
    updateTotalBuy ($total_buy_trade);
    //
    //  ?>
    



### Links to commits:

[Link 1](https://github.com/profchydon/coinguide/commit/c43f0ba8ce7ac6712ad89ef011e893fc6a972927)



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.


<br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@profchydon/coinguide-update-a-cryptocurrency-trade-guide-hitbtc-market-data-now-available">Utopian.io -  Rewarding Open Source Contributors</a></em><hr/>
👍  , , , , , , , , , , , , , ,
properties (23)
post_id42,679,453
authorprofchydon
permlinkcoinguide-update-a-cryptocurrency-trade-guide-hitbtc-market-data-now-available
categoryutopian-io
json_metadata"{"staff_pick": null, "platform": "github", "config": {"questions": [{"question": "How would you rate the impact of the fixed bugs / new features on the project?", "answers": [{"answer": "Very high - the amount of work is very high.", "value": 20, "answer_id": 1}, {"answer": "High - the amount of work is high", "value": 15, "answer_id": 2}, {"answer": "Average - the amount of work is average", "value": 10, "answer_id": 3}, {"answer": "Low - the amount of work is low.", "value": 5, "answer_id": 4}, {"answer": "Very Low - the amount of work is very little.", "value": 0, "answer_id": 5}], "question_id": "dev-1"}, {"question": "How would you rate the quality of the provided code?", "answers": [{"answer": "Very high - the code follows all the best practices and/or is the opposite of trivial.", "value": 20, "answer_id": 1}, {"answer": "High - the code follows nearly all the best practices and/or is not trivial at all. ", "value": 15, "answer_id": 2}, {"answer": "Average - the code follows most the best practices and/or some parts of it are trivial.", "value": 10, "answer_id": 3}, {"answer": "Low - the code doesn't really follow the best practices and/or a lot of it is trivial.", "value": 5, "answer_id": 4}, {"answer": "Very low - the code doesn't follow the best practices and is completely trivial.", "value": 0, "answer_id": 5}], "question_id": "dev-2"}, {"question": "How do you rate the target project overall?", "answers": [{"answer": "Very high - the project has a unique value, will (potentially) also be useful to a lot of people and has the potential to keep growing.", "value": 10, "answer_id": 1}, {"answer": "High - the project isn't really unique but it is well maintained.", "value": 8, "answer_id": 2}, {"answer": "Average - the project is limited or not very well maintained.", "value": 4, "answer_id": 3}, {"answer": "Low - quality of the project overall is low.", "value": 2, "answer_id": 4}, {"answer": "Very low - quality of the project overall is very low and not well maintained.", "value": 0, "answer_id": 5}], "question_id": "dev-3"}, {"question": "Does the writing style meet the Utopian standard considering formalness, informativeness and clarity of the content?", "answers": [{"answer": "It is formal, informative and well written with clear content.", "value": 10, "answer_id": 1}, {"answer": "It is informative with clear content but not formal enough.", "value": 5, "answer_id": 2}, {"answer": "The contribution could be more informative or contains unrelated information, formality and clarity of the content are good enough.", "value": 4, "answer_id": 3}, {"answer": "Not all sections were clear enough but overall holds value for the project.", "value": 2, "answer_id": 4}, {"answer": "Not at all.", "value": 0, "answer_id": 5}], "question_id": "c-1"}, {"question": "Was the provided category template for the editor followed?", "answers": [{"answer": "All points of the template were included with additional points as well.", "value": 5, "answer_id": 1}, {"answer": "The template was followed without additions.", "value": 4, "answer_id": 2}, {"answer": "The template was edited but the points were covered in different way.", "value": 3, "answer_id": 3}, {"answer": "Not all points of the template were covered in the contribution but the structure is clear enough.", "value": 3, "answer_id": 4}, {"answer": "The template was not followed but the structure is clear enough.", "value": 2, "answer_id": 5}, {"answer": "The contents are not clearly structured at all.", "value": 0, "answer_id": 6}], "question_id": "c-2"}, {"question": "Did the contributor tag other users?", "answers": [{"answer": "No other users were tagged by the contributor.", "value": 5, "answer_id": 1}, {"answer": "Used tags are reasonable and all tagged people are connected to the project and/or the contribution.", "value": 5, "answer_id": 2}, {"answer": "The contribution contains mentions of other users that are not directly related to the contribution but related in other ways.", "value": 2, "answer_id": 3}, {"answer": "The contributor misuses tagging of other users.", "value": 0, "answer_id": 4}], "question_id": "c-3"}, {"question": "Did the contributor ask for upvotes, resteems, follows or witness vote?", "answers": [{"answer": "No", "value": 5, "answer_id": 1}, {"answer": "Yes, but not in a way that disturbs readability. ", "value": 5, "answer_id": 2}, {"answer": "Yes.", "value": 0, "answer_id": 3}], "question_id": "c-4"}, {"question": "Was a graphical content like images, charts, videos or screenshots included?", "answers": [{"answer": "Yes, the graphical content is included and adds more value to the contribution.", "value": 5, "answer_id": 1}, {"answer": "No but the contribution works well without graphical content well.", "value": 4, "answer_id": 2}, {"answer": "Yes, but most of the graphical content\u2019s purpose is just for presentational matters.", "value": 3, "answer_id": 3}, {"answer": "No relevant or useful graphical content is included in the contribution.", "value": 0, "answer_id": 4}], "question_id": "c-5"}, {"question": "How would you rate the overall added value?", "answers": [{"answer": "Extraordinary value to both the project and the open source community overall.", "value": 20, "answer_id": 1}, {"answer": "Significant value to the project or open source community.", "value": 15, "answer_id": 2}, {"answer": "Some value to the project or open source community.", "value": 10, "answer_id": 3}, {"answer": "Little value to the project or open source community.", "value": 5, "answer_id": 4}, {"answer": "No obvious value to project or open source community.", "value": 0, "answer_id": 5}], "question_id": "c-6"}]}, "pullRequests": [], "users": ["profchydon"], "questions": {"total_influence": 0, "voters": ["codingdefined"], "answers": [{"user": "codingdefined", "influence": 60, "answer_id": 3, "question_id": "dev-1"}, {"user": "codingdefined", "influence": 60, "answer_id": 3, "question_id": "dev-2"}, {"user": "codingdefined", "influence": 60, "answer_id": 2, "question_id": "dev-3"}, {"user": "codingdefined", "influence": 60, "answer_id": 1, "question_id": "c-1"}, {"user": "codingdefined", "influence": 60, "answer_id": 3, "question_id": "c-2"}, {"user": "codingdefined", "influence": 60, "answer_id": 1, "question_id": "c-3"}, {"user": "codingdefined", "influence": 60, "answer_id": 1, "question_id": "c-4"}, {"user": "codingdefined", "influence": 60, "answer_id": 1, "question_id": "c-5"}, {"user": "codingdefined", "influence": 60, "answer_id": 4, "question_id": "c-6"}], "most_rated": [{"voters": ["codingdefined"], "influence": 60, "answer_id": 3, "question_id": "dev-1"}, {"voters": ["codingdefined"], "influence": 60, "answer_id": 3, "question_id": "dev-2"}, {"voters": ["codingdefined"], "influence": 60, "answer_id": 2, "question_id": "dev-3"}, {"voters": ["codingdefined"], "influence": 60, "answer_id": 1, "question_id": "c-1"}, {"voters": ["codingdefined"], "influence": 60, "answer_id": 3, "question_id": "c-2"}, {"voters": ["codingdefined"], "influence": 60, "answer_id": 1, "question_id": "c-3"}, {"voters": ["codingdefined"], "influence": 60, "answer_id": 1, "question_id": "c-4"}, {"voters": ["codingdefined"], "influence": 60, "answer_id": 1, "question_id": "c-5"}, {"voters": ["codingdefined"], "influence": 60, "answer_id": 4, "question_id": "c-6"}]}, "app": "utopian/1.0.0", "score": 61, "type": "development", "links": ["https://utopian.io/utopian-io/@profchydon/development-of-coinguide-a-cryptocurrency-trade-guide", "https://utopian.io/utopian-io/@profchydon/coinguide-update-a-cryptocurrency-trade-guide", "https://utopian.io/utopian-io/@profchydon/coinguide-update-a-cryptocurrency-trade-guide-coinexchange-market-data-now-availbe", "https://utopian.io/utopian-io/@profchydon/coinguide-update-4-a-cryptocurrency-trade-guide-bittrex-market-data-now-available", "https://cdn.utopian.io/posts/4785bd4ffbda6c2bb8b04eb4952762f505achitbtc2.png", "https://github.com/profchydon/coinguide/commit/c43f0ba8ce7ac6712ad89ef011e893fc6a972927"], "moderator": {"time": "2018-04-11T10:27:56.142Z", "pending": false, "reviewed": true, "flagged": false, "account": "codingdefined"}, "community": "utopian", "tags": ["utopian-io", "coinguide", "stach", "steembees", "development"], "total_influence": 60, "repository": {"full_name": "profchydon/coinguide", "owner": {"login": "profchydon"}, "id": 125532584, "fork": false, "html_url": "https://github.com/profchydon/coinguide", "name": "coinguide"}, "image": ["https://cdn.utopian.io/posts/4785bd4ffbda6c2bb8b04eb4952762f505achitbtc2.png"], "format": "markdown"}"
created2018-04-08 21:45:03
last_update2018-04-11 10:27:57
depth0
children3
net_rshares29,090,789,525,058
last_payout2018-04-15 21:45:03
cashout_time1969-12-31 23:59:59
total_payout_value74.273 SBD
curator_payout_value32.284 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length7,503
author_reputation8,275,186,260,175
root_title"Coinguide Update: A cryptocurrency trade guide (HitBTC market data now available)"
beneficiaries
0.
weight2,500
accountutopian.pay
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (15)
@a-0-0 ·
https://steemit.com/@a-0-0
properties (22)
post_id42,679,464
authora-0-0
permlinkre-profchydon-coinguide-update-a-cryptocurrency-trade-guide-hitbtc-market-data-now-available-20180408t214509048z
categoryutopian-io
json_metadata"{"links": ["https://steemit.com/@a-0-0"], "app": "steemit/0.1", "tags": ["utopian-io"]}"
created2018-04-08 21:45:12
last_update2018-04-08 21:45:12
depth1
children0
net_rshares0
last_payout2018-04-15 21:45:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length26
author_reputation-4,860,340,175,990
root_title"Coinguide Update: A cryptocurrency trade guide (HitBTC market data now available)"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@codingdefined ·
Than you for your contribution.

----------------------------------------------------------------------
Need help? Write a ticket on https://support.utopian.io.
Chat with us on [Discord](https://discord.gg/uTyJkNm).

**[[utopian-moderator]](https://utopian.io/moderators)**
properties (22)
post_id43,063,112
authorcodingdefined
permlinkre-profchydon-coinguide-update-a-cryptocurrency-trade-guide-hitbtc-market-data-now-available-20180411t102722702z
categoryutopian-io
json_metadata"{"app": "utopian/1.0.0", "community": "utopian", "tags": ["utopian-io"]}"
created2018-04-11 10:27:24
last_update2018-04-11 10:27:24
depth1
children0
net_rshares0
last_payout2018-04-18 10:27:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length273
author_reputation71,157,752,447,147
root_title"Coinguide Update: A cryptocurrency trade guide (HitBTC market data now available)"
beneficiaries
0.
weight1,500
accountutopian.pay
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@utopian-io ·
### 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!
<a href="https://discord.gg/zTrEMqB">Participate on Discord</a>. Lets GROW TOGETHER!
- <a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1">Vote for my Witness</a>
- <a href="https://v2.steemconnect.com/sign/account-witness-proxy?proxy=utopian-io&approve=1">Proxy vote to Utopian Witness</a>

**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**
properties (22)
post_id43,077,088
authorutopian-io
permlinkre-profchydon-coinguide-update-a-cryptocurrency-trade-guide-hitbtc-market-data-now-available-20180411t121954522z
categoryutopian-io
json_metadata"{"app": "utopian/1.0.0", "community": "utopian", "tags": ["utopian-io"]}"
created2018-04-11 12:19:54
last_update2018-04-11 12:19:54
depth1
children0
net_rshares0
last_payout2018-04-18 12:19:54
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length715
author_reputation152,913,012,544,965
root_title"Coinguide Update: A cryptocurrency trade guide (HitBTC market data now available)"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000