bittrex_api 1.0.0

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: bea48ab7e5797da7cd9a5671b3ef621c3fe68dec
4
+ data.tar.gz: 4afbce084f44b8bcd494c194011d7aa994910759
5
+ SHA512:
6
+ metadata.gz: 8220ce0c392cb80949e98eaa4429855170fba6dad4e2f2733fbd82ec224921d133ee9273016e68441332c70f610aa0fa95c96a83bc9b0e683d65a320cc69b0bb
7
+ data.tar.gz: 874cb5e2a42ece8f9084f96e7d502cc428f55cfc0a657a5fc3bd9b2e2f046c7b201367232817b51619ee877e166f99f0456bf0488ed5bbd6fc761d5e3f72d660
@@ -0,0 +1,7 @@
1
+ Copyright 2017 Bastian Ermann
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,49 @@
1
+ # BittrexApi
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/poloniex.png)](http://badge.fury.io/rb/poloniex)
4
+
5
+ This gem provides a ruby wrapper to the bittrex.com api: [Link](https://bittrex.com/home/api).
6
+
7
+ It was inspired by the Poloniex gem [Link](https://github.com/Lowest0ne/poloniex).
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'bittrex_api'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install bittrex_api
22
+
23
+ ## Usage
24
+
25
+ All methods provided by ```BittrexApi``` are class methods, and are of the same name as the api ( except that "get"s have been removed ).
26
+
27
+ For example, ```https://bittrex.com/api/v1.1/public/getmarkets``` is written as ```BittrexApi.markets```
28
+
29
+ The BittrexApi module accepts a setup block for configuration:
30
+
31
+ ```
32
+ BittrexApi.setup do | config |
33
+ config.key = 'my api key'
34
+ config.secret = 'my secret token'
35
+ end
36
+ ```
37
+
38
+ GET requests ( to public ) do not need authentication, and therefor do not need Bittrex to be configured.
39
+
40
+ GET requests ( to market and account ) will need authentication, and you will have to have your own key and secret token.
41
+
42
+
43
+ ## Contributing
44
+
45
+ 1. Fork it
46
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
47
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
48
+ 4. Push to the branch (`git push origin my-new-feature`)
49
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,25 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'bittrex_api/version'
4
+ Gem::Specification.new do |s|
5
+ s.name = 'bittrex_api'
6
+ s.version = BittrexApi::VERSION
7
+ s.date = '2017-08-03'
8
+ s.summary = "Provides a wrapper for bittrex.com api"
9
+ s.description = "Provides a wrapper for bittrex.com api"
10
+ s.authors = ["Bastian Ermann"]
11
+ s.email = "bastian@ermannb.com"
12
+ s.homepage = ""
13
+ s.license = "MIT"
14
+
15
+ s.files = `git ls-files`.split($/)
16
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
18
+ s.require_paths = ["lib"]
19
+
20
+ s.add_development_dependency "bundler", "~> 1.3"
21
+ s.add_development_dependency "rake", '~> 0'
22
+
23
+ s.add_dependency 'rest-client', '~> 0'
24
+ s.add_dependency 'addressable', '~> 0'
25
+ end
@@ -0,0 +1,139 @@
1
+ require 'bittrex_api/version'
2
+ require 'rest-client'
3
+ require 'openssl'
4
+ require 'addressable/uri'
5
+
6
+ module BittrexApi
7
+ class << self
8
+ attr_accessor :configuration
9
+ end
10
+
11
+ def self.setup
12
+ @configuration ||= Configuration.new
13
+ yield( @configuration )
14
+ end
15
+
16
+ class Configuration
17
+ attr_accessor :key, :secret
18
+
19
+ def initialize
20
+ @key = ''
21
+ @secret = ''
22
+ end
23
+ end
24
+
25
+ def self.markets
26
+ get_public 'getmarkets'
27
+ end
28
+
29
+ def self.currencies
30
+ get_public 'getcurrencies'
31
+ end
32
+
33
+ def self.ticker( currency_pair )
34
+ get_public 'getticker', market: currency_pair
35
+ end
36
+
37
+ def self.market_summaries
38
+ get_public 'getmarketsummaries'
39
+ end
40
+
41
+ def self.market_summary( currency_pair )
42
+ get_public 'getmarketsummary', market: currency_pair
43
+ end
44
+
45
+ def self.order_book( currency_pair, type = 'both', depth = 10 )
46
+ get_public 'getorderbook', market: currency_pair, type: type, depth: depth
47
+ end
48
+
49
+ def self.market_history( currency_pair )
50
+ get_public 'getmarkethistory', market: currency_pair
51
+ end
52
+
53
+ def self.buy_limit( currency_pair, quantity, rate )
54
+ get_market 'buylimit', market: currency_pair, quantity: quantity, rate: rate
55
+ end
56
+
57
+ def self.sell_limit( currency_pair, quantity, rate )
58
+ get_market 'selllimit', market: currency_pair, quantity: quantity, rate: rate
59
+ end
60
+
61
+ def self.cancel( uuid )
62
+ get_market 'cancel', uuid: uuid
63
+ end
64
+
65
+ def self.open_orders( currency_pair = nil )
66
+ get_market 'getopenorders', market: currency_pair
67
+ end
68
+
69
+ def self.balances
70
+ get_account 'getbalances'
71
+ end
72
+
73
+ def self.balance( currency )
74
+ get_account 'getbalance', currency: currency
75
+ end
76
+
77
+ def self.deposit_address( currency )
78
+ get_account 'getdepositaddress', currency: currency
79
+ end
80
+
81
+ def self.withdraw( currency, quantity, address )
82
+ get_account 'withdraw', currency: currency, quantity: quantity,
83
+ address: address
84
+ end
85
+
86
+ def self.order( uuid )
87
+ get_account 'getorder', uuid: uuid
88
+ end
89
+
90
+ def self.order_history( currency_pair = nil )
91
+ get_account 'getorderhistory', market: currency_pair
92
+ end
93
+
94
+ def self.withdrawal_history( currency = nil )
95
+ get_account 'getwithdrawalhistory', currency: currency
96
+ end
97
+
98
+ def self.deposit_history( currency = nil )
99
+ get_account 'getdeposithistory', currency: currency
100
+ end
101
+
102
+ private
103
+ def self.make_full_url( method, command, params )
104
+ url = "https://bittrex.com/api/v1.1/#{method}/#{command}"
105
+ query = params.map { |k,v| "#{k}=#{v}" }.join '&'
106
+ "#{url}?#{query}"
107
+ end
108
+
109
+ def self.signature( url )
110
+ OpenSSL::HMAC.hexdigest('sha512', configuration.secret.encode("ASCII"),
111
+ url.encode("ASCII"))
112
+ end
113
+
114
+ def self.get_public( command, params = {} )
115
+ get 'public', command, params
116
+ end
117
+
118
+ def self.get_market( command, params = {} )
119
+ get 'market', command, params
120
+ end
121
+
122
+ def self.get_account( command, params = {} )
123
+ get 'account', command, params
124
+ end
125
+
126
+ def self.get( method, command, params )
127
+ if method != 'public'
128
+ params['apikey'] = configuration.key
129
+ params['nonce'] = Time.now.to_i
130
+ end
131
+ full_url = make_full_url(method, command, params)
132
+ if method == 'public'
133
+ RestClient.get(full_url)
134
+ else
135
+ sig = signature(full_url)
136
+ RestClient.get(full_url, apisign: sig)
137
+ end
138
+ end
139
+ end
@@ -0,0 +1,3 @@
1
+ module BittrexApi
2
+ VERSION = "1.0.0"
3
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bittrex_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Bastian Ermann
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-08-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rest-client
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
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: addressable
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Provides a wrapper for bittrex.com api
70
+ email: bastian@ermannb.com
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - License.txt
76
+ - README.md
77
+ - Rakefile
78
+ - bittrex_api.gemspec
79
+ - lib/bittrex_api.rb
80
+ - lib/bittrex_api/version.rb
81
+ homepage: ''
82
+ licenses:
83
+ - MIT
84
+ metadata: {}
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 2.6.11
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: Provides a wrapper for bittrex.com api
105
+ test_files: []