rbtc_arbitrage 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -2
  3. data/Gemfile +2 -2
  4. data/Gemfile.lock +32 -24
  5. data/lib/rbtc_arbitrage/version.rb +1 -1
  6. data/rbtc_arbitrage.gemspec +1 -1
  7. data/spec/spec_helper.rb +1 -0
  8. data/spec/support/cassettes/RbtcArbitrage_Clients_CoinbaseClient/_price/calls_coinbase.yml +136 -104
  9. data/spec/support/cassettes/RbtcArbitrage_Clients_CoinbaseClient/_price/fetches_price_for_buy_correctly.yml +36 -22
  10. data/spec/support/cassettes/RbtcArbitrage_Clients_CoinbaseClient/_price/fetches_price_for_sell_correctly.yml +36 -22
  11. metadata +4 -41
  12. data/.gitmodules +0 -3
  13. data/bitstamp/.gitignore +0 -21
  14. data/bitstamp/.rspec +0 -2
  15. data/bitstamp/.ruby-gemset +0 -1
  16. data/bitstamp/.ruby-version +0 -1
  17. data/bitstamp/Gemfile +0 -24
  18. data/bitstamp/Gemfile.lock +0 -64
  19. data/bitstamp/LICENSE.txt +0 -20
  20. data/bitstamp/README.md +0 -96
  21. data/bitstamp/Rakefile +0 -49
  22. data/bitstamp/VERSION +0 -1
  23. data/bitstamp/bitstamp.gemspec +0 -94
  24. data/bitstamp/lib/bitstamp.rb +0 -77
  25. data/bitstamp/lib/bitstamp/collection.rb +0 -30
  26. data/bitstamp/lib/bitstamp/helper.rb +0 -19
  27. data/bitstamp/lib/bitstamp/model.rb +0 -33
  28. data/bitstamp/lib/bitstamp/net.rb +0 -49
  29. data/bitstamp/lib/bitstamp/orders.rb +0 -41
  30. data/bitstamp/lib/bitstamp/ticker.rb +0 -16
  31. data/bitstamp/lib/bitstamp/transactions.rb +0 -37
  32. data/bitstamp/spec/bitstamp_spec.rb +0 -57
  33. data/bitstamp/spec/collection_spec.rb +0 -12
  34. data/bitstamp/spec/fixtures/vcr_cassettes/bitstamp/balance.yml +0 -63
  35. data/bitstamp/spec/fixtures/vcr_cassettes/bitstamp/order_book.yml +0 -1910
  36. data/bitstamp/spec/fixtures/vcr_cassettes/bitstamp/orders/all.yml +0 -62
  37. data/bitstamp/spec/fixtures/vcr_cassettes/bitstamp/orders/buy.yml +0 -62
  38. data/bitstamp/spec/fixtures/vcr_cassettes/bitstamp/orders/sell/failure.yml +0 -60
  39. data/bitstamp/spec/fixtures/vcr_cassettes/bitstamp/ticker.yml +0 -63
  40. data/bitstamp/spec/fixtures/vcr_cassettes/bitstamp/transactions.yml +0 -244
  41. data/bitstamp/spec/fixtures/vcr_cassettes/bitstamp/user_transactions/all.yml +0 -223
  42. data/bitstamp/spec/orders_spec.rb +0 -40
  43. data/bitstamp/spec/spec_helper.rb +0 -26
  44. data/bitstamp/spec/support/bitstamp_setup.rb +0 -19
  45. data/bitstamp/spec/support/vcr.rb +0 -21
  46. data/bitstamp/spec/transactions_spec.rb +0 -32
  47. data/spec/support/cassettes/RbtcArbitrage_Clients_CoinbaseClient/_balance/fetches_the_balance_correctly.yml +0 -109
data/bitstamp/Rakefile DELETED
@@ -1,49 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'rubygems'
4
- require 'bundler'
5
- begin
6
- Bundler.setup(:default, :development)
7
- rescue Bundler::BundlerError => e
8
- $stderr.puts e.message
9
- $stderr.puts "Run `bundle install` to install missing gems"
10
- exit e.status_code
11
- end
12
- require 'rake'
13
-
14
- require 'jeweler'
15
- Jeweler::Tasks.new do |gem|
16
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
- gem.name = "bitstamp"
18
- gem.homepage = "http://github.com/kojnapp/bitstamp"
19
- gem.license = "MIT"
20
- gem.summary = %Q{Bitstamp Ruby API}
21
- gem.description = %Q{Ruby API for use with bitstamp.}
22
- gem.email = "stygeo@gmail.com"
23
- gem.authors = ["Jeffrey Wilcke"]
24
- # dependencies defined in Gemfile
25
- end
26
- Jeweler::RubygemsDotOrgTasks.new
27
-
28
- require 'rspec/core'
29
- require 'rspec/core/rake_task'
30
- RSpec::Core::RakeTask.new(:spec) do |spec|
31
- spec.pattern = FileList['spec/**/*_spec.rb']
32
- end
33
-
34
- RSpec::Core::RakeTask.new(:rcov) do |spec|
35
- spec.pattern = 'spec/**/*_spec.rb'
36
- spec.rcov = true
37
- end
38
-
39
- task :default => :spec
40
-
41
- require 'rdoc/task'
42
- Rake::RDocTask.new do |rdoc|
43
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
-
45
- rdoc.rdoc_dir = 'rdoc'
46
- rdoc.title = "bitstamp #{version}"
47
- rdoc.rdoc_files.include('README*')
48
- rdoc.rdoc_files.include('lib/**/*.rb')
49
- end
data/bitstamp/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.4.0
@@ -1,94 +0,0 @@
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.0 ruby lib
6
-
7
- Gem::Specification.new do |s|
8
- s.name = "bitstamp"
9
- s.version = "0.4.0"
10
-
11
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
- s.authors = ["Jeffrey Wilcke"]
13
- s.date = "2014-03-09"
14
- s.description = "Ruby API for use with bitstamp."
15
- s.email = "stygeo@gmail.com"
16
- s.extra_rdoc_files = [
17
- "LICENSE.txt",
18
- "README.md"
19
- ]
20
- s.files = [
21
- ".rspec",
22
- ".ruby-gemset",
23
- ".ruby-version",
24
- "Gemfile",
25
- "Gemfile.lock",
26
- "LICENSE.txt",
27
- "README.md",
28
- "Rakefile",
29
- "VERSION",
30
- "bitstamp.gemspec",
31
- "lib/bitstamp.rb",
32
- "lib/bitstamp/collection.rb",
33
- "lib/bitstamp/helper.rb",
34
- "lib/bitstamp/model.rb",
35
- "lib/bitstamp/net.rb",
36
- "lib/bitstamp/orders.rb",
37
- "lib/bitstamp/ticker.rb",
38
- "lib/bitstamp/transactions.rb",
39
- "spec/bitstamp_spec.rb",
40
- "spec/collection_spec.rb",
41
- "spec/fixtures/vcr_cassettes/bitstamp/balance.yml",
42
- "spec/fixtures/vcr_cassettes/bitstamp/order_book.yml",
43
- "spec/fixtures/vcr_cassettes/bitstamp/orders/all.yml",
44
- "spec/fixtures/vcr_cassettes/bitstamp/orders/buy.yml",
45
- "spec/fixtures/vcr_cassettes/bitstamp/orders/sell/failure.yml",
46
- "spec/fixtures/vcr_cassettes/bitstamp/ticker.yml",
47
- "spec/fixtures/vcr_cassettes/bitstamp/transactions.yml",
48
- "spec/fixtures/vcr_cassettes/bitstamp/user_transactions/all.yml",
49
- "spec/orders_spec.rb",
50
- "spec/spec_helper.rb",
51
- "spec/support/bitstamp_setup.rb",
52
- "spec/support/vcr.rb",
53
- "spec/transactions_spec.rb"
54
- ]
55
- s.homepage = "http://github.com/kojnapp/bitstamp"
56
- s.licenses = ["MIT"]
57
- s.require_paths = ["lib"]
58
- s.rubygems_version = "2.1.11"
59
- s.summary = "Bitstamp Ruby API"
60
-
61
- if s.respond_to? :specification_version then
62
- s.specification_version = 4
63
-
64
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
65
- s.add_runtime_dependency(%q<activemodel>, [">= 3.1"])
66
- s.add_runtime_dependency(%q<activesupport>, [">= 3.1"])
67
- s.add_runtime_dependency(%q<curb>, ["> 0.8.1"])
68
- s.add_runtime_dependency(%q<ruby-hmac>, ["= 0.4.0"])
69
- s.add_development_dependency(%q<rspec>, [">= 0"])
70
- s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
71
- s.add_development_dependency(%q<bundler>, ["~> 1.3.5"])
72
- s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
73
- else
74
- s.add_dependency(%q<activemodel>, [">= 3.1"])
75
- s.add_dependency(%q<activesupport>, [">= 3.1"])
76
- s.add_dependency(%q<curb>, ["> 0.8.1"])
77
- s.add_dependency(%q<ruby-hmac>, ["= 0.4.0"])
78
- s.add_dependency(%q<rspec>, [">= 0"])
79
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
80
- s.add_dependency(%q<bundler>, ["~> 1.3.5"])
81
- s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
82
- end
83
- else
84
- s.add_dependency(%q<activemodel>, [">= 3.1"])
85
- s.add_dependency(%q<activesupport>, [">= 3.1"])
86
- s.add_dependency(%q<curb>, ["> 0.8.1"])
87
- s.add_dependency(%q<ruby-hmac>, ["= 0.4.0"])
88
- s.add_dependency(%q<rspec>, [">= 0"])
89
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
90
- s.add_dependency(%q<bundler>, ["~> 1.3.5"])
91
- s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
92
- end
93
- end
94
-
@@ -1,77 +0,0 @@
1
- require 'active_support/core_ext'
2
- require 'active_support/inflector'
3
- require 'active_model'
4
- require 'curb'
5
- require 'hmac-sha2'
6
-
7
- require 'bitstamp/net'
8
- require 'bitstamp/helper'
9
- require 'bitstamp/collection'
10
- require 'bitstamp/model'
11
-
12
- require 'bitstamp/orders'
13
- require 'bitstamp/transactions'
14
- require 'bitstamp/ticker'
15
-
16
- String.send(:include, ActiveSupport::Inflector)
17
-
18
- module Bitstamp
19
- # API Key
20
- mattr_accessor :key
21
-
22
- # Bitstamp secret
23
- mattr_accessor :secret
24
-
25
- # Bitstamp client ID
26
- mattr_accessor :client_id
27
-
28
- # Currency
29
- mattr_accessor :currency
30
- @@currency = :usd
31
-
32
- def self.orders
33
- self.sanity_check!
34
-
35
- @@orders ||= Bitstamp::Orders.new
36
- end
37
-
38
- def self.user_transactions
39
- self.sanity_check!
40
-
41
- @@transactions ||= Bitstamp::UserTransactions.new
42
- end
43
-
44
- def self.transactions
45
- return Bitstamp::Transactions.from_api
46
- end
47
-
48
- def self.balance
49
- self.sanity_check!
50
-
51
- JSON.parse Bitstamp::Net.post('/balance').body_str
52
- end
53
-
54
- def self.ticker
55
- return Bitstamp::Ticker.from_api
56
- end
57
-
58
- def self.order_book
59
- return JSON.parse Bitstamp::Net.get('/order_book/').body_str
60
- end
61
-
62
- def self.setup
63
- yield self
64
- end
65
-
66
- def self.configured?
67
- self.key && self.secret && self.client_id
68
- end
69
-
70
- def self.sanity_check!
71
- unless configured?
72
- raise MissingConfigExeception.new("Bitstamp Gem not properly configured")
73
- end
74
- end
75
-
76
- class MissingConfigExeception<Exception;end;
77
- end
@@ -1,30 +0,0 @@
1
- module Bitstamp
2
- class Collection
3
- attr_accessor :access_token, :module, :name, :model, :path
4
-
5
- def initialize(api_prefix="/api")
6
- self.access_token = Bitstamp.key
7
-
8
- self.module = self.class.to_s.singularize.underscore
9
- self.name = self.module.split('/').last
10
- self.model = self.module.camelize.constantize
11
- self.path = "#{api_prefix}/#{self.name.pluralize}"
12
- end
13
-
14
- def all(options = {})
15
- Bitstamp::Helper.parse_objects! Bitstamp::Net::get(self.path).body_str, self.model
16
- end
17
-
18
- def create(options = {})
19
- Bitstamp::Helper.parse_object! Bitstamp::Net::post(self.path, options).body_str, self.model
20
- end
21
-
22
- def find(id, options = {})
23
- Bitstamp::Helper.parse_object! Bitstamp::Net::get("#{self.path}/#{id}").body_str, self.model
24
- end
25
-
26
- def update(id, options = {})
27
- Bitstamp::Helper.parse_object! Bitstamp::Net::patch("#{self.path}/#{id}", options).body_str, self.model
28
- end
29
- end
30
- end
@@ -1,19 +0,0 @@
1
- module Bitstamp
2
- module Helper
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
-
7
- objects = JSON.parse(string)
8
- objects.collect do |t_json|
9
- parse_object!(t_json, klass)
10
- end
11
- end
12
-
13
- def self.parse_object!(object, klass)
14
- object = JSON.parse(object) if object.is_a? String
15
-
16
- klass.new(object)
17
- end
18
- end
19
- end
@@ -1,33 +0,0 @@
1
- module Bitstamp
2
- class Model
3
- attr_accessor :error, :message
4
-
5
- if ActiveModel::VERSION::MAJOR <= 3
6
- include ActiveModel::Validations
7
- include ActiveModel::Conversion
8
- extend ActiveModel::Naming
9
-
10
- def initialize(attributes = {})
11
- self.attributes = attributes
12
- end
13
- else
14
- include ActiveModel::Model
15
- end
16
-
17
- # Set the attributes based on the given hash
18
- def attributes=(attributes = {})
19
- attributes.each do |name, value|
20
- begin
21
- send("#{name}=", value)
22
- rescue NoMethodError => e
23
- puts "Unable to assign #{name}. No such method."
24
- end
25
- end
26
- end
27
-
28
- # Returns a hash with the current instance variables
29
- def attributes
30
- Hash[instance_variables.map { |name| [name, instance_variable_get(name)] }]
31
- end
32
- end
33
- end
@@ -1,49 +0,0 @@
1
- module Bitstamp
2
- module Net
3
- def self.to_uri(path)
4
- return "https://www.bitstamp.net/api#{path}/"
5
- end
6
-
7
- def self.curl(verb, path, options={})
8
- verb = verb.upcase.to_sym
9
-
10
- c = Curl::Easy.new(self.to_uri(path))
11
-
12
- if Bitstamp.configured?
13
- options[:key] = Bitstamp.key
14
- options[:nonce] = (Time.now.to_f*10000).to_i.to_s
15
- options[:signature] = HMAC::SHA256.hexdigest(Bitstamp.secret, options[:nonce]+Bitstamp.client_id.to_s+options[:key]).upcase
16
- end
17
-
18
- c.post_body = options.to_query
19
-
20
- c.http(verb)
21
-
22
- return c
23
- end
24
-
25
- def self.get(path, options={})
26
- request = self.curl(:GET, path, options)
27
-
28
- return request
29
- end
30
-
31
- def self.post(path, options={})
32
- request = self.curl(:POST, path, options)
33
-
34
- return request
35
- end
36
-
37
- def self.patch(path, options={})
38
- request = self.curl(:PATCH, path, options)
39
-
40
- return request
41
- end
42
-
43
- def self.delete(path, options={})
44
- request = self.curl(:DELETE, path, options)
45
-
46
- return request
47
- end
48
- end
49
- end
@@ -1,41 +0,0 @@
1
- module Bitstamp
2
- class Orders < Bitstamp::Collection
3
- def all(options = {})
4
- Bitstamp::Helper.parse_objects! Bitstamp::Net::post('/open_orders').body_str, self.model
5
- end
6
-
7
- def create(options = {})
8
- path = (options[:type] == Bitstamp::Order::SELL ? "/sell" : "/buy")
9
- Bitstamp::Helper.parse_object! Bitstamp::Net::post(path, options).body_str, self.model
10
- end
11
-
12
- def sell(options = {})
13
- options.merge!({type: Bitstamp::Order::SELL})
14
- self.create options
15
- end
16
-
17
- def buy(options = {})
18
- options.merge!({type: Bitstamp::Order::BUY})
19
- self.create options
20
- end
21
-
22
- def find(order_id)
23
- all = self.all
24
- index = all.index {|order| order.id.to_i == order_id}
25
-
26
- return all[index] if index
27
- end
28
- end
29
-
30
- class Order < Bitstamp::Model
31
- BUY = 0
32
- SELL = 1
33
-
34
- attr_accessor :type, :amount, :price, :id, :datetime
35
- attr_accessor :error, :message
36
-
37
- def cancel!
38
- Bitstamp::Net::post('/cancel_order', {id: self.id}).body_str
39
- end
40
- end
41
- end
@@ -1,16 +0,0 @@
1
- module Bitstamp
2
- class Ticker < Bitstamp::Model
3
- attr_accessor :last, :high, :low, :volume, :bid, :ask, :timestamp, :vwap
4
-
5
- def self.from_api
6
- Bitstamp::Helper.parse_object!(Bitstamp::Net.get('/ticker').body_str, self)
7
- end
8
-
9
- def self.method_missing method, *args
10
- ticker = self.from_api
11
- return ticker.send(method) if ticker.respond_to? method
12
-
13
- super
14
- end
15
- end
16
- end
@@ -1,37 +0,0 @@
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, :btc_usd, :nonce
26
- end
27
-
28
- # adding in methods to pull the last public trades list
29
- class Transactions < Bitstamp::Model
30
- attr_accessor :date, :price, :tid, :amount
31
-
32
- def self.from_api
33
- Bitstamp::Helper.parse_objects! Bitstamp::Net::get("/transactions").body_str, self
34
- end
35
-
36
- end
37
- end