poloniex.rb 0.0.0 → 0.1.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.
- checksums.yaml +4 -4
- data/Gemfile +7 -8
- data/README.md +150 -5
- data/lib/Hash/x_www_form_urlencode.rb +7 -0
- data/lib/Object/inQ.rb +18 -0
- data/lib/Poloniex/V1/Client.rb +571 -86
- data/lib/Poloniex/V1.rb +14 -0
- data/lib/Poloniex/VERSION.rb +1 -1
- data/lib/Thoran/Hash/XWwwFormUrlencode/x_www_form_urlencode.rb +26 -0
- data/lib/Thoran/String/UrlEncode/url_encode.rb +26 -0
- data/lib/poloniex.rb +4 -3
- data/poloniex.rb.gemspec +1 -1
- data/test/Poloniex/Configuration_test.rb +70 -9
- data/test/Poloniex/V1/Client/test_account_endpoints.rb +69 -0
- data/test/Poloniex/V1/Client/test_margin_endpoints.rb +57 -0
- data/test/Poloniex/V1/{Client_test.rb → Client/test_public_endpoints.rb} +22 -57
- data/test/Poloniex/V1/Client/test_trading_endpoints.rb +139 -0
- data/test/Poloniex/V1/Client/test_wallet_endpoints.rb +60 -0
- data/test/Poloniex/VERSION_test.rb +16 -0
- data/test/helper.rb +5 -6
- metadata +14 -7
- data/lib/Poloniex/Client.rb +0 -8
- data/test/Poloniex/Client_test.rb +0 -26
- data/test/poloniex_test.rb +0 -23
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1239f3d75f8740ef02db2a214b2386023efae92bb70faea016f20b5fcac7729a
|
|
4
|
+
data.tar.gz: 9503597302ddf026382009e652a81ed8a48f91b9c08cca55ddfa0e863d16ebf0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a0f92490b48e172724cf090d32d378d3d9be32d2a996de5b148cef49394a4a73ffdb9c5a49ade5e0f88e03b3590af58dde9d7a9cd7f404312ddba53dca7670ef
|
|
7
|
+
data.tar.gz: 1a93ff086f6efce266fa5006e0cdb3e0c3f8008bddb83499a90c1c818ed117ba07a6f74bde5765352fadce7b13b02b30af23a2bf1b2a4ec012fd0e0e2f3f13fe
|
data/Gemfile
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
source
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
2
|
|
|
3
|
-
gem
|
|
3
|
+
gem 'http.rb'
|
|
4
4
|
|
|
5
5
|
group :development, :test do
|
|
6
|
-
gem
|
|
7
|
-
gem
|
|
8
|
-
gem
|
|
9
|
-
gem
|
|
10
|
-
gem
|
|
6
|
+
gem 'rake'
|
|
7
|
+
gem 'minitest'
|
|
8
|
+
gem 'minitest-spec-context'
|
|
9
|
+
gem 'vcr'
|
|
10
|
+
gem 'webmock'
|
|
11
11
|
end
|
|
12
|
-
|
data/README.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
A Ruby wrapper for the Poloniex cryptocurrency exchange API.
|
|
4
4
|
|
|
5
|
+
|
|
5
6
|
## Installation
|
|
6
7
|
|
|
7
8
|
Add this line to your application's Gemfile:
|
|
@@ -22,6 +23,7 @@ Or install it yourself as:
|
|
|
22
23
|
$ gem install poloniex.rb
|
|
23
24
|
```
|
|
24
25
|
|
|
26
|
+
|
|
25
27
|
## Usage
|
|
26
28
|
|
|
27
29
|
### Configuration
|
|
@@ -32,17 +34,28 @@ Poloniex.configure do |config|
|
|
|
32
34
|
config.api_key = 'your_api_key'
|
|
33
35
|
config.api_secret = 'your_api_secret'
|
|
34
36
|
config.debug = false # nil by default; set to true for debugging output
|
|
37
|
+
config.logger = STDOUT # nil by default
|
|
35
38
|
end
|
|
36
39
|
|
|
37
40
|
# Or configure per client instance
|
|
38
41
|
client = Poloniex::Client.new(
|
|
39
42
|
api_key: 'your_api_key',
|
|
40
43
|
api_secret: 'your_api_secret',
|
|
41
|
-
debug: false # nil by default; set to true for debugging output
|
|
44
|
+
debug: false, # nil by default; set to true for debugging output
|
|
45
|
+
logger: STDOUT # nil by default
|
|
42
46
|
)
|
|
47
|
+
|
|
48
|
+
# Or configure per client instance by passing in a configuration object
|
|
49
|
+
configuration = Poloniex::Configuration.new(
|
|
50
|
+
api_key: 'your_api_key',
|
|
51
|
+
api_secret: 'your_api_secret',
|
|
52
|
+
debug: false, # nil by default; set to true for debugging output
|
|
53
|
+
logger: STDOUT # nil by default
|
|
54
|
+
)
|
|
55
|
+
client = Poloniex::Client.new(configuration: configuration)
|
|
43
56
|
```
|
|
44
57
|
|
|
45
|
-
### Public API Endpoints
|
|
58
|
+
### Public V1 API Endpoints
|
|
46
59
|
|
|
47
60
|
```ruby
|
|
48
61
|
# Get candles for specific symbol
|
|
@@ -89,15 +102,148 @@ client.timestamp
|
|
|
89
102
|
|
|
90
103
|
# Get trades for specific symbol
|
|
91
104
|
client.trades('BTC_USDT', limit: 10)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Authenticated V1 API Endpoints
|
|
108
|
+
|
|
109
|
+
#### Account Endpoints
|
|
110
|
+
|
|
111
|
+
```ruby
|
|
112
|
+
# Account information
|
|
113
|
+
client.accounts
|
|
114
|
+
|
|
115
|
+
# All account balances
|
|
116
|
+
client.accounts_balances
|
|
117
|
+
|
|
118
|
+
# Account activity
|
|
119
|
+
client.accounts_activity(limit: 10)
|
|
92
120
|
|
|
121
|
+
# Accounts transfer
|
|
122
|
+
client.accounts_transfer(
|
|
123
|
+
currency: 'USDT',
|
|
124
|
+
amount: 10.5,
|
|
125
|
+
from_account: 'SPOT',
|
|
126
|
+
to_account: 'FUTURES'
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
# Accounts transfer records
|
|
130
|
+
client.accounts_transfer_records
|
|
131
|
+
|
|
132
|
+
# Fee info
|
|
133
|
+
client.fee_info
|
|
134
|
+
|
|
135
|
+
# Interest history
|
|
136
|
+
client.accounts_interest_history
|
|
93
137
|
```
|
|
94
138
|
|
|
139
|
+
#### Margin Endpoints
|
|
140
|
+
```ruby
|
|
141
|
+
# Account margin
|
|
142
|
+
client.account_margin
|
|
143
|
+
|
|
144
|
+
# Borrow status
|
|
145
|
+
client.borrow_status
|
|
146
|
+
|
|
147
|
+
# Borrow status for a particulcar coin
|
|
148
|
+
client.borrow_status(currency: 'BTC')
|
|
149
|
+
|
|
150
|
+
#
|
|
151
|
+
client.max_buy_sell_amount('BTC_USDT')
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
#### Order Endpoints
|
|
155
|
+
```ruby
|
|
156
|
+
|
|
157
|
+
# Create order
|
|
158
|
+
client.create_order(
|
|
159
|
+
symbol: 'BTC_USDT',
|
|
160
|
+
side: 'BUY',
|
|
161
|
+
type: 'LIMIT',
|
|
162
|
+
quantity: 0.001,
|
|
163
|
+
price: 20_000
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
# Create multiple orders
|
|
167
|
+
client.create_multiple_orders(
|
|
168
|
+
[
|
|
169
|
+
{
|
|
170
|
+
symbol: 'BTC_USDT',
|
|
171
|
+
side: 'BUY',
|
|
172
|
+
type: 'LIMIT',
|
|
173
|
+
quantity: 0.01,
|
|
174
|
+
price: 15_000
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
symbol: 'BTC_USDT',
|
|
178
|
+
side: 'BUY',
|
|
179
|
+
type: 'LIMIT',
|
|
180
|
+
quantity: 0.1,
|
|
181
|
+
price: 8_000
|
|
182
|
+
}
|
|
183
|
+
]
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
# Cancel replace order
|
|
187
|
+
client.cancel_replace_order(order_id: 'blue')
|
|
188
|
+
|
|
189
|
+
# Open orders for all symbols
|
|
190
|
+
client.open_orders
|
|
191
|
+
|
|
192
|
+
# Open orders for specific symbol
|
|
193
|
+
client.open_orders(symbol: 'BTC_USDT')
|
|
194
|
+
|
|
195
|
+
# Order details
|
|
196
|
+
client.order_details(order_id: '21934611974062080')
|
|
197
|
+
|
|
198
|
+
# Cancel order
|
|
199
|
+
client.cancel_order(order_id: '32487004629499904')
|
|
200
|
+
|
|
201
|
+
# Cancel multiple orders
|
|
202
|
+
client.cancel_multiple_orders(order_ids: ['12345', '67890'])
|
|
203
|
+
|
|
204
|
+
# Cancel all orders
|
|
205
|
+
client.subject.cancel_all_orders(
|
|
206
|
+
symbols: %w{BTC_USDT ETH_USDT},
|
|
207
|
+
account_types: %w{SPOT}
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
# Kill switch
|
|
211
|
+
client.subject.kill_switch(timeout: 10)
|
|
212
|
+
|
|
213
|
+
# Kill switch status
|
|
214
|
+
client.subject.kill_switch_status
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Wallet Endpoints
|
|
218
|
+
```ruby
|
|
219
|
+
# Deposit addresses
|
|
220
|
+
client.deposit_addresses
|
|
221
|
+
|
|
222
|
+
# Deposit addresses for specific coin
|
|
223
|
+
client.deposit_addresses('BTC')
|
|
224
|
+
|
|
225
|
+
# Wallets activity records
|
|
226
|
+
client.wallets_activity(start: 1754734725, finish: 1754739175)
|
|
227
|
+
|
|
228
|
+
# New currency address
|
|
229
|
+
client.new_currency_address('BTC')
|
|
230
|
+
|
|
231
|
+
# Withdraw currency
|
|
232
|
+
client.withdraw_currency(
|
|
233
|
+
currency: "BTC",
|
|
234
|
+
amount: "0.1",
|
|
235
|
+
address: "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
|
|
236
|
+
)
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
|
|
95
240
|
## Development
|
|
96
241
|
|
|
97
242
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
98
243
|
|
|
99
244
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
100
245
|
|
|
246
|
+
|
|
101
247
|
## Contributing
|
|
102
248
|
|
|
103
249
|
Bug reports and pull requests are welcome on GitHub at https://github.com/yourusername/poloniex.rb.
|
|
@@ -105,14 +251,13 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/yourus
|
|
|
105
251
|
|
|
106
252
|
## Contributing
|
|
107
253
|
|
|
108
|
-
1. Fork it (https://github.com/thoran/
|
|
254
|
+
1. Fork it (https://github.com/thoran/poloniex.rb/fork)
|
|
109
255
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
110
256
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
111
257
|
4. Push to the branch (`git push origin my-new-feature`)
|
|
112
258
|
5. Create a new pull request
|
|
113
259
|
|
|
114
260
|
|
|
115
|
-
|
|
116
261
|
## License
|
|
117
262
|
|
|
118
|
-
The gem is available as open source under the terms of the [Ruby License](https://
|
|
263
|
+
The gem is available as open source under the terms of the [Ruby License](https://en.wikipedia.org/wiki/Ruby_License).
|
data/lib/Object/inQ.rb
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Object/self.inQ
|
|
2
|
+
# Object.in?
|
|
3
|
+
|
|
4
|
+
# 20111114
|
|
5
|
+
# 0.5.0
|
|
6
|
+
|
|
7
|
+
# Description: This is essentially the reverse of Enumerable.include?. It can be pointed at any object and takes a collection as an argument.
|
|
8
|
+
|
|
9
|
+
# Changes:
|
|
10
|
+
# 1. Using Enumerable#flatten instead of testing the first argument in the argument list, since ths makes the code much shorter.
|
|
11
|
+
|
|
12
|
+
class Object
|
|
13
|
+
|
|
14
|
+
def in?(*a)
|
|
15
|
+
a.flatten.include?(self)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|