trades 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/trades +4 -0
  2. data/lib/trades.rb +32 -0
  3. metadata +67 -0
data/bin/trades ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'trades'
4
+ Trades.new ARGV
data/lib/trades.rb ADDED
@@ -0,0 +1,32 @@
1
+ require 'socket'
2
+ require 'rubygems'
3
+ require 'json'
4
+
5
+ class Trades
6
+ def initialize(args = [])
7
+ @socket = TCPSocket.open("bitcoincharts.com", 27007)
8
+
9
+ # thUSD | 2011-06-27 23:00:55 | USD | 17.05 | 0.5 |
10
+ puts "Exchange | Date and time | Currency | Price | Volume |"
11
+
12
+ while data = @socket.gets do
13
+ if data.length > 0
14
+ begin
15
+ j = JSON.parse(data.strip)
16
+ rescue
17
+ end
18
+
19
+ if args.length == 0 or args.include?(j['symbol'].downcase) then
20
+ line = j['symbol'].ljust(15) + "| "
21
+ line += Time.at(j['timestamp']).strftime("%Y-%m-%d %H:%M:%S").\
22
+ ljust(20)
23
+ line += "| " + j['currency'].ljust(9) + "| "
24
+ line += j['price'].round(2).to_s.ljust(7) + "| "
25
+ line += j['volume'].round(2).to_s.ljust(7) + "|"
26
+
27
+ puts line
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trades
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: "0.1"
6
+ platform: ruby
7
+ authors:
8
+ - Waxjar
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-06-28 00:00:00 +02:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: json
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ~>
23
+ - !ruby/object:Gem::Version
24
+ version: 1.5.3
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ description: Displays the trades that Bitcoincharts monitors nicely
28
+ email:
29
+ executables:
30
+ - trades
31
+ extensions: []
32
+
33
+ extra_rdoc_files: []
34
+
35
+ files:
36
+ - lib/trades.rb
37
+ - bin/trades
38
+ has_rdoc: true
39
+ homepage:
40
+ licenses: []
41
+
42
+ post_install_message:
43
+ rdoc_options: []
44
+
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "0"
59
+ requirements: []
60
+
61
+ rubyforge_project:
62
+ rubygems_version: 1.6.2
63
+ signing_key:
64
+ specification_version: 3
65
+ summary: Nice trading data
66
+ test_files: []
67
+