ypoloniex 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ad7d1c267d5beb4b5f14b36f190e6ae1a2168e93
4
+ data.tar.gz: 5c1dbd9ad4a7a1cf169322682576b37c7f800a9b
5
+ SHA512:
6
+ metadata.gz: b94e9c6e4dab9b5df0831afddfa6f1adfcce21fe6c8de26fe108991d2f67f863379fa09ff43c91f21cd56cc8e3eb1e472e4848cd135634ba9e9563297b3cef9b
7
+ data.tar.gz: a22ce819a590572ff384cdbffc550bb8f65be4f8edd467b3987ac97f7077bea8d90e0346062286ff42cc1bbd28f5e5be94ab8770c8a5b14982f58f0f6d4443dc
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in poloniex.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Carl Schwope
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,51 @@
1
+ # Poloniex
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 poloniex.com api: [Link](https://poloniex.com/api)
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'poloniex'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install poloniex
19
+
20
+ ## Usage
21
+
22
+ All methods provided by ```Poloniex``` are class methods, and are of the same name as the api ( except that "return"s have been removed ).
23
+
24
+ For example, ```https://www.poloniex.com/public?command=returnTicker``` is written as ```Poloniex.ticker```
25
+
26
+ The Poloniex module accepts a setup block for configuration:
27
+
28
+ ```
29
+ Poloniex.setup do | config |
30
+ config.key = 'my api key'
31
+ config.secret = 'my secret token'
32
+ end
33
+ ```
34
+
35
+ GET requests ( to /public ) do not need authentication, and therefor do not need Poloniex to be configured.
36
+
37
+ POST requests ( to /tradingApi ) will need authentication, and you will have to have your own key and secret token.
38
+
39
+ ### Points to be aware when using the API
40
+
41
+ * By default only the last 500 entries lending_history items since the beginning of the unix timestamp to the current time will be downloaded
42
+ * trade_history will download ever trace since the beginning of the unix timestamp to the current time
43
+ * deposits_withdrawls will download everthing since the beginning of the unix timestamp to the current time
44
+
45
+ ## Contributing
46
+
47
+ 1. Fork it
48
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
49
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
50
+ 4. Push to the branch (`git push origin my-new-feature`)
51
+ 5. Create new Pull Request
@@ -0,0 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ desc 'Offer a gem task like hoe'
4
+ task :gem => :build
5
+
@@ -0,0 +1,149 @@
1
+ require "poloniex/version"
2
+ require 'rest-client'
3
+ require 'openssl'
4
+ require 'addressable/uri'
5
+
6
+ module Poloniex
7
+
8
+ class << self
9
+ attr_accessor :configuration
10
+ end
11
+
12
+ def self.setup
13
+ @configuration ||= Configuration.new
14
+ yield( configuration )
15
+ end
16
+
17
+ class Configuration
18
+ attr_accessor :key, :secret
19
+
20
+ def intialize
21
+ @key = ''
22
+ @secret = ''
23
+ end
24
+ end
25
+
26
+ def self.get_all_daily_exchange_rates( currency_pair )
27
+ res = get 'returnChartData', currencyPair: currency_pair, period: 86400, start: 0, :end => Time.now.to_i
28
+ end
29
+
30
+ def self.ticker
31
+ get 'returnTicker'
32
+ end
33
+
34
+ def self.volume
35
+ get 'return24hVolume'
36
+ end
37
+
38
+ def self.order_book( currency_pair )
39
+ get 'returnOrderBook', currencyPair: currency_pair
40
+ end
41
+
42
+ def self.active_loans
43
+ post 'returnActiveLoans'
44
+ end
45
+
46
+ def self.balances
47
+ post 'returnBalances'
48
+ end
49
+
50
+ # with the default of limit 0 at most 500 lending items are returned
51
+ def self.lending_history( start = 0, end_time = Time.now.to_i, limit = 0 )
52
+ post 'returnLendingHistory', start: start, :end => end_time, :limit => limit
53
+ end
54
+
55
+ def self.currencies
56
+ get 'returnCurrencies'
57
+ end
58
+
59
+ def self.complete_balances
60
+ post 'returnCompleteBalances'
61
+ end
62
+
63
+ def self.open_orders( currency_pair )
64
+ post 'returnOpenOrders', currencyPair: currency_pair
65
+ end
66
+
67
+ def self.trade_history( currency_pair, start = 0, end_time = Time.now.to_i )
68
+ post 'returnTradeHistory', currencyPair: currency_pair, start: start, :end => end_time
69
+ end
70
+
71
+ def self.buy( currency_pair, rate, amount )
72
+ post 'buy', currencyPair: currency_pair, rate: rate, amount: amount
73
+ end
74
+
75
+ def self.sell( currency_pair, rate, amount )
76
+ post 'sell', currencyPair: currency_pair, rate: rate, amount: amount
77
+ end
78
+
79
+ def self.cancel_order( currency_pair, order_number )
80
+ post 'cancelOrder', currencyPair: currency_pair, orderNumber: order_number
81
+ end
82
+
83
+ def self.move_order( order_number, rate )
84
+ post 'moveOrder', orderNumber: order_number, rate: rate
85
+ end
86
+
87
+ def self.withdraw( currency, amount, address )
88
+ post 'widthdraw', currency: currency, amount: amount, address: address
89
+ end
90
+
91
+ def self.available_account_balances
92
+ post 'returnAvailableAccountBalances'
93
+ end
94
+
95
+ def self.tradable_balances
96
+ post 'returnTradableBalances'
97
+ end
98
+
99
+ def self.transfer_balance( currency, amount, from_ccount, to_account )
100
+ post 'transferBalance', currency: currency, amount: amount, fromAccount: from_ccount, toAccount: to_account
101
+ end
102
+
103
+ def self.margin_account_summary
104
+ post 'returnMarginAccountSummary'
105
+ end
106
+
107
+ def self.margin_buy(currency_pair, rate, amount)
108
+ post 'marginBuy', currencyPair: currency_pair, rate: rate, amount: amount
109
+ end
110
+
111
+ def self.margin_sell(currency_pair, rate, amount)
112
+ post 'marginSell', currencyPair: currency_pair, rate: rate, amount: amount
113
+ end
114
+
115
+ def self.deposit_addresses
116
+ post 'returnDepositAddresses'
117
+ end
118
+
119
+ def self.generate_new_address( currency )
120
+ post 'generateNewAddress', currency: currency
121
+ end
122
+
123
+ def self.deposits_withdrawls( start = 0, end_time = Time.now.to_i )
124
+ post 'returnDepositsWithdrawals', start: start, :end => end_time
125
+ end
126
+
127
+ protected
128
+
129
+ def self.resource
130
+ @@resouce ||= RestClient::Resource.new( 'https://www.poloniex.com' )
131
+ end
132
+
133
+ def self.get( command, params = {} )
134
+ params[:command] = command
135
+ resource[ 'public' ].get params: params
136
+ end
137
+
138
+ def self.post( command, params = {} )
139
+ params[:command] = command
140
+ params[:nonce] = (Time.now.to_f * 10000000).to_i
141
+ resource[ 'tradingApi' ].post params, { Key: configuration.key , Sign: create_sign( params ) }
142
+ end
143
+
144
+ def self.create_sign( data )
145
+ encoded_data = Addressable::URI.form_encode( data )
146
+ OpenSSL::HMAC.hexdigest( 'sha512', configuration.secret , encoded_data )
147
+ end
148
+
149
+ end
@@ -0,0 +1,3 @@
1
+ module Poloniex
2
+ VERSION = "1.0.2"
3
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'poloniex/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ypoloniex"
8
+ spec.version = Poloniex::VERSION
9
+ spec.authors = ["Carl Schwope"]
10
+ spec.email = ["schwope.carl@gmail.com"]
11
+ spec.description = %q{Provides a wrapper for poloniex.com api}
12
+ spec.summary = %q{Provides a wrapper for poloniex.com api}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
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_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+
24
+ spec.add_dependency 'rest-client'
25
+ spec.add_dependency 'addressable'
26
+
27
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ypoloniex
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Carl Schwope
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-04-11 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 poloniex.com api
70
+ email:
71
+ - schwope.carl@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - lib/poloniex.rb
82
+ - lib/poloniex/version.rb
83
+ - ypoloniex.gemspec
84
+ homepage: ''
85
+ licenses:
86
+ - MIT
87
+ metadata: {}
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubyforge_project:
104
+ rubygems_version: 2.6.8
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: Provides a wrapper for poloniex.com api
108
+ test_files: []