bitstamp 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bitstamp.gemspec +5 -3
- data/lib/bitstamp.rb +11 -0
- data/lib/bitstamp/helper.rb +3 -0
- data/lib/bitstamp/model.rb +2 -0
- data/lib/bitstamp/transactions.rb +27 -0
- data/spec/bitstamp_spec.rb +12 -0
- data/spec/transactions_spec.rb +11 -0
- metadata +5 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.7
|
data/bitstamp.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "bitstamp"
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jeffrey Wilcke"]
|
12
|
-
s.date = "2013-06-
|
12
|
+
s.date = "2013-06-25"
|
13
13
|
s.description = "Ruby API for use with bitstamp."
|
14
14
|
s.email = "stygeo@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -32,10 +32,12 @@ Gem::Specification.new do |s|
|
|
32
32
|
"lib/bitstamp/net.rb",
|
33
33
|
"lib/bitstamp/orders.rb",
|
34
34
|
"lib/bitstamp/ticker.rb",
|
35
|
+
"lib/bitstamp/transactions.rb",
|
35
36
|
"spec/bitstamp_spec.rb",
|
36
37
|
"spec/collection_spec.rb",
|
37
38
|
"spec/orders_spec.rb",
|
38
|
-
"spec/spec_helper.rb"
|
39
|
+
"spec/spec_helper.rb",
|
40
|
+
"spec/transactions_spec.rb"
|
39
41
|
]
|
40
42
|
s.homepage = "http://github.com/kojnapp/bitstamp"
|
41
43
|
s.licenses = ["MIT"]
|
data/lib/bitstamp.rb
CHANGED
@@ -9,6 +9,7 @@ require 'bitstamp/collection'
|
|
9
9
|
require 'bitstamp/model'
|
10
10
|
|
11
11
|
require 'bitstamp/orders'
|
12
|
+
require 'bitstamp/transactions'
|
12
13
|
require 'bitstamp/ticker'
|
13
14
|
|
14
15
|
String.send(:include, ActiveSupport::Inflector)
|
@@ -30,6 +31,12 @@ module Bitstamp
|
|
30
31
|
@@orders ||= Bitstamp::Orders.new
|
31
32
|
end
|
32
33
|
|
34
|
+
def self.user_transactions
|
35
|
+
self.sanity_check!
|
36
|
+
|
37
|
+
@@transactions ||= Bitstamp::UserTransactions.new
|
38
|
+
end
|
39
|
+
|
33
40
|
def self.balance
|
34
41
|
self.sanity_check!
|
35
42
|
|
@@ -40,6 +47,10 @@ module Bitstamp
|
|
40
47
|
return Bitstamp::Ticker.from_api
|
41
48
|
end
|
42
49
|
|
50
|
+
def self.order_book
|
51
|
+
return JSON.parse Bitstamp::Net.post('/order_book/').body_str
|
52
|
+
end
|
53
|
+
|
43
54
|
def self.setup
|
44
55
|
yield self
|
45
56
|
end
|
data/lib/bitstamp/helper.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
module Bitstamp
|
2
2
|
module Helper
|
3
3
|
def self.parse_objects!(string, klass)
|
4
|
+
# If Bitstamp returned nothing (which it does if the results yield empty) 'cast' it to an array
|
5
|
+
string = "[]" if string == ""
|
6
|
+
|
4
7
|
objects = JSON.parse(string)
|
5
8
|
objects.collect do |t_json|
|
6
9
|
parse_object!(t_json, klass)
|
data/lib/bitstamp/model.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
module Bitstamp
|
2
|
+
class UserTransactions < Bitstamp::Collection
|
3
|
+
def all(options = {})
|
4
|
+
# Default time delta to an hour
|
5
|
+
options[:timedelta] = "3600" unless options[:timedelta]
|
6
|
+
|
7
|
+
Bitstamp::Helper.parse_objects! Bitstamp::Net::post("/user_transactions", options).body_str, self.model
|
8
|
+
end
|
9
|
+
|
10
|
+
def find(order_id)
|
11
|
+
all = self.all
|
12
|
+
index = all.index {|order| order.id.to_i == order_id}
|
13
|
+
|
14
|
+
return all[index] if index
|
15
|
+
end
|
16
|
+
|
17
|
+
def create(options = {})
|
18
|
+
end
|
19
|
+
|
20
|
+
def update(options={})
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class UserTransaction < Bitstamp::Model
|
25
|
+
attr_accessor :datetime, :id, :type, :usd, :btc, :fee, :order_id
|
26
|
+
end
|
27
|
+
end
|
data/spec/bitstamp_spec.rb
CHANGED
@@ -28,4 +28,16 @@ describe Bitstamp do
|
|
28
28
|
|
29
29
|
Bitstamp.balance.should be_kind_of Hash
|
30
30
|
end
|
31
|
+
|
32
|
+
it 'should have a order_book method' do
|
33
|
+
Bitstamp.order_book.should be_kind_of Hash
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should have bids and asks in the order_book' do
|
37
|
+
order_book = Bitstamp.order_book
|
38
|
+
order_book.should have_key("asks")
|
39
|
+
order_book.should have_key("bids")
|
40
|
+
order_book["asks"].should be_kind_of Array
|
41
|
+
order_book["bids"].should be_kind_of Array
|
42
|
+
end
|
31
43
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitstamp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -146,10 +146,12 @@ files:
|
|
146
146
|
- lib/bitstamp/net.rb
|
147
147
|
- lib/bitstamp/orders.rb
|
148
148
|
- lib/bitstamp/ticker.rb
|
149
|
+
- lib/bitstamp/transactions.rb
|
149
150
|
- spec/bitstamp_spec.rb
|
150
151
|
- spec/collection_spec.rb
|
151
152
|
- spec/orders_spec.rb
|
152
153
|
- spec/spec_helper.rb
|
154
|
+
- spec/transactions_spec.rb
|
153
155
|
homepage: http://github.com/kojnapp/bitstamp
|
154
156
|
licenses:
|
155
157
|
- MIT
|
@@ -165,7 +167,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
165
167
|
version: '0'
|
166
168
|
segments:
|
167
169
|
- 0
|
168
|
-
hash:
|
170
|
+
hash: -1399410324904363812
|
169
171
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
170
172
|
none: false
|
171
173
|
requirements:
|