bittrex 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0cd849c0f70e937b817ebf384aba50c95749106e
4
+ data.tar.gz: 11d2cb28dd38cfc46e2c66b5ecc28ab94eb0704b
5
+ SHA512:
6
+ metadata.gz: 711d86b97047ae0deb9d2979990d3fef5245c0d580da6b8ceeb0eaccb2dcb07499ad041e0eb04870c3624b59f46c0e67f0575c1faa31f8599d3e79d118726f00
7
+ data.tar.gz: d9d64dba3ac81e59faaf4de5ac19683884e634058d2a236a9cfd00665eee3a0dac0048778e1f1b52f28748b2e5c0cae79d83c755ecbcff3948b9202c6524fd45
@@ -0,0 +1,25 @@
1
+ .DS_Store
2
+ *.gem
3
+ *.rbc
4
+ .rspec
5
+ .bundle
6
+ .config
7
+ .yardoc
8
+ Gemfile.lock
9
+ InstalledFiles
10
+ _yardoc
11
+ coverage
12
+ doc/
13
+ lib/bundler/man
14
+ pkg
15
+ rdoc
16
+ spec/reports
17
+ test/tmp
18
+ test/version_tmp
19
+ tmp
20
+ *.bundle
21
+ *.so
22
+ *.o
23
+ *.a
24
+ mkmf.log
25
+ script
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Matthew Werner
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,25 @@
1
+ # Bittrex
2
+
3
+ Unofficial gem for the Bittrex API
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'bittrex'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install bittrex
18
+
19
+ ## Contributing
20
+
21
+ 1. Fork it ( https://github.com/[my-github-username]/bittrex/fork )
22
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
23
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
24
+ 4. Push to the branch (`git push origin my-new-feature`)
25
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bittrex/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bittrex"
8
+ spec.version = Bittrex::VERSION
9
+ spec.authors = ["Matthew Werner"]
10
+ spec.email = ["m@mjw.io"]
11
+ spec.summary = %q{API Client for the Bittrex API}
12
+ spec.description = %q{API Client for the Bittrex API}
13
+ spec.homepage = "https://github.com/mwerner/bittrex"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'faraday', '~> 0.9.0'
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.6"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "simplecov"
27
+ spec.add_development_dependency "mocha"
28
+ end
@@ -0,0 +1,31 @@
1
+ require "bittrex/version"
2
+
3
+ module Bittrex
4
+ autoload :Market, 'bittrex/market'
5
+ autoload :Client, 'bittrex/client'
6
+ autoload :Configuration, 'bittrex/configuration'
7
+ autoload :Currency, 'bittrex/currency'
8
+ autoload :Deposit, 'bittrex/deposit'
9
+ autoload :Order, 'bittrex/order'
10
+ autoload :Quote, 'bittrex/quote'
11
+ autoload :Summary, 'bittrex/summary'
12
+ autoload :Wallet, 'bittrex/wallet'
13
+ autoload :Withdrawl, 'bittrex/withdrawl'
14
+
15
+ def self.client
16
+ @client ||= Client.new(configuration.auth)
17
+ end
18
+
19
+ def self.config
20
+ yield configuration
21
+ @client = Client.new(configuration.auth)
22
+ end
23
+
24
+ def self.configuration
25
+ Configuration.instance
26
+ end
27
+
28
+ def self.root
29
+ File.expand_path('../..', __FILE__)
30
+ end
31
+ end
@@ -0,0 +1,45 @@
1
+ require 'faraday'
2
+ require 'base64'
3
+
4
+ module Bittrex
5
+ class Client
6
+ HOST = 'https://bittrex.com/api/v1.1'
7
+
8
+ attr_reader :key, :secret
9
+
10
+ def initialize(attrs = {})
11
+ @key = attrs[:key]
12
+ @secret = attrs[:secret]
13
+ end
14
+
15
+ def get(path, params = {}, headers = {})
16
+ nonce = Time.now.to_i
17
+ response = connection.get do |req|
18
+ url = "#{HOST}/#{path}"
19
+ req.params.merge!(params)
20
+ req.url(url)
21
+
22
+ if key
23
+ req.params[:apikey] = key
24
+ req.params[:nonce] = nonce
25
+ req.headers[:apisign] = signature(url, nonce)
26
+ end
27
+ end
28
+
29
+ JSON.parse(response.body)['result']
30
+ end
31
+
32
+ private
33
+
34
+ def signature(url, nonce)
35
+ OpenSSL::HMAC.hexdigest('sha512', secret, "#{url}?apikey=#{key}&nonce=#{nonce}")
36
+ end
37
+
38
+ def connection
39
+ @connection ||= Faraday.new(:url => HOST) do |faraday|
40
+ faraday.request :url_encoded
41
+ faraday.adapter Faraday.default_adapter
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,33 @@
1
+ require 'singleton'
2
+
3
+ module Bittrex
4
+ class Configuration
5
+ include Singleton
6
+
7
+ attr_accessor :key, :secret
8
+
9
+ @@defaults = {
10
+ key: nil,
11
+ secret: nil
12
+ }
13
+
14
+ def self.defaults
15
+ @@defaults
16
+ end
17
+
18
+ def initialize
19
+ reset
20
+ end
21
+
22
+ def auth
23
+ {
24
+ key: key,
25
+ secret: secret
26
+ }
27
+ end
28
+
29
+ def reset
30
+ @@defaults.each_pair { |k, v| send("#{k}=", v) }
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,27 @@
1
+ module Bittrex
2
+ class Currency
3
+ attr_reader :name, :abbreviation, :minimum_confirmation, :transaction_fee, :active, :raw
4
+
5
+ alias_method :min_confirmation, :minimum_confirmation
6
+ alias_method :fee, :transaction_fee
7
+
8
+ def initialize(attrs = {})
9
+ @name = attrs['CurrencyLong']
10
+ @abbreviation = attrs['Currency']
11
+ @transaction_fee = attrs['TxFee']
12
+ @minimum_confirmation = attrs['MinConfirmation']
13
+ @active = attrs['IsActive']
14
+ @raw = attrs
15
+ end
16
+
17
+ def self.all
18
+ client.get('public/getcurrencies').map{|data| new(data) }
19
+ end
20
+
21
+ private
22
+
23
+ def self.client
24
+ @client ||= Bittrex.client
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,25 @@
1
+ module Bittrex
2
+ class Deposit
3
+ attr_reader :id, :transaction_id, :address, :quantity, :currency, :confirmations, :executed_at
4
+
5
+ def initialize(attrs = {})
6
+ @id = attrs['Id']
7
+ @transaction_id = attrs['TxId']
8
+ @address = attrs['CryptoAddress']
9
+ @quantity = attrs['Amount']
10
+ @currency = attrs['Currency']
11
+ @confirmations = attrs['Confirmations']
12
+ @executed_at = Time.parse(attrs['LastUpdated'])
13
+ end
14
+
15
+ def self.all
16
+ client.get('account/getdeposithistory').map{|data| new(data) }
17
+ end
18
+
19
+ private
20
+
21
+ def self.client
22
+ @client ||= Bittrex.client
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,27 @@
1
+ module Bittrex
2
+ class Market
3
+ attr_reader :name, :currency, :base, :currency_name, :base_name, :minimum_trade, :active, :created_at, :raw
4
+
5
+ def initialize(attrs = {})
6
+ @name = attrs['MarketName']
7
+ @currency = attrs['MarketCurrency']
8
+ @base = attrs['BaseCurrency']
9
+ @currency_name = attrs['MarketCurrencyLong']
10
+ @base_name = attrs['BaseCurrencyLong']
11
+ @minimum_trade = attrs['MinTradeSize']
12
+ @active = attrs['IsActive']
13
+ @created_at = Time.parse(attrs['Created'])
14
+ @raw = attrs
15
+ end
16
+
17
+ def self.all
18
+ client.get('public/getmarkets').map{|data| new(data) }
19
+ end
20
+
21
+ private
22
+
23
+ def self.client
24
+ @client ||= Bittrex.client
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,62 @@
1
+ module Bittrex
2
+ class Order
3
+ attr_reader :type, :id, :limit,
4
+ :exchange, :price, :quantity, :remaining,
5
+ :total, :fill, :executed_at, :raw
6
+
7
+ def initialize(attrs = {})
8
+ @id = attrs['Id'] || attrs['OrderUuid']
9
+ @type = (attrs['Type'] || attrs['OrderType']).to_s.capitalize
10
+ @exchange = attrs['Exchange']
11
+ @quantity = attrs['Quantity']
12
+ @remaining = attrs['QuantityRemaining']
13
+ @price = attrs['Rate'] || attrs['Price']
14
+ @total = attrs['Total']
15
+ @fill = attrs['FillType']
16
+ @limit = attrs['Limit']
17
+ @commission = attrs['Commission']
18
+ @raw = attrs
19
+ @executed_at = Time.parse(attrs['TimeStamp'])
20
+ end
21
+
22
+ def self.book(market, type, depth = 50)
23
+ orders = []
24
+
25
+ if type.to_sym == :both
26
+ orderbook(market, type.downcase, depth).each_pair do |type, values|
27
+ values.each do |data|
28
+ orders << new(data.merge('Type' => type))
29
+ end
30
+ end
31
+ else
32
+ orderbook(market, type.downcase, depth).each do |data|
33
+ orders << new(data.merge('Type' => type))
34
+ end
35
+ end
36
+
37
+ orders
38
+ end
39
+
40
+ def self.open
41
+ client.get('market/getopenorders').map{|data| new(data) }
42
+ end
43
+
44
+ def self.history
45
+ client.get('account/getorderhistory').map{|data| new(data) }
46
+ end
47
+
48
+ private
49
+
50
+ def self.orderbook(market, type, depth)
51
+ client.get('public/getorderbook', {
52
+ market: market,
53
+ type: type,
54
+ depth: depth
55
+ })
56
+ end
57
+
58
+ def self.client
59
+ @client ||= Bittrex.client
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,25 @@
1
+ module Bittrex
2
+ class Quote
3
+ attr_reader :market, :bid, :ask, :last, :raw
4
+
5
+ def initialize(market, attrs = {})
6
+ @market = market
7
+ @bid = attrs['Bid']
8
+ @ask = attrs['Ask']
9
+ @last = attrs['Last']
10
+ @raw = attrs
11
+ end
12
+
13
+ # Example:
14
+ # Bittrex::Quote.current('BTC-HPY')
15
+ def self.current(market)
16
+ new(market, client.get('public/getticker', market: market))
17
+ end
18
+
19
+ private
20
+
21
+ def self.client
22
+ @client ||= Bittrex.client
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,29 @@
1
+ module Bittrex
2
+ class Summary
3
+ attr_reader :name, :high, :low, :volume, :last, :base_volume, :raw, :created_at
4
+
5
+ alias_method :vol, :volume
6
+ alias_method :base_vol, :base_volume
7
+
8
+ def initialize(attrs = {})
9
+ @name = attrs['MarketName']
10
+ @high = attrs['High']
11
+ @low = attrs['Low']
12
+ @volume = attrs['Volume']
13
+ @last = attrs['Last']
14
+ @base_volume = attrs['BaseVolume']
15
+ @raw = attrs
16
+ @created_at = Time.parse(attrs['TimeStamp'])
17
+ end
18
+
19
+ def self.all
20
+ client.get('public/getmarketsummaries').map{|data| new(data) }
21
+ end
22
+
23
+ private
24
+
25
+ def self.client
26
+ @client ||= Bittrex.client
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module Bittrex
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,26 @@
1
+ module Bittrex
2
+ class Wallet
3
+ attr_reader :id, :currency, :balance, :available, :pending, :address, :requested, :raw
4
+
5
+ def initialize(attrs = {})
6
+ @id = attrs['Uuid'].to_s
7
+ @address = attrs['CryptoAddress']
8
+ @currency = attrs['Currency']
9
+ @balance = attrs['Balance']
10
+ @available = attrs['Available']
11
+ @pending = attrs['Pending']
12
+ @raw = attrs
13
+ @requested = attrs['Requested']
14
+ end
15
+
16
+ def self.all
17
+ client.get('account/getbalances').values.map{|data| new(data) }
18
+ end
19
+
20
+ private
21
+
22
+ def self.client
23
+ @client ||= Bittrex.client
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,31 @@
1
+ module Bittrex
2
+ class Withdrawl
3
+ attr_reader :id, :currency, :quantity, :address, :authorized,
4
+ :pending, :canceled, :invalid_address,
5
+ :transaction_cost, :transaction_id, :executed_at
6
+
7
+ def initialize(attrs = {})
8
+ @id = attrs['PaymentUuid']
9
+ @currency = attrs['Currency']
10
+ @quantity = attrs['Amount']
11
+ @address = attrs['Address']
12
+ @authorized = attrs['Authorized']
13
+ @pending = attrs['PendingPayment']
14
+ @canceled = attrs['Canceled']
15
+ @invalid_address = attrs['Canceled']
16
+ @transaction_cost = attrs['TxCost']
17
+ @transaction_id = attrs['TxId']
18
+ @executed_at = Time.parse(attrs['Opened'])
19
+ end
20
+
21
+ def self.all
22
+ client.get('account/getwithdrawalhistory').map{|data| new(data) }
23
+ end
24
+
25
+ private
26
+
27
+ def self.client
28
+ @client ||= Bittrex.client
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,7 @@
1
+ {
2
+ "CurrencyLong": "Bitcoin",
3
+ "Currency": "BTC",
4
+ "TxFee": 8.0e-08,
5
+ "MinConfirmation": 5,
6
+ "IsActive": true
7
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "Id": 2045339,
3
+ "Amount": 0.31074098,
4
+ "Currency": "BTC",
5
+ "Confirmations": 2,
6
+ "LastUpdated": "2014-06-16T22:57:17.457",
7
+ "TxId": "416ba84218c178e7befbe22b23bf1123a23ec2bc68678586a27cebdxxxb6",
8
+ "CryptoAddress": "17m3mcA3wo5kk637TgEysxxx2c89SDCRZDB"
9
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "MarketCurrency": "LTC",
3
+ "BaseCurrency": "BTC",
4
+ "MarketCurrencyLong": "Litecoin",
5
+ "BaseCurrencyLong": "Bitcoin",
6
+ "MinTradeSize": 0.01,
7
+ "MarketName": "BTC-LTC",
8
+ "IsActive": true,
9
+ "Created": "2014-02-13T00:00:00",
10
+ "DisplayMarketCurrency": null,
11
+ "DisplayMarketName": null
12
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "OrderUuid": "1af0399d-e845-4xxx-9d85-aa332d831e95",
3
+ "Exchange": "BTC-HPY",
4
+ "TimeStamp": "2014-06-21T04:08:08.75",
5
+ "OrderType": "LIMIT_SELL",
6
+ "Limit": 1.6E-7,
7
+ "Quantity": 371810.26006413,
8
+ "QuantityRemaining": 371810.26006413,
9
+ "Price": 0.0,
10
+ "PricePerUnit": null,
11
+ "CancelInitiated": false,
12
+ "IsConditional": false,
13
+ "Condition": "NONE",
14
+ "ConditionTarget": null,
15
+ "ImmediateOrCancel": false
16
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "Bid": 0.01607601,
3
+ "Ask": 0.01633299,
4
+ "Last": 0.01635099
5
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "MarketName": "LTC-ZEIT",
3
+ "High": 2.3E-7,
4
+ "Low": 2.0E-7,
5
+ "Volume": 1406611.43827056,
6
+ "Last": 2.0E-7,
7
+ "BaseVolume": 0.30179011,
8
+ "TimeStamp": "2014-06-26T05:22:57.673",
9
+ "Bid": 2.0E-7,
10
+ "Ask": 2.3E-7,
11
+ "OpenBuyOrders": 7,
12
+ "OpenSellOrders": 7,
13
+ "PrevDay": 2.2E-7,
14
+ "Created": "2014-03-01T21:00:00",
15
+ "DisplayMarketName": null
16
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "Currency": "CRYPT",
3
+ "Balance": 115.0,
4
+ "Available": 0.0,
5
+ "Pending": 0.0,
6
+ "CryptoAddress": null,
7
+ "Requested": false,
8
+ "Uuid": "3dab465d-d0f2-4xxx-819f-aafad450f05b"
9
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "PaymentUuid": "c7f7b806-36cf-4xxx-b198-fcdeb1220762",
3
+ "Currency": "BTC",
4
+ "Amount": 0.0098,
5
+ "Address": "14UKkY9xxxvk79X7u1zYpxxxRUEQ8F7Lh5",
6
+ "Opened": "2014-06-26T05:37:55.083",
7
+ "Authorized": true,
8
+ "PendingPayment": false,
9
+ "TxCost": 0.0002,
10
+ "TxId": "0b34fc4xxx102d0f80efddafexxx6b77c6ce170100b2a579ab5b5f493a383392",
11
+ "Canceled": false,
12
+ "InvalidAddress": false
13
+ }
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bittrex::Configuration do
4
+ context 'defaults' do
5
+ it 'is a hash of default configuration' do
6
+ expect(Bittrex::Configuration.defaults).to be_kind_of(Hash)
7
+ end
8
+ end
9
+
10
+ context 'access' do
11
+ it 'is callable from .config' do
12
+ Bittrex.config do |c|
13
+ expect(c).to be_kind_of(Bittrex::Configuration)
14
+ end
15
+ end
16
+
17
+ context 'options' do
18
+ let(:map) { { 'user' => { a: 1 } } }
19
+ let(:api_key) { 'my_special_key' }
20
+
21
+ it 'is able to set the options_key' do
22
+ Bittrex.config { |config| config.key = api_key }
23
+ expect(Bittrex.configuration.key).to eq(api_key)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bittrex::Currency do
4
+ let(:data){ fixture(:currency) }
5
+ let(:subject){ Bittrex::Currency.new(data) }
6
+
7
+ describe '#initialization' do
8
+ it { should_assign_attribute(subject, :name, 'Bitcoin') }
9
+ it { should_assign_attribute(subject, :abbreviation, 'BTC') }
10
+ it { should_assign_attribute(subject, :transaction_fee, 0.00000008) }
11
+ it { should_assign_attribute(subject, :minimum_confirmation, 5) }
12
+ it { should_assign_attribute(subject, :active, true) }
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bittrex::Deposit do
4
+ let(:data){ fixture(:deposit) }
5
+ let(:subject){ Bittrex::Deposit.new(data) }
6
+
7
+ describe '#initialization' do
8
+ it { should_assign_attribute(subject, :id, 2045339) }
9
+ it { should_assign_attribute(subject, :currency, 'BTC') }
10
+ it { should_assign_attribute(subject, :quantity, 0.31074098) }
11
+ it { should_assign_attribute(subject, :address, '17m3mcA3wo5kk637TgEysxxx2c89SDCRZDB') }
12
+ it { should_assign_attribute(subject, :transaction_id, '416ba84218c178e7befbe22b23bf1123a23ec2bc68678586a27cebdxxxb6') }
13
+ it { should_assign_attribute(subject, :confirmations, 2) }
14
+ it { should_assign_attribute(subject, :executed_at, Time.parse('2014-06-16T22:57:17.457')) }
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bittrex::Market do
4
+ let(:data){ fixture(:market) }
5
+ let(:subject){ Bittrex::Market.new(data) }
6
+
7
+ describe '#initialization' do
8
+ it { should_assign_attribute(subject, :name, 'BTC-LTC') }
9
+ it { should_assign_attribute(subject, :currency, 'LTC') }
10
+ it { should_assign_attribute(subject, :base, 'BTC') }
11
+ it { should_assign_attribute(subject, :currency_name, 'Litecoin') }
12
+ it { should_assign_attribute(subject, :base_name, 'Bitcoin') }
13
+ it { should_assign_attribute(subject, :minimum_trade, 0.01) }
14
+ it { should_assign_attribute(subject, :active, true) }
15
+ it { should_assign_attribute(subject, :created_at, Time.parse('2014-02-13T00:00:00')) }
16
+ end
17
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bittrex::Order do
4
+ let(:data){ fixture(:order) }
5
+ let(:subject){ Bittrex::Order.new(data) }
6
+
7
+ attr_reader :type, :id, :quantity, :rate, :total, :fill, :raw, :executed_at
8
+
9
+ context '#initialization' do
10
+ it { should_assign_attribute(subject, :id, '1af0399d-e845-4xxx-9d85-aa332d831e95') }
11
+ it { should_assign_attribute(subject, :type, 'Limit_sell') }
12
+ it { should_assign_attribute(subject, :exchange, 'BTC-HPY') }
13
+ it { should_assign_attribute(subject, :quantity, 371810.26006413) }
14
+ it { should_assign_attribute(subject, :remaining, 371810.26006413) }
15
+ it { should_assign_attribute(subject, :limit, 0.00000016) }
16
+ it { should_assign_attribute(subject, :price, 0.0) }
17
+ it { should_assign_attribute(subject, :total, nil) }
18
+ it { should_assign_attribute(subject, :fill, nil) }
19
+ it { should_assign_attribute(subject, :executed_at, Time.parse('2014-06-21T04:08:08.75')) }
20
+ end
21
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bittrex::Quote do
4
+ let(:data){ fixture(:quote) }
5
+ let(:subject){ Bittrex::Quote.new('BTC-HPY', data) }
6
+
7
+ describe '#initialization' do
8
+ it { should_assign_attribute(subject, :market, 'BTC-HPY') }
9
+ it { should_assign_attribute(subject, :bid, 0.01607601) }
10
+ it { should_assign_attribute(subject, :ask, 0.01633299) }
11
+ it { should_assign_attribute(subject, :last, 0.01635099) }
12
+ end
13
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bittrex::Summary do
4
+ let(:data){ fixture(:summary) }
5
+ let(:subject){ Bittrex::Summary.new(data) }
6
+
7
+ describe '#initialization' do
8
+ it { should_assign_attribute(subject, :name, 'LTC-ZEIT') }
9
+ it { should_assign_attribute(subject, :high, 0.00000023) }
10
+ it { should_assign_attribute(subject, :low, 0.00000020) }
11
+ it { should_assign_attribute(subject, :volume, 1406611.43827056) }
12
+ it { should_assign_attribute(subject, :last, 0.00000020) }
13
+ it { should_assign_attribute(subject, :base_volume, 0.30179011) }
14
+ it { should_assign_attribute(subject, :created_at, Time.parse('2014-06-26T05:22:57.673')) }
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bittrex::Wallet do
4
+ let(:data){ fixture(:wallet) }
5
+ let(:subject){ Bittrex::Wallet.new(data) }
6
+
7
+ describe '#initialization' do
8
+ it { should_assign_attribute(subject, :id, '3dab465d-d0f2-4xxx-819f-aafad450f05b') }
9
+ it { should_assign_attribute(subject, :currency, 'CRYPT') }
10
+ it { should_assign_attribute(subject, :balance, 115.0) }
11
+ it { should_assign_attribute(subject, :available, 0.0) }
12
+ it { should_assign_attribute(subject, :pending, 0.0) }
13
+ it { should_assign_attribute(subject, :address, nil) }
14
+ it { should_assign_attribute(subject, :requested, false) }
15
+ end
16
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bittrex::Withdrawl do
4
+ let(:data){ fixture(:withdrawl) }
5
+ let(:subject){ Bittrex::Withdrawl.new(data) }
6
+
7
+ describe '#initialization' do
8
+ it { should_assign_attribute(subject, :id, 'c7f7b806-36cf-4xxx-b198-fcdeb1220762') }
9
+ it { should_assign_attribute(subject, :currency, 'BTC') }
10
+ it { should_assign_attribute(subject, :quantity, 0.0098) }
11
+ it { should_assign_attribute(subject, :address, '14UKkY9xxxvk79X7u1zYpxxxRUEQ8F7Lh5') }
12
+ it { should_assign_attribute(subject, :authorized, true) }
13
+ it { should_assign_attribute(subject, :pending, false) }
14
+ it { should_assign_attribute(subject, :canceled, false) }
15
+ it { should_assign_attribute(subject, :invalid_address, false) }
16
+ it { should_assign_attribute(subject, :transaction_cost, 0.0002) }
17
+ it { should_assign_attribute(subject, :transaction_id, '0b34fc4xxx102d0f80efddafexxx6b77c6ce170100b2a579ab5b5f493a383392') }
18
+ it { should_assign_attribute(subject, :executed_at, Time.parse('2014-06-26T05:37:55.083')) }
19
+ end
20
+ end
@@ -0,0 +1,24 @@
1
+ require 'json'
2
+ require 'simplecov'
3
+ SimpleCov.start
4
+
5
+ require 'rspec'
6
+ require 'bittrex'
7
+
8
+ Dir[File.join(Bittrex.root, 'spec/fixtures/**/*.rb')].each { |f| require f }
9
+ Dir[File.join(Bittrex.root, 'spec/support/**/*.rb')].each {|f| require f}
10
+
11
+ RSpec.configure do |config|
12
+ config.before(:each) do
13
+ Bittrex.stub(:client)
14
+ end
15
+ end
16
+
17
+ def fixture(resource)
18
+ path = File.join(Bittrex.root, "spec/fixtures/#{resource}.json")
19
+ JSON.parse File.read(path)
20
+ end
21
+
22
+ def should_assign_attribute(subject, method, value)
23
+ subject.send(method).should eq(value)
24
+ end
@@ -0,0 +1,9 @@
1
+ module APIHelper
2
+ def should_assign_attribute(subject, method, value)
3
+ subject.send(method).should eq(value)
4
+ end
5
+ end
6
+
7
+ RSpec.configure do |config|
8
+ config.extend APIHelper
9
+ end
metadata ADDED
@@ -0,0 +1,184 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bittrex
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Matthew Werner
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.9.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.9.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: mocha
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: API Client for the Bittrex API
98
+ email:
99
+ - m@mjw.io
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - Gemfile
106
+ - LICENSE.txt
107
+ - README.md
108
+ - Rakefile
109
+ - bittrex.gemspec
110
+ - lib/bittrex.rb
111
+ - lib/bittrex/client.rb
112
+ - lib/bittrex/configuration.rb
113
+ - lib/bittrex/currency.rb
114
+ - lib/bittrex/deposit.rb
115
+ - lib/bittrex/market.rb
116
+ - lib/bittrex/order.rb
117
+ - lib/bittrex/quote.rb
118
+ - lib/bittrex/summary.rb
119
+ - lib/bittrex/version.rb
120
+ - lib/bittrex/wallet.rb
121
+ - lib/bittrex/withdrawl.rb
122
+ - spec/fixtures/currency.json
123
+ - spec/fixtures/deposit.json
124
+ - spec/fixtures/market.json
125
+ - spec/fixtures/order.json
126
+ - spec/fixtures/quote.json
127
+ - spec/fixtures/summary.json
128
+ - spec/fixtures/wallet.json
129
+ - spec/fixtures/withdrawl.json
130
+ - spec/models/configuration_spec.rb
131
+ - spec/models/currency_spec.rb
132
+ - spec/models/deposit_spec.rb
133
+ - spec/models/market_spec.rb
134
+ - spec/models/order_spec.rb
135
+ - spec/models/quote_spec.rb
136
+ - spec/models/summary_spec.rb
137
+ - spec/models/wallet_spec.rb
138
+ - spec/models/withdrawl_spec.rb
139
+ - spec/spec_helper.rb
140
+ - spec/support/api_helper.rb
141
+ homepage: https://github.com/mwerner/bittrex
142
+ licenses:
143
+ - MIT
144
+ metadata: {}
145
+ post_install_message:
146
+ rdoc_options: []
147
+ require_paths:
148
+ - lib
149
+ required_ruby_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ required_rubygems_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ requirements: []
160
+ rubyforge_project:
161
+ rubygems_version: 2.2.2
162
+ signing_key:
163
+ specification_version: 4
164
+ summary: API Client for the Bittrex API
165
+ test_files:
166
+ - spec/fixtures/currency.json
167
+ - spec/fixtures/deposit.json
168
+ - spec/fixtures/market.json
169
+ - spec/fixtures/order.json
170
+ - spec/fixtures/quote.json
171
+ - spec/fixtures/summary.json
172
+ - spec/fixtures/wallet.json
173
+ - spec/fixtures/withdrawl.json
174
+ - spec/models/configuration_spec.rb
175
+ - spec/models/currency_spec.rb
176
+ - spec/models/deposit_spec.rb
177
+ - spec/models/market_spec.rb
178
+ - spec/models/order_spec.rb
179
+ - spec/models/quote_spec.rb
180
+ - spec/models/summary_spec.rb
181
+ - spec/models/wallet_spec.rb
182
+ - spec/models/withdrawl_spec.rb
183
+ - spec/spec_helper.rb
184
+ - spec/support/api_helper.rb