コインチェックの販売所の見えない手数料(スプレッド)表示する方法

coincheckその他・雑記
スポンサーリンク

かにたまです。

 

以前、「コインチェックの高い売買手数料を自動的に計算して表示させる方法」を書きましたが、当時と比べるとモナコイン(mona)やステラ(stellar)などの通貨が記載されています。

 

そこで、本日は現状のコインチェックの販売所の見えない手数料(スプレッド)表示するコードを記載したいと思います。

 

良かったらご覧ください。

スポンサーリンク

コインチェックのスプレッドを可視化する 2019年~

可視化させると、このような表示になります。

 

 

やり方は「コインチェックの高い売買手数料を自動的に計算して表示させる方法」を参照して下さい。

 

ただし、1点だけ、以前とは張り付けるコードが違います。

先ほどご紹介したひとりぶろぐさんが作ったコードはstellarなどの新しくコインチェックで追加された仮想通貨のスプレッドが表示されません。

 

ではどうするかと言いますと、ひとりぶろぐさんが作られたコードをいじって新しくコインチェックで追加された通貨コードを入力する必要があります。

var currencies = ["btc","eth","etc","lsk","fct","xmr","rep","xrp","zec","xem","ltc","dash","bch","mona","xlm"];

赤字の,"mona","xlm"

"の部分が付け加えた部分です。

 

追加した部分を加えて現時点では以下の□内のコードを貼り付けます。

// ==UserScript==

// @name         CCSpreadVisualizer

// @namespace    http://hitoriblog.com/

// @version      0.2

// @description  try to take over the world!

// @author       moyashi

// @match        https://coincheck.com/ja/exchange

// @grant        none

// ==/UserScript==

 

(function() {

    'use strict';

 

function floatFormat( number, n ) {

    var _pow = Math.pow( 10 , n );

    return Math.round( number * _pow ) / _pow;

}

 

var currencies = ["btc","eth","etc","lsk","fct","xmr","rep","xrp","zec","xem","ltc","dash","bch","mona","xml"];

 

$(document).ready(function(){

    $.each(currencies,function(index, elem) {

        $("[href='/ja/buys?pair=" + elem +"_jpy']").append("<p class=\"currency_desc ng-binding append\"><span style=\"color:green; font-weight: bold;\">買</span><span id=\"" + elem +"-buy-price\"></span></p>");

        $("[href='/ja/buys?pair=" + elem +"_jpy']").append("<p class=\"currency_desc ng-binding append\">(<span id=\"" + elem +"-buy-difference\"></span>%)</p>");

        $("[href='/ja/buys?pair=" + elem +"_jpy']").append("<p class=\"currency_desc ng-binding append\"><span style=\"color:red; font-weight: bold;\">売</span><span id=\"" + elem +"-sell-price\"></span></p>");

        $("[href='/ja/buys?pair=" + elem +"_jpy']").append("<p class=\"currency_desc ng-binding append\">(<span id=\"" + elem +"-sell-difference\"></span>%)</p>");

    });

});

 

function updatePrice(currency) {

  $.getJSON("https://coincheck.com/buys/rate?amount=10&pair=" + currency +"_jpy",function getFunc(myData){

    var price = parseFloat(myData.price / 10);

    $("#" + currency +"-buy-price").text(floatFormat(price, 2));

    var org = parseFloat($("[href='/ja/buys?pair=" + currency +"_jpy'] p:contains('円')").text().replace("円",""));

    var difference = floatFormat((price / org - 1) * 100, 2);

    $("#" + currency +"-buy-difference").text(difference);

    $.getJSON("https://coincheck.com/sells/rate?amount=10&pair=" + currency +"_jpy",function getFunc(myData){

      var price = parseFloat(myData.price / 10);

      $("#" + currency +"-sell-price").text(floatFormat(price, 2));

      var org = parseFloat($("[href='/ja/buys?pair=" + currency +"_jpy'] p:contains('円')").text().replace("円",""));

      var difference = floatFormat((org / price - 1) * 100, 2);

      $("#" + currency +"-sell-difference").text(difference);

    });

  });

}

 

function update() {

    $.each(currencies,function(index, elem) {

        updatePrice(elem);

    });

}

 

update();

 

$(".ticker .box.last .value").on('DOMSubtreeModified propertychange',function() {

  update();

});

 

})();

このようにコインチェックで新しい仮想通貨が加えられるたびにvar currencies = []の部分に,"通貨記号"」を加えていけば新たな通貨の見えない手数料(スプレッド)を表示することができます。

 

コメント