bitex-bitstamp 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +27 -0
- data/Gemfile.lock +126 -0
- data/LICENSE.txt +20 -0
- data/README.md +96 -0
- data/Rakefile +55 -0
- data/VERSION +1 -0
- data/bitstamp.gemspec +93 -0
- data/lib/bitstamp.rb +107 -0
- data/lib/bitstamp/collection.rb +30 -0
- data/lib/bitstamp/helper.rb +19 -0
- data/lib/bitstamp/model.rb +29 -0
- data/lib/bitstamp/net.rb +43 -0
- data/lib/bitstamp/orders.rb +71 -0
- data/lib/bitstamp/ticker.rb +16 -0
- data/lib/bitstamp/transactions.rb +43 -0
- data/spec/bitstamp_spec.rb +87 -0
- data/spec/collection_spec.rb +12 -0
- data/spec/fixtures/vcr_cassettes/bitstamp/balance.yml +63 -0
- data/spec/fixtures/vcr_cassettes/bitstamp/order_book.yml +1910 -0
- data/spec/fixtures/vcr_cassettes/bitstamp/orders/all.yml +62 -0
- data/spec/fixtures/vcr_cassettes/bitstamp/orders/buy.yml +62 -0
- data/spec/fixtures/vcr_cassettes/bitstamp/orders/sell/failure.yml +60 -0
- data/spec/fixtures/vcr_cassettes/bitstamp/ticker.yml +63 -0
- data/spec/fixtures/vcr_cassettes/bitstamp/transactions.yml +244 -0
- data/spec/fixtures/vcr_cassettes/bitstamp/unconfirmed_user_deposits.yml +72 -0
- data/spec/fixtures/vcr_cassettes/bitstamp/user_transactions/all.yml +223 -0
- data/spec/fixtures/vcr_cassettes/bitstamp/withdraw_bitcoins/failure.yml +145 -0
- data/spec/orders_spec.rb +40 -0
- data/spec/spec_helper.rb +31 -0
- data/spec/support/bitstamp_setup.rb +19 -0
- data/spec/support/vcr.rb +15 -0
- data/spec/transactions_spec.rb +32 -0
- metadata +178 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b3b7f98b7db443efd689c11bbe012acf19de375b
|
4
|
+
data.tar.gz: 8084d193a296bc6ff590f8175e1c7a143a8d5633
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d79a12fa828e28f5394df383ee339f83bb7fb8fc88bd92be7535806a9c1dc01da74eaed8e018787af3625c0d755d250de7680ca6be15c00d6ee3b52024c30405
|
7
|
+
data.tar.gz: f79ccfe7293c338e7b0c59ec3f3cb0f8cae7afc9ee84b1dd061bd4a194f4b3cc693a2d9b6c58a6b1bd75cd59af1027a13522e9ecb9c9fa9e506a4e335e3d1741
|
data/.rspec
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
bitstamp
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.4.1
|
data/Gemfile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
ruby '2.4.1'
|
2
|
+
|
3
|
+
source 'http://rubygems.org'
|
4
|
+
|
5
|
+
|
6
|
+
# Add dependencies required to use your gem here.
|
7
|
+
gem 'activemodel', '~> 5.1'
|
8
|
+
gem 'activesupport', '~> 5.1'
|
9
|
+
gem 'rest-client', '2.0.2'
|
10
|
+
gem 'ruby-hmac'
|
11
|
+
|
12
|
+
|
13
|
+
# Add dependencies to develop your gem here.
|
14
|
+
# Include everything needed to run rake, tests, features, etc.
|
15
|
+
group :development do
|
16
|
+
gem 'rdoc'
|
17
|
+
gem 'bundler'
|
18
|
+
gem 'jeweler'
|
19
|
+
end
|
20
|
+
|
21
|
+
group :test do
|
22
|
+
gem 'byebug'
|
23
|
+
gem 'rspec'
|
24
|
+
gem 'rspec-its'
|
25
|
+
gem 'vcr', '2.6.0'
|
26
|
+
gem 'webmock', '3.4.2'
|
27
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activemodel (5.2.1)
|
5
|
+
activesupport (= 5.2.1)
|
6
|
+
activesupport (5.2.1)
|
7
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
8
|
+
i18n (>= 0.7, < 2)
|
9
|
+
minitest (~> 5.1)
|
10
|
+
tzinfo (~> 1.1)
|
11
|
+
addressable (2.4.0)
|
12
|
+
builder (3.2.3)
|
13
|
+
byebug (10.0.2)
|
14
|
+
concurrent-ruby (1.0.5)
|
15
|
+
crack (0.4.3)
|
16
|
+
safe_yaml (~> 1.0.0)
|
17
|
+
descendants_tracker (0.0.4)
|
18
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
19
|
+
diff-lcs (1.3)
|
20
|
+
domain_name (0.5.20180417)
|
21
|
+
unf (>= 0.0.5, < 1.0.0)
|
22
|
+
faraday (0.9.2)
|
23
|
+
multipart-post (>= 1.2, < 3)
|
24
|
+
git (1.5.0)
|
25
|
+
github_api (0.16.0)
|
26
|
+
addressable (~> 2.4.0)
|
27
|
+
descendants_tracker (~> 0.0.4)
|
28
|
+
faraday (~> 0.8, < 0.10)
|
29
|
+
hashie (>= 3.4)
|
30
|
+
mime-types (>= 1.16, < 3.0)
|
31
|
+
oauth2 (~> 1.0)
|
32
|
+
hashdiff (0.3.7)
|
33
|
+
hashie (3.6.0)
|
34
|
+
highline (2.0.0)
|
35
|
+
http-cookie (1.0.3)
|
36
|
+
domain_name (~> 0.5)
|
37
|
+
i18n (1.1.0)
|
38
|
+
concurrent-ruby (~> 1.0)
|
39
|
+
jeweler (2.3.9)
|
40
|
+
builder
|
41
|
+
bundler
|
42
|
+
git (>= 1.2.5)
|
43
|
+
github_api (~> 0.16.0)
|
44
|
+
highline (>= 1.6.15)
|
45
|
+
nokogiri (>= 1.5.10)
|
46
|
+
psych
|
47
|
+
rake
|
48
|
+
rdoc
|
49
|
+
semver2
|
50
|
+
jwt (1.5.6)
|
51
|
+
mime-types (2.99.3)
|
52
|
+
mini_portile2 (2.3.0)
|
53
|
+
minitest (5.11.3)
|
54
|
+
multi_json (1.13.1)
|
55
|
+
multi_xml (0.6.0)
|
56
|
+
multipart-post (2.0.0)
|
57
|
+
netrc (0.11.0)
|
58
|
+
nokogiri (1.8.4)
|
59
|
+
mini_portile2 (~> 2.3.0)
|
60
|
+
oauth2 (1.4.0)
|
61
|
+
faraday (>= 0.8, < 0.13)
|
62
|
+
jwt (~> 1.0)
|
63
|
+
multi_json (~> 1.3)
|
64
|
+
multi_xml (~> 0.5)
|
65
|
+
rack (>= 1.2, < 3)
|
66
|
+
psych (3.0.2)
|
67
|
+
rack (2.0.5)
|
68
|
+
rake (12.3.1)
|
69
|
+
rdoc (6.0.4)
|
70
|
+
rest-client (2.0.2)
|
71
|
+
http-cookie (>= 1.0.2, < 2.0)
|
72
|
+
mime-types (>= 1.16, < 4.0)
|
73
|
+
netrc (~> 0.8)
|
74
|
+
rspec (3.8.0)
|
75
|
+
rspec-core (~> 3.8.0)
|
76
|
+
rspec-expectations (~> 3.8.0)
|
77
|
+
rspec-mocks (~> 3.8.0)
|
78
|
+
rspec-core (3.8.0)
|
79
|
+
rspec-support (~> 3.8.0)
|
80
|
+
rspec-expectations (3.8.1)
|
81
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
82
|
+
rspec-support (~> 3.8.0)
|
83
|
+
rspec-its (1.2.0)
|
84
|
+
rspec-core (>= 3.0.0)
|
85
|
+
rspec-expectations (>= 3.0.0)
|
86
|
+
rspec-mocks (3.8.0)
|
87
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
88
|
+
rspec-support (~> 3.8.0)
|
89
|
+
rspec-support (3.8.0)
|
90
|
+
ruby-hmac (0.4.0)
|
91
|
+
safe_yaml (1.0.4)
|
92
|
+
semver2 (3.4.2)
|
93
|
+
thread_safe (0.3.6)
|
94
|
+
tzinfo (1.2.5)
|
95
|
+
thread_safe (~> 0.1)
|
96
|
+
unf (0.1.4)
|
97
|
+
unf_ext
|
98
|
+
unf_ext (0.0.7.5)
|
99
|
+
vcr (2.6.0)
|
100
|
+
webmock (3.4.2)
|
101
|
+
addressable (>= 2.3.6)
|
102
|
+
crack (>= 0.3.2)
|
103
|
+
hashdiff
|
104
|
+
|
105
|
+
PLATFORMS
|
106
|
+
ruby
|
107
|
+
|
108
|
+
DEPENDENCIES
|
109
|
+
activemodel (~> 5.1)
|
110
|
+
activesupport (~> 5.1)
|
111
|
+
bundler
|
112
|
+
byebug
|
113
|
+
jeweler
|
114
|
+
rdoc
|
115
|
+
rest-client (= 2.0.2)
|
116
|
+
rspec
|
117
|
+
rspec-its
|
118
|
+
ruby-hmac
|
119
|
+
vcr (= 2.6.0)
|
120
|
+
webmock (= 3.4.2)
|
121
|
+
|
122
|
+
RUBY VERSION
|
123
|
+
ruby 2.4.1p111
|
124
|
+
|
125
|
+
BUNDLED WITH
|
126
|
+
1.16.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Kojn
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
# Bitstamp Ruby API
|
2
|
+
|
3
|
+
Feel free to fork, modify & redistribute under the MIT license.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'bitstamp'
|
10
|
+
|
11
|
+
## Create API Key
|
12
|
+
|
13
|
+
More info at: [https://www.bitstamp.net/article/api-key-implementation/](https://www.bitstamp.net/article/api-key-implementation/)
|
14
|
+
|
15
|
+
## Setup
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
Bitstamp.setup do |config|
|
19
|
+
config.key = YOUR_API_KEY
|
20
|
+
config.secret = YOUR_API_SECRET
|
21
|
+
config.client_id = YOUR_BITSTAMP_USERNAME
|
22
|
+
end
|
23
|
+
```
|
24
|
+
|
25
|
+
If you fail to set your `key` or `secret` or `client_id` a `MissingConfigExeception`
|
26
|
+
will be raised.
|
27
|
+
|
28
|
+
## Bitstamp ticker
|
29
|
+
|
30
|
+
The bitstamp ticker. Returns `last`, `high`, `low`, `volume`, `bid` and `ask`
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
Bitstamp.ticker
|
34
|
+
```
|
35
|
+
|
36
|
+
It's also possible to query through the `Bitstamp::Ticker` object with
|
37
|
+
each individual method.
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
Bitstamp::Ticker.low # => "109.00"
|
41
|
+
```
|
42
|
+
|
43
|
+
## Fetch your open order
|
44
|
+
|
45
|
+
Returns an array with your open orders.
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
Bitstamp.orders.all
|
49
|
+
```
|
50
|
+
|
51
|
+
## Create a sell order
|
52
|
+
|
53
|
+
Returns an `Order` object.
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
Bitstamp.orders.sell(amount: 1.0, price: 111)
|
57
|
+
```
|
58
|
+
|
59
|
+
## Create a buy order
|
60
|
+
|
61
|
+
Returns an `Order` object.
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
Bitstamp.orders.buy(amount: 1.0, price: 111)
|
65
|
+
```
|
66
|
+
|
67
|
+
## Fetch your transactions
|
68
|
+
|
69
|
+
Returns an `Array` of `UserTransaction`.
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
Bitstamp.user_transactions.all
|
73
|
+
```
|
74
|
+
|
75
|
+
*To be continued!**
|
76
|
+
|
77
|
+
# Tests
|
78
|
+
|
79
|
+
If you'd like to run the tests you need to set the following environment variables:
|
80
|
+
|
81
|
+
```
|
82
|
+
export BITSTAMP_KEY=xxx
|
83
|
+
export BITSTAMP_SECRET=yyy
|
84
|
+
export BITSTAMP_CLIENT_ID=zzz
|
85
|
+
```
|
86
|
+
|
87
|
+
## Contributing
|
88
|
+
|
89
|
+
1. Fork it
|
90
|
+
2. Create your feature branch (`git checkout -b
|
91
|
+
my-new-feature`)
|
92
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
93
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
94
|
+
5. Create new Pull Request
|
95
|
+
|
96
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
require "bundler/gem_tasks"
|
6
|
+
|
7
|
+
begin
|
8
|
+
Bundler.setup(:default, :development)
|
9
|
+
rescue Bundler::BundlerError => e
|
10
|
+
$stderr.puts e.message
|
11
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
12
|
+
exit e.status_code
|
13
|
+
end
|
14
|
+
require 'rake'
|
15
|
+
|
16
|
+
require 'jeweler'
|
17
|
+
Jeweler::Tasks.new do |gem|
|
18
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
19
|
+
gem.name = "bitstamp"
|
20
|
+
gem.homepage = "http://github.com/kojnapp/bitstamp"
|
21
|
+
gem.license = "MIT"
|
22
|
+
gem.summary = %Q{Bitstamp Ruby API}
|
23
|
+
gem.description = %Q{Ruby API for use with bitstamp.}
|
24
|
+
gem.email = "stygeo@gmail.com"
|
25
|
+
gem.authors = ["Jeffrey Wilcke"]
|
26
|
+
#gem.add_dependency('activemodel', '~> 5.1')
|
27
|
+
#gem.add_dependency('activesupport', '~> 5.1')
|
28
|
+
#gem.add_dependency('rest-client', '2.0.2')
|
29
|
+
#gem.add_dependency('ruby-hmac', '= 0.4.0')
|
30
|
+
# dependencies defined in Gemfile
|
31
|
+
end
|
32
|
+
Jeweler::RubygemsDotOrgTasks.new
|
33
|
+
|
34
|
+
require 'rspec/core'
|
35
|
+
require 'rspec/core/rake_task'
|
36
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
37
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
38
|
+
end
|
39
|
+
|
40
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
41
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
42
|
+
spec.rcov = true
|
43
|
+
end
|
44
|
+
|
45
|
+
task :default => :spec
|
46
|
+
|
47
|
+
require 'rdoc/task'
|
48
|
+
Rake::RDocTask.new do |rdoc|
|
49
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
50
|
+
|
51
|
+
rdoc.rdoc_dir = 'rdoc'
|
52
|
+
rdoc.title = "bitstamp #{version}"
|
53
|
+
rdoc.rdoc_files.include('README*')
|
54
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
55
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.4.2
|
data/bitstamp.gemspec
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: bitstamp 0.4.1 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "bitex-bitstamp".freeze
|
9
|
+
s.version = "0.9.1"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib".freeze]
|
13
|
+
s.authors = ["Jeffrey Wilcke".freeze]
|
14
|
+
s.date = "2017-12-20"
|
15
|
+
s.description = "Ruby API for use with bitstamp.".freeze
|
16
|
+
s.email = "stygeo@gmail.com".freeze
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.md"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".rspec",
|
23
|
+
".ruby-gemset",
|
24
|
+
".ruby-version",
|
25
|
+
"Gemfile",
|
26
|
+
"Gemfile.lock",
|
27
|
+
"LICENSE.txt",
|
28
|
+
"README.md",
|
29
|
+
"Rakefile",
|
30
|
+
"VERSION",
|
31
|
+
"bitstamp.gemspec",
|
32
|
+
"lib/bitstamp.rb",
|
33
|
+
"lib/bitstamp/collection.rb",
|
34
|
+
"lib/bitstamp/helper.rb",
|
35
|
+
"lib/bitstamp/model.rb",
|
36
|
+
"lib/bitstamp/net.rb",
|
37
|
+
"lib/bitstamp/orders.rb",
|
38
|
+
"lib/bitstamp/ticker.rb",
|
39
|
+
"lib/bitstamp/transactions.rb",
|
40
|
+
"spec/bitstamp_spec.rb",
|
41
|
+
"spec/collection_spec.rb",
|
42
|
+
"spec/fixtures/vcr_cassettes/bitstamp/balance.yml",
|
43
|
+
"spec/fixtures/vcr_cassettes/bitstamp/order_book.yml",
|
44
|
+
"spec/fixtures/vcr_cassettes/bitstamp/orders/all.yml",
|
45
|
+
"spec/fixtures/vcr_cassettes/bitstamp/orders/buy.yml",
|
46
|
+
"spec/fixtures/vcr_cassettes/bitstamp/orders/sell/failure.yml",
|
47
|
+
"spec/fixtures/vcr_cassettes/bitstamp/ticker.yml",
|
48
|
+
"spec/fixtures/vcr_cassettes/bitstamp/transactions.yml",
|
49
|
+
"spec/fixtures/vcr_cassettes/bitstamp/unconfirmed_user_deposits.yml",
|
50
|
+
"spec/fixtures/vcr_cassettes/bitstamp/user_transactions/all.yml",
|
51
|
+
"spec/fixtures/vcr_cassettes/bitstamp/withdraw_bitcoins/failure.yml",
|
52
|
+
"spec/orders_spec.rb",
|
53
|
+
"spec/spec_helper.rb",
|
54
|
+
"spec/support/bitstamp_setup.rb",
|
55
|
+
"spec/support/vcr.rb",
|
56
|
+
"spec/transactions_spec.rb"
|
57
|
+
]
|
58
|
+
s.homepage = "http://github.com/kojnapp/bitstamp".freeze
|
59
|
+
s.licenses = ["MIT".freeze]
|
60
|
+
s.rubygems_version = "2.6.12".freeze
|
61
|
+
s.summary = "Bitstamp Ruby API".freeze
|
62
|
+
|
63
|
+
if s.respond_to? :specification_version then
|
64
|
+
s.specification_version = 4
|
65
|
+
|
66
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
67
|
+
s.add_runtime_dependency(%q<activemodel>.freeze, ["~> 5.1"])
|
68
|
+
s.add_runtime_dependency(%q<activesupport>.freeze, ["~> 5.1"])
|
69
|
+
s.add_runtime_dependency(%q<rest-client>.freeze, ["= 2.0.2"])
|
70
|
+
s.add_runtime_dependency(%q<ruby-hmac>.freeze, [">= 0"])
|
71
|
+
s.add_development_dependency(%q<rdoc>.freeze, [">= 0"])
|
72
|
+
s.add_development_dependency(%q<bundler>.freeze, [">= 0"])
|
73
|
+
s.add_development_dependency(%q<jeweler>.freeze, [">= 0"])
|
74
|
+
else
|
75
|
+
s.add_dependency(%q<activemodel>.freeze, ["~> 5.1"])
|
76
|
+
s.add_dependency(%q<activesupport>.freeze, ["~> 5.1"])
|
77
|
+
s.add_dependency(%q<rest-client>.freeze, ["= 2.0.2"])
|
78
|
+
s.add_dependency(%q<ruby-hmac>.freeze, [">= 0"])
|
79
|
+
s.add_dependency(%q<rdoc>.freeze, [">= 0"])
|
80
|
+
s.add_dependency(%q<bundler>.freeze, [">= 0"])
|
81
|
+
s.add_dependency(%q<jeweler>.freeze, [">= 0"])
|
82
|
+
end
|
83
|
+
else
|
84
|
+
s.add_dependency(%q<activemodel>.freeze, ["~> 5.1"])
|
85
|
+
s.add_dependency(%q<activesupport>.freeze, ["~> 5.1"])
|
86
|
+
s.add_dependency(%q<rest-client>.freeze, ["= 2.0.2"])
|
87
|
+
s.add_dependency(%q<ruby-hmac>.freeze, [">= 0"])
|
88
|
+
s.add_dependency(%q<rdoc>.freeze, [">= 0"])
|
89
|
+
s.add_dependency(%q<bundler>.freeze, [">= 0"])
|
90
|
+
s.add_dependency(%q<jeweler>.freeze, [">= 0"])
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
data/lib/bitstamp.rb
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'active_support/dependencies/autoload'
|
2
|
+
require 'active_support/core_ext'
|
3
|
+
require 'active_support/inflector'
|
4
|
+
require 'active_model'
|
5
|
+
require 'rest_client'
|
6
|
+
require 'hmac-sha2'
|
7
|
+
|
8
|
+
require 'bitstamp/net'
|
9
|
+
require 'bitstamp/helper'
|
10
|
+
require 'bitstamp/collection'
|
11
|
+
require 'bitstamp/model'
|
12
|
+
|
13
|
+
require 'bitstamp/orders'
|
14
|
+
require 'bitstamp/transactions'
|
15
|
+
require 'bitstamp/withdrawals'
|
16
|
+
require 'bitstamp/ticker'
|
17
|
+
|
18
|
+
String.send(:include, ActiveSupport::Inflector)
|
19
|
+
|
20
|
+
module Bitstamp
|
21
|
+
# API Key
|
22
|
+
mattr_accessor :key
|
23
|
+
|
24
|
+
# Bitstamp secret
|
25
|
+
mattr_accessor :secret
|
26
|
+
|
27
|
+
# Bitstamp client ID
|
28
|
+
mattr_accessor :client_id
|
29
|
+
|
30
|
+
# Currency
|
31
|
+
mattr_accessor :currency
|
32
|
+
@@currency = :usd
|
33
|
+
|
34
|
+
def self.orders
|
35
|
+
self.sanity_check!
|
36
|
+
|
37
|
+
@@orders ||= Bitstamp::Orders.new
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.user_transactions
|
41
|
+
self.sanity_check!
|
42
|
+
|
43
|
+
@@transactions ||= Bitstamp::UserTransactions.new
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.transactions(currency_pair = "btcusd")
|
47
|
+
return Bitstamp::Transactions.from_api(currency_pair)
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.balance(currency_pair = "btcusd")
|
51
|
+
self.sanity_check!
|
52
|
+
path = currency_pair ? "/v2/balance/#{currency_pair}" : "/v2/balance"
|
53
|
+
JSON.parse Bitstamp::Net.post(path).to_str
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.create_withdrawal(options = {})
|
57
|
+
self.sanity_check!
|
58
|
+
Bitstamp::Withdrawals.new.create(options)
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.withdraw_bitcoins(options = {})
|
62
|
+
self.sanity_check!
|
63
|
+
if options[:amount].nil? || options[:address].nil?
|
64
|
+
raise MissingConfigExeception.new("Required parameters not supplied, :amount, :address")
|
65
|
+
end
|
66
|
+
response_body = Bitstamp::Net.post('/bitcoin_withdrawal',options).to_str
|
67
|
+
if response_body != 'true'
|
68
|
+
return JSON.parse response_body
|
69
|
+
else
|
70
|
+
return response_body
|
71
|
+
end
|
72
|
+
end
|
73
|
+
def self.bitcoin_deposit_address
|
74
|
+
# returns the deposit address
|
75
|
+
self.sanity_check!
|
76
|
+
return Bitstamp::Net.post('/bitcoin_deposit_address').to_str
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.unconfirmed_user_deposits
|
80
|
+
self.sanity_check!
|
81
|
+
return JSON.parse Bitstamp::Net::post("/unconfirmed_btc").to_str
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.ticker(currency_pair = "btcusd")
|
85
|
+
return Bitstamp::Ticker.from_api(currency_pair)
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.order_book(currency_pair = "btcusd")
|
89
|
+
return JSON.parse Bitstamp::Net.get("/v2/order_book/#{currency_pair}").to_str
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.setup
|
93
|
+
yield self
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.configured?
|
97
|
+
self.key && self.secret && self.client_id
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.sanity_check!
|
101
|
+
unless configured?
|
102
|
+
raise MissingConfigExeception.new("Bitstamp Gem not properly configured")
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
class MissingConfigExeception<Exception;end;
|
107
|
+
end
|