Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gil dev #41

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ <h1>Highest price differences + pairs</h1>

<script id="high-template" type="text/x-handlebars-template">
<li class="coin-info-high " data-coin="{{coin}}" data-market1="{{market1}}" data-market2="{{market2}}">
<h1>Transfer <strong>{{coin}}</strong> from <strong>{{market1}}</strong> to <strong> {{market2}}</strong> for a
<h1>Transfer <strong>{{coin}}</strong> from <strong><a href="{{coinlink1}}">{{market1}}</a></strong> to <strong><a href="{{coinlink2}}">{{market2}}</a></strong> for a
profit of
<strong> {{diff}}%</strong></h1>
<div class="coin">
Expand All @@ -254,15 +254,15 @@ <h1>Transfer <strong>{{coin}}</strong> from <strong>{{market1}}</strong> to <str
Remove this opportunity </a>
</li>
<li class="coin-info-low" data-coin="{{pair.coin}}" data-market1="{{pair.market1}}" data-market2="{{pair-market2}}">
<h1>sell for <strong>{{pair.coin}}</strong> and transfer back to <strong> {{pair.market2}}
({{pair.diff}}%)</strong>
<h1>sell for <strong>{{pair.coin}}</strong> and transfer back to <strong><a href="{{coinlink1}}"> {{pair.market1}}
({{pair.diff}}%)</a></strong>
</h1>
<div class="coin">
<i class="cc-{{pair.coin}} {{pair.coin}} cc"> </i>
<p class="coin-name">{{pair.coin}}</p>
<p class="coin-prices">{{pair.diff}}%</p>
<p class="coin-markets"><a>{{pair.market1}}</a>: {{pair.market1price}}<span class="mBTC">mBTC</span> <i
class="fa fa-long-arrow-right"></i> <a>{{pair.market2}}</a>: {{pair.market2price}}<span
<p class="coin-markets"><a>{{pair.market1}}</a>: {{pair.market2price}}<span class="mBTC">mBTC</span> <i
class="fa fa-long-arrow-right"></i> <a>{{pair.market2}}</a>: {{pair.market1price}}<span
class="mBTC">mBTC</span>
</p>
</div>
Expand Down
15 changes: 15 additions & 0 deletions docs/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,21 @@ $(window).load(function () {

});

function coinLinkBuilder(coin, market){
var marketBaseLinks = {
poloniex: 'https://poloniex.com/exchange#btc_',
bittrex: 'https://bittrex.com/Market/Index?MarketName=BTC-',
btc38: 'http://www.btc38.com/trade_en.html?btc38_trade_coin_name=',
jubi: 'https://www.jubi.com/coin/',
cryptopia: 'https://www.cryptopia.co.nz/Exchange/?market=',
bleutrade: 'https://bleutrade.com/exchange/',
kraken: 'https://www.kraken.com/u/trade'
}
if(market.includes('cryptopia')) return marketBaseLinks[market]+coin+'_BTC';
else if(market.includes('bleutrade')) return marketBaseLinks[market]+coin+'/BTC';
else if(market.includes('kraken')) return marketBaseLinks[market];
else return marketBaseLinks[market]+coin;
}
});


Expand Down
16 changes: 16 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,23 @@ async function computePrices(data) {
}
}

let asks = [];
let bids = [];
for (let market in data[coin]) {
asks.push([data[coin][market].ask, market]);
bids.push([data[coin][market].bid, market]);
}
asks.sort(function (a, b) {
return a[0] - b[0];
});
bids.sort(function(a,b){
return b[0] - a[0];
});
for (let i = 0; i < asks.length; i++) {
for (let j = i; j < asks.length; j++) {
results.push([coin,bids[i][0]/asks[j][0],bids[i][0],asks[j][0],bids[i][1],asks[j][1] ]);
}

}
results.sort(function (a, b) {
return a.spread - b.spread;
Expand Down
43 changes: 30 additions & 13 deletions settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ let markets = [
if(obj["MarketName"].includes('BTC-')) {
let coinName = obj["MarketName"].replace("BTC-", '');
if (!coin_prices[coinName]) coin_prices[coinName] = {};
coin_prices[coinName].bittrex = obj.Last;
coin_prices[coinName]['bittrex'] = {
bid: obj.Bid,
ask: obj.Ask
};
}
}
res(coin_prices);
Expand Down Expand Up @@ -102,8 +105,10 @@ let markets = [
let coinName = key.toUpperCase();
let price = data[key]['ticker'].last;
if (!coin_prices[coinName]) coin_prices[coinName] = {};

coin_prices[coinName]["btc38"] = data[key]['ticker'].last / priceOfBTC;
coin_prices[coinName]['btc38'] = {
bid: data[key]['ticker'].buy / priceOfBTC,
ask: data[key]['ticker'].sell / priceOfBTC
};
}
res(coin_prices);
}
Expand All @@ -130,8 +135,10 @@ let markets = [
let coinName = key.toUpperCase();
let price = data[key].last;
if (!coin_prices[coinName]) coin_prices[coinName] = {};

coin_prices[coinName]["jubi"] = data[key].last / priceOfBTC;
coin_prices[coinName]['jubi'] = {
bid: data[key].buy / priceOfBTC,
ask: data[key].sell / priceOfBTC
};
}
res(coin_prices);
}
Expand All @@ -158,7 +165,10 @@ let markets = [
if(obj.includes('BTC_')&&obj!=="BTC_EMC2") {
let coinName = obj.replace("BTC_", '');
if (!coin_prices[coinName]) coin_prices[coinName] = {};
coin_prices[coinName].poloniex = data[obj].last;
coin_prices[coinName]['poloniex'] = {
bid: data[obj].highestBid,
ask: data[obj].lowestAsk
};
}
}
res(coin_prices);
Expand All @@ -184,8 +194,11 @@ let markets = [
for (let obj of data.Data) {
if(obj["Label"].includes('/BTC')) {
let coinName = obj["Label"].replace("/BTC", '');
if (!coin_prices[coinName]) coin_prices[coinName] = {};
coin_prices[coinName].cryptopia = obj.LastPrice;
if (!coin_prices[coinName]) coin_prices[coinName] = {};
coin_prices[coinName]['cryptopia'] = {
bid: obj.BidPrice,
ask: obj.AskPrice
};
}
}
res(coin_prices);
Expand All @@ -211,8 +224,11 @@ let markets = [
for (let obj of data.result) {
if(obj["MarketName"].includes('_BTC')) {
let coinName = obj["MarketName"].replace("_BTC", '');
if (!coin_prices[coinName]) coin_prices[coinName] = {};
coin_prices[coinName].bleutrade = obj.Last;
if (!coin_prices[coinName]) coin_prices[coinName] = {};
coin_prices[coinName]['bleutrade'] = {
bid: obj.Bid,
ask: obj.Ask
};
}
}
res(coin_prices);
Expand Down Expand Up @@ -248,9 +264,10 @@ let markets = [
}

if (!coin_prices[coinName]) coin_prices[coinName] = {};

coin_prices[coinName].kraken = data.result[name].c[0];

coin_prices[coinName]['kraken'] = {
bid: data.result[name].b[0],
ask: data.result[name].a[0]
};
}
res(coin_prices);

Expand Down