-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from Someguy123/develop
Develop
- Loading branch information
Showing
12 changed files
with
209 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
var request = require('request'), | ||
BaseAdapter = require('./base'); | ||
|
||
var BitfinexAdapter = { | ||
name: 'Bitfinex', | ||
code: 'bitfinex', | ||
provides: [ | ||
['usdt','usd'], | ||
['btc','usd'] | ||
], | ||
|
||
has_pair: (from, to) => BaseAdapter.has_pair_ext(from, to, BitfinexAdapter.provides), | ||
|
||
get_pair: function(from,to,callback) { | ||
if (!BitfinexAdapter.has_pair(from, to)) { | ||
return callback(`Pair ${from}/${to} is not supported by this adapter.`, null); | ||
} | ||
|
||
if (from === 'usdt') | ||
from = 'ust' | ||
|
||
var pair = [from,to].join('').toUpperCase(), | ||
ticker_url = `https://api-pub.bitfinex.com/v2/ticker/t${pair}`; | ||
request(ticker_url, function(error,response,body) { | ||
if(error || response.statusCode !== 200) { | ||
return callback(true,null); | ||
} | ||
try { | ||
let ticker_data = JSON.parse(body); | ||
if(!ticker_data || !ticker_data[6]) { | ||
return callback(true,null); | ||
} | ||
return callback(false, ticker_data[6]) | ||
} catch { | ||
return callback(true, null) | ||
} | ||
}); | ||
}, | ||
} | ||
|
||
module.exports = BitfinexAdapter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
var request = require('request'), | ||
BaseAdapter = require('./base'); | ||
|
||
var CoinbaseAdapter = { | ||
name: 'Coinbase', | ||
code: 'coinbase', | ||
provides: [ | ||
['usdt','usd'], | ||
['btc','usd'] | ||
], | ||
|
||
has_pair: (from, to) => BaseAdapter.has_pair_ext(from, to, CoinbaseAdapter.provides), | ||
|
||
get_pair: function(from,to,callback) { | ||
if (!CoinbaseAdapter.has_pair(from, to)) { | ||
return callback(`Pair ${from}/${to} is not supported by this adapter.`, null); | ||
} | ||
|
||
var pair = [from,to].join('-').toUpperCase(), | ||
ticker_url = `https://api.exchange.coinbase.com/products/${pair}/ticker`; | ||
request(ticker_url, function(error,response,body) { | ||
if(error || response.statusCode !== 200) { | ||
return callback(true,null); | ||
} | ||
try { | ||
let ticker_data = JSON.parse(body); | ||
if(!ticker_data || !ticker_data.price) { | ||
return callback(true,null); | ||
} | ||
return callback(false, ticker_data.price) | ||
} catch { | ||
return callback(true, null) | ||
} | ||
}); | ||
}, | ||
} | ||
|
||
module.exports = CoinbaseAdapter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
var request = require('request'), | ||
BaseAdapter = require('./base'); | ||
|
||
var GateIOAdapter = { | ||
name: 'GateIO', | ||
code: 'gateio', | ||
provides: [ | ||
['hive','usdt'] | ||
], | ||
|
||
has_pair: (from, to) => BaseAdapter.has_pair_ext(from, to, GateIOAdapter.provides), | ||
|
||
get_pair: function(from,to,callback) { | ||
if (!GateIOAdapter.has_pair(from, to)) { | ||
return callback(`Pair ${from}/${to} is not supported by this adapter.`, null); | ||
} | ||
|
||
var pair = [from,to].join('_'), | ||
ticker_url = `https://api.gateio.ws/api/v4/spot/tickers?currency_pair=${pair}`; | ||
request(ticker_url, function(error,response,body) { | ||
if(error || response.statusCode !== 200) { | ||
return callback(true,null); | ||
} | ||
try { | ||
let ticker_data = JSON.parse(body); | ||
if(!ticker_data || ticker_data.length === 0 || !ticker_data[0].last) { | ||
return callback(true,null); | ||
} | ||
return callback(false, ticker_data[0].last) | ||
} catch { | ||
return callback(true, null) | ||
} | ||
}); | ||
}, | ||
} | ||
|
||
module.exports = GateIOAdapter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
var request = require('request'), | ||
BaseAdapter = require('./base'); | ||
|
||
var MEXCAdapter = { | ||
name: 'MEXC', | ||
code: 'mexc', | ||
provides: [ | ||
['hive','usdt'], | ||
['hive','btc'] | ||
], | ||
|
||
has_pair: (from, to) => BaseAdapter.has_pair_ext(from, to, MEXCAdapter.provides), | ||
|
||
get_pair: function(from,to,callback) { | ||
if (!MEXCAdapter.has_pair(from, to)) { | ||
return callback(`Pair ${from}/${to} is not supported by this adapter.`, null); | ||
} | ||
|
||
var pair = [from,to].join('').toUpperCase(), | ||
ticker_url = `https://api.mexc.com/api/v3/ticker/price?symbol=${pair}`; | ||
request(ticker_url, function(error,response,body) { | ||
if(error || response.statusCode !== 200) { | ||
return callback(true,null); | ||
} | ||
try { | ||
let ticker_data = JSON.parse(body); | ||
if(!ticker_data.price) { | ||
return callback(true,null); | ||
} | ||
return callback(false, ticker_data.price) | ||
} catch { | ||
return callback(true, null) | ||
} | ||
}); | ||
}, | ||
} | ||
|
||
module.exports = MEXCAdapter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
var request = require('request'), | ||
BaseAdapter = require('./base'); | ||
|
||
var ProbitAdapter = { | ||
name: 'Probit', | ||
code: 'probit', | ||
provides: [ | ||
['hive','usdt'], | ||
['hive','btc'] | ||
], | ||
|
||
has_pair: (from, to) => BaseAdapter.has_pair_ext(from, to, ProbitAdapter.provides), | ||
|
||
get_pair: function(from,to,callback) { | ||
if (!ProbitAdapter.has_pair(from, to)) { | ||
return callback(`Pair ${from}/${to} is not supported by this adapter.`, null); | ||
} | ||
|
||
var pair = [from,to].join('-').toUpperCase(), | ||
ticker_url = `https://api.probit.com/api/exchange/v1/ticker?market_ids=${pair}`; | ||
request(ticker_url, function(error,response,body) { | ||
if(error || response.statusCode !== 200) { | ||
return callback(true,null); | ||
} | ||
try { | ||
let ticker_data = JSON.parse(body); | ||
if(!ticker_data.data || ticker_data.data.length === 0 || !ticker_data.data[0].last) { | ||
return callback(true,null); | ||
} | ||
return callback(false, ticker_data.data[0].last) | ||
} catch { | ||
return callback(true, null) | ||
} | ||
}); | ||
}, | ||
} | ||
|
||
module.exports = ProbitAdapter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters