Skip to content

Commit

Permalink
cryptsy refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Williams committed Jul 6, 2015
1 parent 8ed8c3c commit cdbfe5e
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 481 deletions.
14 changes: 1 addition & 13 deletions lib/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ var mongoose = require('mongoose')
, poloniex = require('./markets/poloniex')
, bittrex = require('./markets/bittrex')
, cryptsy = require('./markets/cryptsy')
, cryptsy2 = require('./markets/cryptsy2')
, cryptsy3 = require('./markets/cryptsy3')
, yobit = require('./markets/yobit')
, empoex = require('./markets/empoex');

Expand Down Expand Up @@ -198,17 +196,7 @@ function get_market_data(market, cb) {
});
break;
case 'cryptsy':
cryptsy.get_data(settings.markets.coin, settings.markets.exchange, settings.markets.Crymktid, function(err, obj){
return cb(err, obj);
});
break;
case 'cryptsy2':
cryptsy2.get_data(settings.markets.coin, settings.markets.Cryexchange2, settings.markets.Crymktid2, function(err, obj){
return cb(err, obj);
});
break;
case 'cryptsy3':
cryptsy3.get_data(settings.markets.coin, settings.markets.Cryexchange3, settings.markets.Crymktid3, function(err, obj){
cryptsy.get_data(settings.markets.coin, settings.markets.exchange, settings.markets.cryptsy_id, function(err, obj){
return cb(err, obj);
});
break;
Expand Down
2 changes: 0 additions & 2 deletions lib/locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ exports.poloniex = "Poloniex",
exports.bittrex = "Bittrex",
exports.yobit = "Yobit",
exports.cryptsy = "Cryptsy",
exports.cryptsy2 = "Cryptsy2",
exports.cryptsy3 = "Cryptsy3",
exports.empoex = "Empoex",

exports.reloadLocale = function reloadLocale(locale) {
Expand Down
50 changes: 21 additions & 29 deletions lib/markets/cryptsy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,31 @@ var request = require('request');

var base_url = 'https://api.cryptsy.com/api/v2/markets';
function get_summary(coin, exchange, Crymktid, cb) {
var summary = [];
var req_url1 = base_url + '/' + Crymktid + '/ticker';
request({uri: req_url1, json: true}, function (error, response, body) {
var summary = {};
request({uri: base_url + '/' + Crymktid + '/ticker', json: true}, function (error, response, body) {
if (error) {
return cb(error, null);
} else if (body.success === true) {
summary['bid'] = body.data['bid'].toFixed(8);
summary['ask'] = body.data['ask'].toFixed(8);
request({uri: base_url + '/' + Crymktid, json: true}, function (error, response, body) {
if (error) {
return cb(error, null);
} else if (body.success === true) {
summary['volume'] = body.data['24hr']['volume'];
summary['volume_btc'] = body.data['24hr']['volume_btc'];
summary['high'] = body.data['24hr']['price_high'];
summary['low'] = body.data['24hr']['price_low'];
summary['last'] = body.data['last_trade']['price'];
return cb(null, summary);
} else {
return cb(error, null);
}
});
} else {
if (body.message) {
return cb(body.message, null)
} else {
}};
summary = body;
summary.data['Bid'] = body.data['bid'].toFixed(8);
summary.data['Ask'] = body.data['ask'].toFixed(8);
var req_url = base_url + '/' + Crymktid;
request({uri: req_url, json: true}, function (error, response, body) {
if (error) {
return cb(error, null);
} else {
if (body.message) {
return cb(body.message, null)
} else {
summary.data['volume'] = body.data['24hr']['volume'];
summary.data['price_high'] = body.data['24hr']['price_high'].toFixed(8);
summary.data['price_low'] = body.data['24hr']['price_low'];
summary.data['Last'] = body.data['last_trade']['price'];
summary.data['last'] = body.data['last_trade']['price'];
summary.data['lastprice'] = body.data['last_trade']['price'];
}};
return cb (null, summary.data);
}
);
}
);
}
});
}
function get_trades(coin, exchange, Crymktid, cb) {
var req_url = base_url + '/' + Crymktid + '/tradehistory?limit=100';
Expand Down
102 changes: 0 additions & 102 deletions lib/markets/cryptsy2.js

This file was deleted.

102 changes: 0 additions & 102 deletions lib/markets/cryptsy3.js

This file was deleted.

2 changes: 0 additions & 2 deletions locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@
"yobit": "Yobit",
"empoex": "Empoex",
"cryptsy": "Cryptsy",
"cryptsy2": "Cryptsy",
"cryptsy3": "Cryptsy",

// Heavy rewards view
"heavy_title": "Reward/voting information",
Expand Down
21 changes: 9 additions & 12 deletions settings.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,14 @@
},

// market settings
//supported markets: bittrex, poloniex, yobit, empoex, cryptsy * 3
//supported markets: bittrex, poloniex, yobit, empoex, cryptsy
//default market is loaded by default and determines last price in header
"markets": {
"coin": "42",
"coin": "JBS",
"exchange": "BTC",
"enabled": ["bittrex", "empoex", "cryptsy"],
"default": "bittrex",
"Crymktid": "141",
"Cryexchange2": "XRP",
"Crymktid2": "345",
"Cryexchange3": "LTC",
"Crymktid3": "345"
"enabled": ["bittrex", "cryptsy"],
"cryptsy_id": "290",
"default": "bittrex"
},

// richlist/top100 settings
Expand Down Expand Up @@ -131,9 +127,10 @@
// getnetworkhashps: uses getnetworkhashps api call, returns in GH/s
// netmhashps: uses getmininginfo.netmhashpsm returns in MH/s
"nethash": "getnetworkhashps",
// nethashSP: sets nethash API return speed, in PH/s P, TH/s T, GH/s G, MH/s M or KH/s K
"nethashSP": "G",


// nethash unitd: sets nethash API return units
// valid options: "P" (PH/s), "T" (TH/s), "G" (GH/s), "M" (MH/s), "K" (KH/s)
"nethash_units": "G",

// Address labels
// example : "JhbrvAmM7kNpwA6wD5KoAsbtikLWWMNPcM": {"label": "This is a burn address", "type":"danger", "url":"http://example.com"}
Expand Down
14 changes: 7 additions & 7 deletions views/markets/cryptsy.jade
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ block market_view
th.hidden-xs #{settings.locale.mkt_last}
tbody
tr
td #{marketdata.data.summary.price_high}
td #{marketdata.data.summary.price_low}
td #{marketdata.data.summary.high}
td #{marketdata.data.summary.low}
td #{marketdata.data.summary.volume}
td.hidden-xs #{marketdata.data.summary.Bid}
td.hidden-xs #{marketdata.data.summary.Ask}
td.hidden-xs #{marketdata.data.summary.Last}
td.hidden-xs #{marketdata.data.summary.bid}
td.hidden-xs #{marketdata.data.summary.ask}
td.hidden-xs #{marketdata.data.summary.last}
.row
.col-md-6.col-xs-12
.panel.panel-default
Expand All @@ -42,7 +42,7 @@ block market_view
td
=buy.price
td
=buy.amount
=buy.amount.toFixed(8)
td.hidden-xs
=buy.total
.col-md-6.col-xs-12
Expand All @@ -61,7 +61,7 @@ block market_view
td
=sell.price
td
=sell.amount
=sell.amount.toFixed(8)
td.hidden-xs
=sell.total
.row
Expand Down
Loading

0 comments on commit cdbfe5e

Please sign in to comment.