Coinguide Update: Code Refactoring in progress, Gdax BTC and ETH Market Data now available, About, Privacy Policy and FAQs Page now available.
Repository
https://github.com/profchydon/coinguide
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 crypto exchanges's 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
Link to sixth update here
Link to seventh update here
Link to eight update here
Update:
Gdax BTC Market Data now available: Users can now have access to Gdax BTC and ETH Market data.
Code Refactoring : As advised by @justyy, I am in the process of refactoring the code to improve functionalities and also reduce code redundancy. Right now, i have moved the entire project to PHP Laravel framework and i'm in the process of getting all available market synced. So far, tradesatoshi and cryptopia exchange market have been successful.
About us Page and details now available: Coinguide about us details now available. Thanks to a contributor @wizzybright for providing the details.
Privacy Policy Page and details now available: Coinguide privacy details now available. Thanks to a contributor @wizzybright for providing the details.
FAQs Page and details now available: Coinguide frequently asked questions details now available. Thanks to a contributor @wizzybright for providing the details.
How I implemented this.
Making use of PHP Laravel framework gives me the flexibility and also utilizing the MVC architecture.
Model file
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Gdax extends Model
{
//
protected $fillable = [
'id', 'coin', 'product_id', 'currencypair', 'buy', 'total_buy_trade', 'current_buy', 'last_total_buy_trade'
];
}
Repository file handling the data and logic
<?php
namespace App\Http\Repositories;
use App\Gdax;
class GdaxRepository
{
protected $gdax;
public function __construct(Gdax $gdax)
{
$this->gdax = $gdax;
}
/**
* Fetches all coins from gdax via the endpoint /GetTradePairs
* @param
* @return array $coins
*/
public function getCoins ()
{
$coins = file_get_contents('https://api.gdax.com/products');
// Convert JSOn resource to object
$coins = json_decode($coins);
// Convert object to array
$coins = json_decode(json_encode($coins) , TRUE);
return $coins;
}
/**
* Fetches market history for each coin from gdax via the endpoint /GetMarketHistory
* @param $currencypair
* @return array $buy
*/
public function getBuy ($currencypair)
{
$buy = file_get_contents('https://api.gdax.com//products/'.$currencypair.'/trades');
// Convert JSOn resource to object
$buy = json_decode($buy);
// Convert object to array
$buy = json_decode(json_encode($buy) , TRUE);
return $buy;
}
public function saveData ($coin, $currencypair) {
$save = Gdax::create([
'coin' => $coin,
'currencypair' => $currencypair
]);
return $save ? true : false;
}
public function getAllCurrencyPair ()
{
$all = Gdax::select('currencypair')->get();
return json_decode(json_encode($all) , TRUE);
}
public function updateBuy ($currencypair, $buy)
{
$update = Gdax::where('currencypair', $currencypair)->update(['buy' => $buy]);
return $update ? true : false;
}
public function updateTotalBuy ($total_buy_trade)
{
$update = Gdax::update(['total_buy_trade' => $total_buy_trade]);
return $update ? true : false;
}
public function getAllByLimit ()
{
$all = Gdax::get();
return json_decode(json_encode($all) , TRUE);
}
}
Controller file to handle request and renders the appropriate view with the model data as a response.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Repositories\GdaxRepository;
class GdaxController extends Controller
{
//
protected $gdax;
public function __construct(GdaxRepository $gdax)
{
$this->gdax = $gdax;
}
public function getCoins ()
{
$coins = $this->gdax->getCoins();
return $coins;
}
public function saveCoins ()
{
$coins = $this->getCoins();
foreach ($coins as $key => $coin) {
if ($coin['quote_currency'] == "BTC") {
$coin_name = $coin['base_currency'];
$currencypair = $coin['id'];
$this->gdax->saveData ($coin_name, $currencypair);
}
}
}
public function getcurrencyPair ()
{
return $this->gdax->getAllCurrencyPair();
}
public function getMarketHistory ()
{
$currencypair = $this->getcurrencyPair();
$total_buy_trade = 0;
foreach ($currencypair as $key => $currencypair) {
$currencypair = $currencypair['currencypair'];
$result = $this->gdax->getBuy($currencypair);
$buy = 0;
foreach ($result as $key => $summary) {
if ($summary['side'] == "buy") {
$buy = $buy + 1;
}
}
$update = $this->gdax->updateBuy ($currencypair , $buy);
$total_buy_trade = $total_buy_trade + $buy;
}
$update_total_buy = $this->gdax->updateTotalBuy ($total_buy_trade);
}
public function viewMarket ()
{
$data['gdax'] = $this->gdax->getAllByLimit();
return view ('markets.gdax', $data);
}
}
Links to commits:
https://github.com/profchydon/coinguide/commit/136240b26bd4dd923f8feeeadd05356402877c5d
https://github.com/profchydon/coinguide/commit/f42814625eecb1669b15e1022a4d99bbab7054fe
https://github.com/profchydon/coinguide/commit/1173c88aa48296bf2329db2279009a9c2f36c1b2
https://github.com/profchydon/coinguide/commit/f63dc3e7a98ddfb7cef6947c4c396f1c457ab592
https://github.com/profchydon/coinguide/commit/383ccb1b64640c02094124f2b558c92ab5be6f5c
Thank you for your contribution, it has been approved.
Need help? Write a ticket on https://support.utopian.io.
Chat with us on Discord.
[utopian-moderator]
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit