mt_gox 0.7.3 → 0.7.5

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY ADDED
@@ -0,0 +1,8 @@
1
+
2
+ == 0.7.4 / 2012-01-16
3
+
4
+ * Models hacked in
5
+
6
+ == 0.7.5 / 2012-01-17
7
+
8
+ * Model now has attributes / properties
data/README.md CHANGED
@@ -1,6 +1,5 @@
1
1
  # Ruby wrapper for the Mt. Gox Trade API.
2
2
 
3
-
4
3
  ## <a name="fork"></a>This Fork
5
4
  This is a fork of https://github.com/sferik/mtgox. This fork features a rework of the
6
5
  original business domain entities into new Models, with an intent to make these Models
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.3
1
+ 0.7.5
@@ -1,6 +1,6 @@
1
+ require 'mtgox/models'
1
2
  require 'mtgox/client'
2
3
  require 'mtgox/configuration'
3
- require 'mtgox/error'
4
4
 
5
5
  module MtGox
6
6
  extend Configuration
@@ -22,4 +22,11 @@ module MtGox
22
22
  new.respond_to?(method, include_private) || super(method, include_private)
23
23
  end
24
24
  end
25
+
26
+ # Custom error class for rescuing from all MtGox errors
27
+ class Error < StandardError
28
+ end
29
+
30
+ class MysqlError < Error
31
+ end
25
32
  end
@@ -1,20 +1,12 @@
1
1
  require 'faraday/error'
2
- require 'mtgox/ask'
3
- require 'mtgox/balance'
4
- require 'mtgox/bid'
5
- require 'mtgox/buy'
6
2
  require 'mtgox/connection'
7
- require 'mtgox/max_bid'
8
- require 'mtgox/min_ask'
9
3
  require 'mtgox/request'
10
- require 'mtgox/sell'
11
- require 'mtgox/ticker'
12
- require 'mtgox/trade'
13
4
 
14
5
  module MtGox
15
6
  class Client
16
7
  include MtGox::Connection
17
8
  include MtGox::Request
9
+ include MtGox::Models
18
10
 
19
11
  ORDER_TYPES = {:sell => 1, :buy => 2}
20
12
 
@@ -36,13 +28,7 @@ module MtGox
36
28
  # MtGox.ticker
37
29
  def ticker
38
30
  ticker = get('/api/0/data/ticker.php')['ticker']
39
- Ticker.instance.buy = ticker['buy'].to_f
40
- Ticker.instance.high = ticker['high'].to_f
41
- Ticker.instance.price = ticker['last'].to_f
42
- Ticker.instance.low = ticker['low'].to_f
43
- Ticker.instance.sell = ticker['sell'].to_f
44
- Ticker.instance.volume = ticker['vol'].to_f
45
- Ticker.instance.vwap = ticker['vwap'].to_f
31
+ Ticker.instance.set_attributes ticker
46
32
  Ticker.instance
47
33
  end
48
34
 
@@ -94,9 +80,7 @@ module MtGox
94
80
  # @example
95
81
  # MtGox.min_ask
96
82
  def min_ask
97
- min_ask = asks.first
98
- MinAsk.instance.price = min_ask.price
99
- MinAsk.instance.amount = min_ask.amount
83
+ MinAsk.instance.set_attributes asks.first.attributes
100
84
  MinAsk.instance
101
85
  end
102
86
 
@@ -107,9 +91,7 @@ module MtGox
107
91
  # @example
108
92
  # MtGox.max_bid
109
93
  def max_bid
110
- max_bid = bids.first
111
- MaxBid.instance.price = max_bid.price
112
- MaxBid.instance.amount = max_bid.amount
94
+ MaxBid.instance.set_attributes bids.first.attributes
113
95
  MaxBid.instance
114
96
  end
115
97
 
@@ -120,7 +102,7 @@ module MtGox
120
102
  # @example
121
103
  # MtGox.trades
122
104
  def trades
123
- get('/api/0/data/getTrades.php').sort_by{|trade| trade['date']}.map do |trade|
105
+ get('/api/0/data/getTrades.php').sort_by { |trade| trade['date'] }.map do |trade|
124
106
  Trade.new(trade)
125
107
  end
126
108
  end
@@ -133,6 +115,10 @@ module MtGox
133
115
  # MtGox.balance
134
116
  def balance
135
117
  parse_balance(post('/api/0/getFunds.php', {}))
118
+ #info = post('/code/info.php', pass_params)
119
+ #info['Wallets'].values.map { |v| v['Balance'] }.map do |balance_info|
120
+ # Balance.new(balance_info['currency'], balance_info['value'])
121
+ #end
136
122
  end
137
123
 
138
124
  # Fetch your open orders, both buys and sells, for network efficiency
@@ -210,13 +196,13 @@ module MtGox
210
196
  # MtGox.cancel {'oid' => '1234567890', 'type' => 2}
211
197
  def cancel(args)
212
198
  if args.is_a?(Hash)
213
- order = args.delete_if{|k, v| !['oid', 'type'].include?(k.to_s)}
199
+ order = args.delete_if { |k, v| !['oid', 'type'].include?(k.to_s) }
214
200
  parse_orders(post('/api/0/cancelOrder.php', order)['orders'])
215
201
  else
216
202
  orders = post('/api/0/getOrders.php', {})['orders']
217
- order = orders.find{|order| order['oid'] == args.to_s}
203
+ order = orders.find { |order| order['oid'] == args.to_s }
218
204
  if order
219
- order = order.delete_if{|k, v| !['oid', 'type'].include?(k.to_s)}
205
+ order = order.delete_if { |k, v| !['oid', 'type'].include?(k.to_s) }
220
206
  parse_orders(post('/api/0/cancelOrder.php', order)['orders'])
221
207
  else
222
208
  raise Faraday::Error::ResourceNotFound, {:status => 404, :headers => {}, :body => 'Order not found.'}
@@ -241,20 +227,20 @@ module MtGox
241
227
 
242
228
  def parse_balance(balance)
243
229
  balances = []
244
- balances << Balance.new('BTC', balance['btcs'])
245
- balances << Balance.new('USD', balance['usds'])
230
+ balances << Balance.new(:currency => 'BTC', :amount => balance['btcs'])
231
+ balances << Balance.new(:currency => 'USD', :amount => balance['usds'])
246
232
  balances
247
233
  end
248
234
 
249
235
  def parse_orders(orders)
250
236
  buys = []
251
237
  sells = []
252
- orders.sort_by{|order| order['date']}.each do |order|
238
+ orders.sort_by { |order| order['date'] }.each do |order|
253
239
  case order['type']
254
- when ORDER_TYPES[:sell]
255
- sells << Sell.new(order)
256
- when ORDER_TYPES[:buy]
257
- buys << Buy.new(order)
240
+ when ORDER_TYPES[:sell]
241
+ sells << Sell.new(order)
242
+ when ORDER_TYPES[:buy]
243
+ buys << Buy.new(order)
258
244
  end
259
245
  end
260
246
  {:buys => buys, :sells => sells}
@@ -0,0 +1,14 @@
1
+ module MtGox
2
+ module Models
3
+ end # module Models
4
+ end
5
+
6
+ require 'mtgox/models/ask'
7
+ require 'mtgox/models/balance'
8
+ require 'mtgox/models/bid'
9
+ require 'mtgox/models/buy'
10
+ require 'mtgox/models/max_bid'
11
+ require 'mtgox/models/min_ask'
12
+ require 'mtgox/models/sell'
13
+ require 'mtgox/models/ticker'
14
+ require 'mtgox/models/trade'
@@ -0,0 +1,17 @@
1
+ require 'mtgox/models/offer'
2
+
3
+ module MtGox
4
+ module Models
5
+ class Ask < Offer
6
+
7
+ def initialize(price=nil, amount=nil)
8
+ super :price => price, :amount => amount
9
+ end
10
+
11
+ def eprice
12
+ price / (1 - MtGox.commission)
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,10 @@
1
+ require 'mtgox/models/model'
2
+
3
+ module MtGox
4
+ module Models
5
+ class Balance < Model
6
+ prop :amount => :f,
7
+ :currency => proc { |val| val.to_s.upcase }
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ require 'mtgox/models/offer'
2
+
3
+ module MtGox
4
+ module Models
5
+ class Bid < Offer
6
+
7
+ def initialize(price=nil, amount=nil)
8
+ super :price => price, :amount => amount
9
+ end
10
+
11
+ def eprice
12
+ price * (1 - MtGox.commission)
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,8 @@
1
+ require 'mtgox/models/order'
2
+
3
+ module MtGox
4
+ module Models
5
+ class Buy < Order
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,12 @@
1
+ require 'mtgox/models/bid'
2
+ require 'mtgox/price_ticker'
3
+ require 'singleton'
4
+
5
+ module MtGox
6
+ module Models
7
+ class MaxBid < Bid
8
+ include Singleton
9
+ include PriceTicker
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ require 'mtgox/models/ask'
2
+ require 'mtgox/price_ticker'
3
+ require 'singleton'
4
+
5
+ module MtGox
6
+ module Models
7
+ class MinAsk < Ask
8
+ include Singleton
9
+ include PriceTicker
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,57 @@
1
+ module MtGox
2
+ module Models
3
+
4
+ # Base data Model class, in future it will be developed into ActiveModel
5
+ class Model
6
+
7
+ def self.prop *properties
8
+ prop_hash = properties.last.is_a?(Hash) ? properties.pop : {}
9
+
10
+ properties.each { |names| define_property names, '' }
11
+ prop_hash.each { |names, type| define_property names, type }
12
+ end
13
+
14
+ def self.define_property names, type
15
+ aliases = [names].flatten
16
+ name = aliases.shift
17
+ instance_eval do
18
+
19
+ define_method(name) do
20
+ @attributes[name]
21
+ end
22
+
23
+ case type
24
+ when ''
25
+ define_method("#{name}=") do |value|
26
+ @attributes[name] = value
27
+ end
28
+ when Proc
29
+ define_method("#{name}=") do |value|
30
+ @attributes[name] = type.call(value)
31
+ end
32
+ else
33
+ define_method("#{name}=") do |value|
34
+ @attributes[name] = value.send "to_#{type}"
35
+ end
36
+ end
37
+
38
+ aliases.each do |ali|
39
+ alias_method "#{ali}", name
40
+ alias_method "#{ali}=", "#{name}="
41
+ end
42
+ end
43
+ end
44
+
45
+ attr_reader :attributes
46
+
47
+ def initialize attrs={}
48
+ @attributes = {}
49
+ set_attributes attrs
50
+ end
51
+
52
+ def set_attributes attrs={}
53
+ attrs.keys.each { |key| self.send("#{key}=", attrs[key]) }
54
+ end
55
+ end # class Model
56
+ end # module Models
57
+ end
@@ -0,0 +1,11 @@
1
+ require 'mtgox/models/model'
2
+
3
+ module MtGox
4
+ module Models
5
+ class Offer < Model
6
+
7
+ prop :amount => :f,
8
+ :price => :f
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,17 @@
1
+ require 'mtgox/models/offer'
2
+
3
+ module MtGox
4
+ module Models
5
+ class Order < Offer
6
+ prop :currency,
7
+ :item,
8
+ :type, # 1 for sell order or 2 for buy order
9
+ :status, # 1 for active, 2 for not enough funds
10
+ :dark,
11
+ :priority,
12
+ [:id, :oid] => :i, # Order ID
13
+ :date => proc { |val| Time.at val } # 1326655184
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,8 @@
1
+ require 'mtgox/models/order'
2
+
3
+ module MtGox
4
+ module Models
5
+ class Sell < Order
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,21 @@
1
+ require 'mtgox/models/model'
2
+ require 'mtgox/price_ticker'
3
+ require 'singleton'
4
+
5
+ module MtGox
6
+ module Models
7
+ class Ticker < Model
8
+ include Singleton
9
+ include PriceTicker
10
+ prop :buy,
11
+ :sell,
12
+ :high,
13
+ :low,
14
+ [:vol, :volume],
15
+ [:last, :price],
16
+ :avg,
17
+ :vwap
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,31 @@
1
+ require 'mtgox/models/offer'
2
+
3
+ module MtGox
4
+ module Models
5
+ class Trade < Offer
6
+
7
+ prop :type, # "trade"
8
+ :item, # "BTC"
9
+ :price_currency, # "USD"
10
+ :trade_type, # "ask", "
11
+ :primary, # "Y" or "N", the primary currency is always the buyers currency
12
+ :properties, # "limit,mixed_currency"
13
+ :amount_int, # "1067215400"
14
+ :price_int, # 681526"
15
+ :amount => :f, # 10.672154
16
+ :price => :f, # 6.81526
17
+ [:id, :tid] => :i, # "tid"=>"1326655184087854"
18
+ :date => proc { |val| Time.at val } # 1326655184
19
+
20
+ def to_s
21
+ "<Trade: #{@date.strftime('%H:%M:%S')} #{ amount.round(3) } at #{ price.round(3) }"
22
+ end
23
+
24
+ def to_s
25
+ "<Trade: #{ amount.round(3) } at #{ price.round(3) }"+
26
+ " #{price_currency}/#{item} (#{trade_type}) - #{ properties } #{ primary } >"
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+ require File.expand_path('../lib/mtgox/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = 'mt_gox'
6
+ gem.version = File.open('VERSION').read.strip
7
+ gem.authors = ["Erik Michaels-Ober", "arvicco"]
8
+ gem.summary = "Ruby wrapper for the Mt. Gox Trade API."
9
+ gem.description = "Ruby wrapper for the Mt. Gox Trade API. Extended with Models."
10
+ gem.email = 'arvicco@gmail.com'
11
+ gem.files = `git ls-files`.split("\n")
12
+ gem.homepage = 'https://github.com/arvicco/mtgox'
13
+
14
+ gem.require_paths = ['lib']
15
+ gem.required_ruby_version = '>= 1.9.2'
16
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+
18
+ gem.add_dependency 'faraday', '~> 0.7'
19
+ gem.add_dependency 'faraday_middleware', '~> 0.7'
20
+ gem.add_dependency 'multi_json', '~> 1.0'
21
+ gem.add_development_dependency 'json'
22
+ gem.add_development_dependency 'rake'
23
+ gem.add_development_dependency 'rdiscount'
24
+ gem.add_development_dependency 'rspec'
25
+ gem.add_development_dependency 'simplecov'
26
+ gem.add_development_dependency 'webmock'
27
+ gem.add_development_dependency 'yard'
28
+
29
+ end
@@ -22,7 +22,7 @@ describe MtGox::Client do
22
22
  address.should == '171dH9Uum6wWLSwH2g8g2yto6SG7NEGyXG'
23
23
  end
24
24
  end
25
-
25
+
26
26
  describe '#ticker' do
27
27
  before do
28
28
  stub_get('/api/0/data/ticker.php').
@@ -0,0 +1,14 @@
1
+ desc 'Alias to doc:rdoc'
2
+ task :doc => 'doc:rdoc'
3
+
4
+ namespace :doc do
5
+ require 'rake/rdoctask'
6
+ Rake::RDocTask.new do |rdoc|
7
+ # Rake::RDocTask.new(:rdoc => "rdoc", :clobber_rdoc => "clobber", :rerdoc => "rerdoc") do |rdoc|
8
+ rdoc.rdoc_dir = DOC_PATH.basename.to_s
9
+ rdoc.title = "#{NAME} #{CLASS_NAME::VERSION} Documentation"
10
+ rdoc.main = "README.doc"
11
+ rdoc.rdoc_files.include('README*')
12
+ rdoc.rdoc_files.include('lib/**/*.rb')
13
+ end
14
+ end
@@ -0,0 +1,40 @@
1
+ desc "Alias to gem:release"
2
+ task :release => 'gem:release'
3
+
4
+ desc "Alias to gem:install"
5
+ task :install => 'gem:install'
6
+
7
+ desc "Alias to gem:build"
8
+ task :gem => 'gem:build'
9
+
10
+ namespace :gem do
11
+ p gem_file = "#{NAME}-#{CLASS_NAME::VERSION}.gem"
12
+
13
+ desc "(Re-)Build gem"
14
+ task :build do
15
+ puts "Remove existing gem package"
16
+ rm_rf PKG_PATH
17
+ puts "Build new gem package"
18
+ system "gem build #{NAME}.gemspec"
19
+ puts "Move built gem to package dir"
20
+ mkdir_p PKG_PATH
21
+ mv gem_file, PKG_PATH
22
+ end
23
+
24
+ desc "Cleanup already installed gem(s)"
25
+ task :cleanup do
26
+ puts "Cleaning up installed gem(s)"
27
+ system "gem cleanup #{NAME}"
28
+ end
29
+
30
+ desc "Build and install gem"
31
+ task :install => :build do
32
+ system "gem install #{PKG_PATH}/#{gem_file}"
33
+ end
34
+
35
+ desc "Build and push gem to Gemcutter"
36
+ task :release => [:build, 'git:tag'] do
37
+ puts "Pushing gem to Gemcutter"
38
+ system "gem push #{PKG_PATH}/#{gem_file}"
39
+ end
40
+ end
@@ -0,0 +1,34 @@
1
+ desc "Alias to git:commit"
2
+ task :git => 'git:commit'
3
+
4
+ namespace :git do
5
+
6
+ desc "Stage and commit your work [with message]"
7
+ task :commit, [:message] do |t, args|
8
+ puts "Staging new (unversioned) files"
9
+ system "git add --all"
10
+ if args.message
11
+ puts "Committing with message: #{args.message}"
12
+ system %Q[git commit -a -m "#{args.message}" --author arvicco]
13
+ else
14
+ puts "Committing"
15
+ system %Q[git commit -a -m "No message" --author arvicco]
16
+ end
17
+ end
18
+
19
+ desc "Push local changes to Github"
20
+ task :push => :commit do
21
+ puts "Pushing local changes to remote"
22
+ system "git push"
23
+ end
24
+
25
+ desc "Create (release) tag on Github"
26
+ task :tag => :push do
27
+ tag = CLASS_NAME::VERSION
28
+ puts "Creating git tag: #{tag}"
29
+ system %Q{git tag -a -m "Release tag #{tag}" #{tag}}
30
+ puts "Pushing #{tag} to remote"
31
+ system "git push origin #{tag}"
32
+ end
33
+
34
+ end
@@ -0,0 +1,16 @@
1
+ desc 'Alias to spec:spec'
2
+ task :spec => 'spec:spec'
3
+
4
+ namespace :spec do
5
+ # require 'spec/rake/spectask'
6
+ require 'rspec/core/rake_task'
7
+
8
+ desc "Run all specs"
9
+ RSpec::Core::RakeTask.new(:spec){|task|}
10
+
11
+ desc "Run specs with RCov"
12
+ RSpec::Core::RakeTask.new(:rcov) do |task|
13
+ task.rcov = true
14
+ task.rcov_opts = ['--exclude', 'spec']
15
+ end
16
+ end
@@ -0,0 +1,71 @@
1
+ class Version
2
+ attr_accessor :major, :minor, :patch, :build
3
+
4
+ def initialize(version_string)
5
+ raise "Invalid version #{version_string}" unless version_string =~ /^(\d+)\.(\d+)\.(\d+)(?:\.(.*?))?$/
6
+ @major = $1.to_i
7
+ @minor = $2.to_i
8
+ @patch = $3.to_i
9
+ @build = $4
10
+ end
11
+
12
+ def bump_major(x)
13
+ @major += x.to_i
14
+ @minor = 0
15
+ @patch = 0
16
+ @build = nil
17
+ end
18
+
19
+ def bump_minor(x)
20
+ @minor += x.to_i
21
+ @patch = 0
22
+ @build = nil
23
+ end
24
+
25
+ def bump_patch(x)
26
+ @patch += x.to_i
27
+ @build = nil
28
+ end
29
+
30
+ def update(major, minor, patch, build=nil)
31
+ @major = major
32
+ @minor = minor
33
+ @patch = patch
34
+ @build = build
35
+ end
36
+
37
+ def write(desc = nil)
38
+ CLASS_NAME::VERSION_FILE.open('w') {|file| file.puts to_s }
39
+ (BASE_PATH + 'HISTORY').open('a') do |file|
40
+ file.puts "\n== #{to_s} / #{Time.now.strftime '%Y-%m-%d'}\n"
41
+ file.puts "\n* #{desc}\n" if desc
42
+ end
43
+ end
44
+
45
+ def to_s
46
+ [major, minor, patch, build].compact.join('.')
47
+ end
48
+ end
49
+
50
+ desc 'Set version: [x.y.z] - explicitly, [1/10/100] - bump major/minor/patch, [.build] - build'
51
+ task :version, [:command, :desc] do |t, args|
52
+ version = Version.new(CLASS_NAME::VERSION)
53
+ case args.command
54
+ when /^(\d+)\.(\d+)\.(\d+)(?:\.(.*?))?$/ # Set version explicitly
55
+ version.update($1, $2, $3, $4)
56
+ when /^\.(.*?)$/ # Set build
57
+ version.build = $1
58
+ when /^(\d{1})$/ # Bump patch
59
+ version.bump_patch $1
60
+ when /^(\d{1})0$/ # Bump minor
61
+ version.bump_minor $1
62
+ when /^(\d{1})00$/ # Bump major
63
+ version.bump_major $1
64
+ else # Unknown command, just display VERSION
65
+ puts "#{NAME} #{version}"
66
+ next
67
+ end
68
+
69
+ puts "Writing version #{version} to VERSION file"
70
+ version.write args.desc
71
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: mt_gox
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.7.3
5
+ version: 0.7.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Erik Michaels-Ober
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2012-01-16 00:00:00 +03:00
14
+ date: 2012-01-17 00:00:00 +03:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -139,30 +139,33 @@ files:
139
139
  - .travis.yml
140
140
  - .yardopts
141
141
  - Gemfile
142
+ - HISTORY
142
143
  - LICENSE.md
143
144
  - README.md
144
145
  - Rakefile
145
146
  - VERSION
146
147
  - lib/faraday/response/raise_mtgox_error.rb
147
148
  - lib/mtgox.rb
148
- - lib/mtgox/ask.rb
149
- - lib/mtgox/balance.rb
150
- - lib/mtgox/bid.rb
151
- - lib/mtgox/buy.rb
152
149
  - lib/mtgox/client.rb
153
150
  - lib/mtgox/configuration.rb
154
151
  - lib/mtgox/connection.rb
155
- - lib/mtgox/error.rb
156
- - lib/mtgox/max_bid.rb
157
- - lib/mtgox/min_ask.rb
158
- - lib/mtgox/offer.rb
159
- - lib/mtgox/order.rb
152
+ - lib/mtgox/models.rb
153
+ - lib/mtgox/models/ask.rb
154
+ - lib/mtgox/models/balance.rb
155
+ - lib/mtgox/models/bid.rb
156
+ - lib/mtgox/models/buy.rb
157
+ - lib/mtgox/models/max_bid.rb
158
+ - lib/mtgox/models/min_ask.rb
159
+ - lib/mtgox/models/model.rb
160
+ - lib/mtgox/models/offer.rb
161
+ - lib/mtgox/models/order.rb
162
+ - lib/mtgox/models/sell.rb
163
+ - lib/mtgox/models/ticker.rb
164
+ - lib/mtgox/models/trade.rb
160
165
  - lib/mtgox/price_ticker.rb
161
166
  - lib/mtgox/request.rb
162
- - lib/mtgox/sell.rb
163
- - lib/mtgox/ticker.rb
164
- - lib/mtgox/trade.rb
165
167
  - lib/mtgox/version.rb
168
+ - mt_gox.gemspec
166
169
  - spec/faraday/response_spec.rb
167
170
  - spec/fixtures/address.json
168
171
  - spec/fixtures/balance.json
@@ -179,6 +182,11 @@ files:
179
182
  - spec/helper.rb
180
183
  - spec/mtgox/client_spec.rb
181
184
  - spec/mtgox_spec.rb
185
+ - tasks/doc.rake
186
+ - tasks/gem.rake
187
+ - tasks/git.rake
188
+ - tasks/spec.rake
189
+ - tasks/version.rake
182
190
  has_rdoc: true
183
191
  homepage: https://github.com/arvicco/mtgox
184
192
  licenses: []
@@ -1,16 +0,0 @@
1
- require 'mtgox/offer'
2
-
3
- module MtGox
4
- class Ask < Offer
5
-
6
- def initialize(price=nil, amount=nil)
7
- self.price = price.to_f
8
- self.amount = amount.to_f
9
- end
10
-
11
- def eprice
12
- price / (1 - MtGox.commission)
13
- end
14
-
15
- end
16
- end
@@ -1,10 +0,0 @@
1
- module MtGox
2
- class Balance
3
- attr_accessor :currency, :amount
4
-
5
- def initialize(currency=nil, amount=nil)
6
- self.currency = currency.to_s.upcase
7
- self.amount = amount.to_f
8
- end
9
- end
10
- end
@@ -1,16 +0,0 @@
1
- require 'mtgox/offer'
2
-
3
- module MtGox
4
- class Bid < Offer
5
-
6
- def initialize(price=nil, amount=nil)
7
- self.price = price.to_f
8
- self.amount = amount.to_f
9
- end
10
-
11
- def eprice
12
- price * (1 - MtGox.commission)
13
- end
14
-
15
- end
16
- end
@@ -1,6 +0,0 @@
1
- require 'mtgox/order'
2
-
3
- module MtGox
4
- class Buy < Order
5
- end
6
- end
@@ -1,7 +0,0 @@
1
- module MtGox
2
- # Custom error class for rescuing from all MtGox errors
3
- class Error < StandardError; end
4
-
5
- class MysqlError < Error; end
6
- end
7
-
@@ -1,10 +0,0 @@
1
- require 'mtgox/bid'
2
- require 'mtgox/price_ticker'
3
- require 'singleton'
4
-
5
- module MtGox
6
- class MaxBid < Bid
7
- include Singleton
8
- include PriceTicker
9
- end
10
- end
@@ -1,10 +0,0 @@
1
- require 'mtgox/ask'
2
- require 'mtgox/price_ticker'
3
- require 'singleton'
4
-
5
- module MtGox
6
- class MinAsk < Ask
7
- include Singleton
8
- include PriceTicker
9
- end
10
- end
@@ -1,5 +0,0 @@
1
- module MtGox
2
- class Offer
3
- attr_accessor :amount, :price
4
- end
5
- end
@@ -1,14 +0,0 @@
1
- require 'mtgox/offer'
2
-
3
- module MtGox
4
- class Order < Offer
5
- attr_accessor :id, :date
6
-
7
- def initialize(order={})
8
- self.id = order['oid']
9
- self.date = Time.at(order['date'].to_i)
10
- self.amount = order['amount'].to_f
11
- self.price = order['price'].to_f
12
- end
13
- end
14
- end
@@ -1,6 +0,0 @@
1
- require 'mtgox/order'
2
-
3
- module MtGox
4
- class Sell < Order
5
- end
6
- end
@@ -1,10 +0,0 @@
1
- require 'mtgox/price_ticker'
2
- require 'singleton'
3
-
4
- module MtGox
5
- class Ticker
6
- include Singleton
7
- include PriceTicker
8
- attr_accessor :buy, :sell, :high, :low, :volume, :vwap
9
- end
10
- end
@@ -1,13 +0,0 @@
1
- require 'mtgox/order'
2
-
3
- module MtGox
4
- class Trade < Order
5
-
6
- def initialize(trade={})
7
- self.id = trade['tid'].to_i
8
- self.date = Time.at(trade['date'].to_i)
9
- self.amount = trade['amount'].to_f
10
- self.price = trade['price'].to_f
11
- end
12
- end
13
- end