Permalink
Browse files

trying to sync changes

  • Loading branch information...
cronopio
cronopio committed Sep 16, 2011
2 parents 5490b2e + 83c5b49 commit e249fcee39ab20de1f79caaf6c2c8306d6862ce0
Showing with 8 additions and 73 deletions.
  1. +0 −71 bin/ws
  2. +8 −2 package.json
View
71 bin/ws
@@ -8,75 +8,4 @@ var mtgoxTest = new WebSocketHook({
debug:false
});
-var mtgoxChannels = {
- channels: mtgoxTest.channels,
- lastTrade: 0,
- getChannel: function(key){
- var selected = this.channels.filter(function(c){
- if (c.key == key)
- return true;
- return false;
- });
- return selected[0];
- },
- showMsg: function(data){
- var ch = this.getChannel(data.channel);
- this['_'+ch.private](data);
- },
- _depth: function(depth){
- var vol,
- now = new Date(),
- data = depth.depth,
- msg = '<'+now.getHours()+':'+now.getMinutes()+':'+now.getSeconds()+'> ';
- if (data.volume < 0){
- // An order has been deleted
- msg += 'Remove ';
- vol = data.volume * -1;
- } else {
- // An order has been created
- msg += 'Create ';
- vol = data.volume;
- }
- msg += data.type_str + ' ' +vol + ' @ ' + data.price;
- console.log(msg);
- },
- _trade: function(trade){
- var data = trade.trade,
- time = new Date(data.date),
- msg = '['+time.getHours()+':'+time.getMinutes()+':'+time.getSeconds()+'] ';
- if (data.trade_type == 'ask'){
- msg += 'Sell ';
- } else if (data.trade_type == 'bid'){
- msg += 'Buy ';
- }
- msg += data.amount + ' '+data.item+ ' @ '+data.price+' '+data.price_currency;
- if (data.price > this.lastTrade){
- msg += '';
- }
- if (data.price < this.lastTrade){
- msg += '';
- }
- this.lastTrade = data.price;
- console.log(msg);
- },
- _ticker: function(tick){
- var data = tick.ticker;
- console.log('---------------------');
- console.log(' Volume: %d ', data.vol);
- console.log(' Buy:%d - Sell:%d ', data.buy, data.sell);
- console.log(' Max:%d - Min:%d ', data.high, data.low);
- console.log(' Last Price: %d ', this.lastTrade);
- console.log('---------------------')
- }
-};
-
-
-mtgoxTest.on('websocket::message',function(data){
- if (data.op == 'subscribe'){
- console.log('Now suscribe to: %s',mtgoxChannels.getChannel(data.channel).name);
- } else {
- mtgoxChannels.showMsg(data);
- }
-});
-
mtgoxTest.start();
View
@@ -1,8 +1,14 @@
{
"author": "Daniel Aristizabal <aristizabal.daniel@gmail.com>",
+ "contributors": [
+ {
+ "name": "Marak Squires",
+ "email": "marak.squires@gmail.com"
+ }
+ ],
"name": "hook.io-ws",
- "description": "hook for websocket connection",
- "version": "0.0.1",
+ "description": "hook.io hook for websocket connection",
+ "version": "0.1.0",
"repository": {
"type": "git",
"url": "git://github.com/cronopio/hook.io-ws.git"

0 comments on commit e249fce

Please sign in to comment.