vaultoro 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 +7 -0
- data/CHANGELOG.md +4 -0
- data/LICENSE.md +20 -0
- data/README.md +583 -0
- data/lib/vaultoro.rb +57 -0
- data/lib/vaultoro/base.rb +32 -0
- data/lib/vaultoro/basic_api/bid_ask.rb +38 -0
- data/lib/vaultoro/basic_api/buy_orders.rb +37 -0
- data/lib/vaultoro/basic_api/client.rb +47 -0
- data/lib/vaultoro/basic_api/latest_price.rb +25 -0
- data/lib/vaultoro/basic_api/latest_trades.rb +44 -0
- data/lib/vaultoro/basic_api/market_data.rb +56 -0
- data/lib/vaultoro/basic_api/order.rb +10 -0
- data/lib/vaultoro/basic_api/order_book.rb +46 -0
- data/lib/vaultoro/basic_api/price_volume.rb +11 -0
- data/lib/vaultoro/basic_api/sell_orders.rb +37 -0
- data/lib/vaultoro/basic_api/trade.rb +12 -0
- data/lib/vaultoro/basic_api/transaction.rb +11 -0
- data/lib/vaultoro/basic_api/transactions.rb +45 -0
- data/lib/vaultoro/configuration.rb +72 -0
- data/lib/vaultoro/trading_api/balance.rb +11 -0
- data/lib/vaultoro/trading_api/balances.rb +39 -0
- data/lib/vaultoro/trading_api/buy.rb +51 -0
- data/lib/vaultoro/trading_api/cancel.rb +33 -0
- data/lib/vaultoro/trading_api/client.rb +59 -0
- data/lib/vaultoro/trading_api/order.rb +13 -0
- data/lib/vaultoro/trading_api/orders.rb +53 -0
- data/lib/vaultoro/trading_api/sell.rb +48 -0
- data/lib/vaultoro/trading_api/trade.rb +16 -0
- data/lib/vaultoro/trading_api/trades.rb +65 -0
- data/lib/vaultoro/trading_api/withdraw.rb +36 -0
- data/lib/vaultoro/version.rb +11 -0
- metadata +105 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ebc755738bdf8a1717ff5f5286d93dce94da8f98
|
4
|
+
data.tar.gz: b9107b6ee86d5827bd63a3d4c5ee7de87a0f6e53
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 747ee54de3577d6ef743aa508bf8f6a08c613e72ccb3c635dde81af53020cff091051a3ad6d5841faa1667fc225e8206ce3019f5fae659601c4739dc44b46d65
|
7
|
+
data.tar.gz: 2eaaf37b9b6b05ff81c70c30761acb97b7c6200595b94ad6e953ae2e060603a203bc000b05b359d41c1c67b5a2eb36695da32f66cf51c51109dac8788912914b
|
data/CHANGELOG.md
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2018 Jurgen Jocubeit. All rights reserved.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,583 @@
|
|
1
|
+
[](https://badge.fury.io/rb/vaultoro)
|
2
|
+
[](https://github.com/exavest/vaultoro/pulls)
|
3
|
+
|
4
|
+
# Vaultoro
|
5
|
+
|
6
|
+
A ruby API client for [vaultoro.com](https://vaultoro.com/?a=109382), a global bitcoin and physical gold exchange that runs 24 hours a day, every day of the year. [Vaultoro](https://vaultoro.com/?a=109382) facilitates the purchase of real 99.9% pure gold using bitcoin. [Vaultoro](https://vaultoro.com/?a=109382) gold is stored in a high security vaulting facility operated by ProAurum AG in Switzerland, the largest precious metals dealer in Europe. All gold is 100% allocated, reserved and secured under your name as your property and all holdings are audited by one of the largest auditing firms in the world - BDO International. In addition every gram of gold is professionally insured against physical loss for full replacement value. All transactions are instantly settled, and publicly audit-able via the Glass Books Protocol.
|
7
|
+
|
8
|
+
This ruby gem is currently being used by [Exavest](https://exavest.com) to provide an additional portfolio facet. You can be assured the API will remain consistent and stable should you choose to utilize it yourself.
|
9
|
+
|
10
|
+
The [Vaultoro](https://vaultoro.com/?a=109382) ruby gem implements the full API provided by [Vaultoro](https://vaultoro.com/?a=109382). Please note the [Vaultoro](https://vaultoro.com/?a=109382) API is still in beta and is subject to change without notice, consequently this gem may also break without notice. Please report any issues immediately and I will endeavor to patch the gem and issue a release.
|
11
|
+
|
12
|
+
To use the gem to issue buy, sell or cancel orders, query your account balance, open orders or closed trades, and withdraw bitcoin; you will need a [Vaultoro](https://vaultoro.com/?a=109382) account and a set of API keys.
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
To install add the following line to your `Gemfile`:
|
17
|
+
|
18
|
+
``` ruby
|
19
|
+
gem 'vaultoro'
|
20
|
+
```
|
21
|
+
|
22
|
+
And run `bundle install`.
|
23
|
+
|
24
|
+
Alternatively, you can install it from the terminal:
|
25
|
+
|
26
|
+
```
|
27
|
+
gem install vaultoro
|
28
|
+
```
|
29
|
+
|
30
|
+
## Dependencies
|
31
|
+
|
32
|
+
The [Vaultoro](https://vaultoro.com/?a=109382) ruby gem has the following runtime dependencies:
|
33
|
+
- Virtus ~> 1.0.3
|
34
|
+
|
35
|
+
## Compatibility
|
36
|
+
|
37
|
+
Developed with MRI 2.4, however the `.gemspec` only specifies MRI 2.2. It may work with other flavors, but it hasn't been tested. Please let us know if you encounter any issues.
|
38
|
+
|
39
|
+
## Usage
|
40
|
+
|
41
|
+
### Prerequisites
|
42
|
+
|
43
|
+
The [Vaultoro](https://vaultoro.com/?a=109382) ruby gem requires an API key and API secret to use the Trading API. By default the library will look for your API key and secret in the environment variables `VAULTORO_API_KEY` and `VAULTORO_API_SECRET`.
|
44
|
+
|
45
|
+
### Environments
|
46
|
+
|
47
|
+
The [Vaultoro](https://vaultoro.com/?a=109382) ruby gem supports multiple environments. These environments don't have to match your application's environments. By default the environments provided by the client are `:production`, `:test` and `:development`. The default environment is `:production` and the credentials for this environment are read from ENV variables.
|
48
|
+
|
49
|
+
If you'd like to override this behavior and provide the API key and/or secret directly to the client, setup a configuration initializer as shown below:
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
Vaultoro.configure do |config|
|
53
|
+
config.credentials[:production][:api_key] = "B04B4E74C57C37DE4886"
|
54
|
+
config.credentials[:production][:api_secret] = "s3kr3t"
|
55
|
+
config.credentials[:production][:api_uri] = "https://api.vaultoro.com"
|
56
|
+
config.credentials[:production][:api_version] = 1
|
57
|
+
|
58
|
+
config.credentials[:test][:api_key] = "testapi"
|
59
|
+
config.credentials[:test][:api_secret] = "testsecret"
|
60
|
+
config.credentials[:test][:api_uri] = "https://api.vaultoro.com"
|
61
|
+
config.credentials[:test][:api_version] = 1
|
62
|
+
|
63
|
+
config.credentials[:development][:api_key] = "testapi"
|
64
|
+
config.credentials[:development][:api_secret] = "testsecret"
|
65
|
+
config.credentials[:development][:api_uri] = "https://api.vaultoro.com"
|
66
|
+
config.credentials[:development][:api_version] = 1
|
67
|
+
end
|
68
|
+
```
|
69
|
+
|
70
|
+
Or pass the values directly to the attributes on the `Vaultoro` namespace:
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
# Set the environment to development:
|
74
|
+
Vaultoro.environment = :development
|
75
|
+
|
76
|
+
# The set the credentials:
|
77
|
+
Vaultoro.api_key = "B04B4E74C57C37DE4886"
|
78
|
+
Vaultoro.api_secret = "s3kr3t"
|
79
|
+
Vaultoro.api_uri = "https://api.vaultoro.com"
|
80
|
+
Vaultoro.api_version = 1
|
81
|
+
```
|
82
|
+
|
83
|
+
The [Vaultoro](https://vaultoro.com/?a=109382) ruby gem provides flexibility by allowing you to use whatever credentials you want, in whatever environment you want. You can, for instance, add a `:staging` environment if you want:
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
Vaultoro.credentials[:staging][:api_key] = "44CD64EEEFFF887755560B"
|
87
|
+
Vaultoro.credentials[:staging][:api_secret] = "another_secret"
|
88
|
+
Vaultoro.credentials[:staging][:api_uri] = "https://api.vaultoro.com"
|
89
|
+
Vaultoro.credentials[:staging][:api_version] = 1
|
90
|
+
```
|
91
|
+
|
92
|
+
You can query the current list of environments:
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
Vaultoro.environments #=> [:production, :test, :development, :staging]
|
96
|
+
```
|
97
|
+
|
98
|
+
And the currently selected environment:
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
Vaultoro.environment #=> :development
|
102
|
+
```
|
103
|
+
|
104
|
+
The current environment operates independently of any other framework environment, e.g. `Rails.env` or `Rack.env`. You can of course manipulate them to synchronize manually.
|
105
|
+
|
106
|
+
### API Calls
|
107
|
+
The [Vaultoro](https://vaultoro.com/?a=109382) ruby gem provides access to the following [Vaultoro](https://vaultoro.com/?a=109382) API endpoints:
|
108
|
+
|
109
|
+
API | Name | Description
|
110
|
+
--- | --- | ---
|
111
|
+
Basic | Bid And Ask | A simplified version of the order book.
|
112
|
+
Basic | Buy Orders | Buy orders currently in the order book.
|
113
|
+
Basic | Latest Price | Last traded gold price in bitcoin per gram.
|
114
|
+
Basic | Latest Trades | The latest x number of trades.
|
115
|
+
Basic | Market Data | Current market data including last, 24 hour low and 24 hour high prices and 24 hour volume.
|
116
|
+
Basic | Order Book | Current order book (buy and sell orders).
|
117
|
+
Basic | Sell Orders | Sell orders currently in the order book.
|
118
|
+
Basic | Transactions | All transactions in the selected timeframe.
|
119
|
+
Trading | Balances | Your current bitcoin and gold balance in your account.
|
120
|
+
Trading | Trades | Your fulfilled buy or sell orders.
|
121
|
+
Trading | Orders | Your open buy or sell orders and see how much volume is still pending.
|
122
|
+
Trading | Buy | Issue a buy order.
|
123
|
+
Trading | Cancel | Cancel any buy or sell order.
|
124
|
+
Trading | Sell | Issue a sell order.
|
125
|
+
Trading | Withdraw | Withdraw any amount of bitcoin to your saved bitcoin address.
|
126
|
+
|
127
|
+
All dates and times are UTC.
|
128
|
+
|
129
|
+
### Basic API
|
130
|
+
|
131
|
+
The Basic API classes are a collection GET requests that don't require a set of API keys.
|
132
|
+
|
133
|
+
#### Bid And Ask
|
134
|
+
|
135
|
+
No parameters are required for this API call.
|
136
|
+
|
137
|
+
```ruby
|
138
|
+
@bid_ask = Vaultoro::BasicAPI::BidAsk.new
|
139
|
+
result = @bid_ask.fetch #=> true
|
140
|
+
|
141
|
+
# If the fetch method fails it will return false
|
142
|
+
# and populate the errors collection attribute:
|
143
|
+
unless result
|
144
|
+
@bid_ask.errors.each do |error|
|
145
|
+
puts error
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
# Iterate the collection of Vaultoro::BasicAPI::PriceVolume:
|
150
|
+
@bid_ask.list.each do |price_volume|
|
151
|
+
puts price_volume.type #=> 'bid'
|
152
|
+
puts price_volume.price #=> 0.16644123
|
153
|
+
puts price_volume.volume #=> 1.011
|
154
|
+
end
|
155
|
+
```
|
156
|
+
|
157
|
+
#### Buy Orders
|
158
|
+
|
159
|
+
No parameters are required for this API call.
|
160
|
+
|
161
|
+
```ruby
|
162
|
+
@buy_orders = Vaultoro::BasicAPI::BuyOrders.new
|
163
|
+
result = @buy_orders.fetch #=> true
|
164
|
+
|
165
|
+
# If the fetch method fails it will return false
|
166
|
+
# and populate the errors collection attribute:
|
167
|
+
unless result
|
168
|
+
@buy_orders.errors.each do |error|
|
169
|
+
puts error
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
# Iterate the array of Vaultoro::BasicAPI::Order:
|
174
|
+
@buy_orders.list.each do |order|
|
175
|
+
puts order.gold_amount #=> 1.5649
|
176
|
+
puts order.gold_price #=> 0.142
|
177
|
+
end
|
178
|
+
```
|
179
|
+
|
180
|
+
#### Latest Price
|
181
|
+
|
182
|
+
No parameters are required for this API call.
|
183
|
+
|
184
|
+
```ruby
|
185
|
+
@latest_price = Vaultoro::BasicAPI::LatestPrice.new
|
186
|
+
result = @latest_price.fetch #=> true
|
187
|
+
|
188
|
+
# If the fetch method fails it will return false
|
189
|
+
# and populate the errors collection attribute:
|
190
|
+
unless result
|
191
|
+
@latest_price.errors.each do |error|
|
192
|
+
puts error
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
# Read the gold_price attribute:
|
197
|
+
@latest_price.gold_price #=> 0.16548874
|
198
|
+
```
|
199
|
+
|
200
|
+
#### Latest Trades
|
201
|
+
|
202
|
+
This API call requires one of following parameters:
|
203
|
+
- `since` - A transaction_id
|
204
|
+
- `count` - Number of trades to return (range 1-250)
|
205
|
+
|
206
|
+
```ruby
|
207
|
+
@latest_trades = Vaultoro::BasicAPI::LatestTrades.new
|
208
|
+
|
209
|
+
# Request the last 100 trades:
|
210
|
+
@latest_trades.count = 100
|
211
|
+
# or all transactions following transaction id 13992101601423:
|
212
|
+
@latest_trades.since = 13992101601423
|
213
|
+
|
214
|
+
result = @latest_trades.fetch #=> true
|
215
|
+
|
216
|
+
# If the fetch method fails it will return false
|
217
|
+
# and populate the errors collection attribute:
|
218
|
+
unless result
|
219
|
+
@latest_trades.errors.each do |error|
|
220
|
+
puts error
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
# Iterate the array of Vaultoro::BasicAPI::Trade:
|
225
|
+
@latest_trades.list.each do |trade|
|
226
|
+
puts trade.transaction_id #=> 13992101601423
|
227
|
+
puts trade.price #=> 0.15273842
|
228
|
+
puts trade.amount #=> 1.824
|
229
|
+
puts trade.time #=> 2018-04-13 07:56:36 UTC
|
230
|
+
end
|
231
|
+
```
|
232
|
+
|
233
|
+
#### Market Data
|
234
|
+
|
235
|
+
No parameters are required for this API call.
|
236
|
+
|
237
|
+
```ruby
|
238
|
+
@market_data = Vaultoro::BasicAPI::MarketData.new
|
239
|
+
result = @market_data.fetch #=> true
|
240
|
+
|
241
|
+
# If the fetch method fails it will return false
|
242
|
+
# and populate the errors collection attribute:
|
243
|
+
unless result
|
244
|
+
@market_data.errors.each do |error|
|
245
|
+
puts error
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
# Query the MarketData attributes:
|
250
|
+
@market_data.market_currency #=> 'GLD'
|
251
|
+
@market_data.base_currency #=> 'BTC'
|
252
|
+
@market_data.market_currency_name #=> 'Gold'
|
253
|
+
@market_data.base_currency_name #=> 'Bitcoin'
|
254
|
+
@market_data.min_trade_size #=> 0.0
|
255
|
+
@market_data.market_name #=> 'BTC-GLD'
|
256
|
+
@market_data.is_active #=> true
|
257
|
+
@market_data.min_unit_qty #=> 0.0002
|
258
|
+
@market_data.min_price #=> 0.000002
|
259
|
+
@market_data.last_price #=> 0.12414987
|
260
|
+
@market_data.daily_low #=> 0.16550209
|
261
|
+
@market_data.daily_high #=> 0.16550209
|
262
|
+
@market_data.daily_volume #=> 0.067
|
263
|
+
```
|
264
|
+
|
265
|
+
#### Order Book
|
266
|
+
|
267
|
+
No parameters are required for this API call.
|
268
|
+
|
269
|
+
```ruby
|
270
|
+
@order_book = Vaultoro::BasicAPI::OrderBook.new
|
271
|
+
result = @order_book.fetch #=> true
|
272
|
+
|
273
|
+
# If the fetch method fails it will return false
|
274
|
+
# and populate the errors collection attribute:
|
275
|
+
unless result
|
276
|
+
@order_book.errors.each do |error|
|
277
|
+
puts error
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
# Iterate the array of Vaultoro::BasicAPI::Order:
|
282
|
+
@order_book.list.each do |order|
|
283
|
+
puts order.gold_amount #=> 1.5649452112676057
|
284
|
+
puts order.gold_price #=> 0.142
|
285
|
+
end
|
286
|
+
```
|
287
|
+
|
288
|
+
#### Sell Orders
|
289
|
+
|
290
|
+
No parameters are required for this API call.
|
291
|
+
|
292
|
+
```ruby
|
293
|
+
@sell_orders = Vaultoro::BasicAPI::SellOrders.new
|
294
|
+
result = @sell_orders.fetch #=> true
|
295
|
+
|
296
|
+
# If the fetch method fails it will return false
|
297
|
+
# and populate the errors collection attribute:
|
298
|
+
unless result
|
299
|
+
@sell_orders.errors.each do |error|
|
300
|
+
puts error
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
# Iterate the array of Vaultoro::BasicAPI::Order:
|
305
|
+
@sell_orders.list.each do |order|
|
306
|
+
puts order.gold_amount #=> 1.5649
|
307
|
+
puts order.gold_price #=> 0.142
|
308
|
+
end
|
309
|
+
```
|
310
|
+
|
311
|
+
#### Transactions
|
312
|
+
|
313
|
+
This API call requires one parameter:
|
314
|
+
- `time` - A timeframe, either 'hour', 'day' or 'month'
|
315
|
+
|
316
|
+
```ruby
|
317
|
+
@transactions = Vaultoro::BasicAPI::Transactions.new
|
318
|
+
|
319
|
+
# Request transactions for the day:
|
320
|
+
@transactions.time = 'day'
|
321
|
+
|
322
|
+
result = @transactions.fetch #=> true
|
323
|
+
|
324
|
+
# If the fetch method fails it will return false
|
325
|
+
# and populate the errors collection attribute:
|
326
|
+
unless result
|
327
|
+
@transactions.errors.each do |error|
|
328
|
+
puts error
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
332
|
+
# Iterate the array of Vaultoro::BasicAPI::Transaction:
|
333
|
+
@transactions.list.each do |transaction|
|
334
|
+
puts transaction.time #=> 2018-04-13 07:56:36 UTC
|
335
|
+
puts transaction.gold_price #=> 0.16453745590989327
|
336
|
+
puts transaction.gold_amount #=> 30.236276430118696
|
337
|
+
end
|
338
|
+
```
|
339
|
+
|
340
|
+
### Trading API
|
341
|
+
|
342
|
+
The Trading API classes are a collection GET and POST requests that all require a set of API keys.
|
343
|
+
|
344
|
+
#### Balances
|
345
|
+
|
346
|
+
No parameters are required for this API call.
|
347
|
+
|
348
|
+
```ruby
|
349
|
+
@balances = Vaultoro::TradingAPI::Balances.new
|
350
|
+
|
351
|
+
result = @balances.fetch #=> true
|
352
|
+
|
353
|
+
# If the fetch method fails it will return false
|
354
|
+
# and populate the errors collection attribute:
|
355
|
+
unless result
|
356
|
+
@balances.errors.each do |error|
|
357
|
+
puts error
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
361
|
+
# Returns an array containing two balances, one for Gold and the other for Bitcoin.
|
362
|
+
# Iterate the array of Vaultoro::TradingAPI::Balance:
|
363
|
+
@balances.list.each do |balance|
|
364
|
+
puts balance.currency #=> 'GLD'
|
365
|
+
puts balance.cash #=> 0.125
|
366
|
+
puts balance.reserved #=> 0
|
367
|
+
end
|
368
|
+
```
|
369
|
+
|
370
|
+
#### Trades
|
371
|
+
|
372
|
+
This API call requires one of following parameters:
|
373
|
+
- `since` - A time in UTC
|
374
|
+
- `count` - Number of last trades to return (range 1-250)
|
375
|
+
|
376
|
+
```ruby
|
377
|
+
@trades = Vaultoro::TradingAPI::Trades.new
|
378
|
+
|
379
|
+
result = @trades.fetch #=> true
|
380
|
+
|
381
|
+
# If the fetch method fails it will return false
|
382
|
+
# and populate the errors collection attribute:
|
383
|
+
unless result
|
384
|
+
@trades.errors.each do |error|
|
385
|
+
puts error
|
386
|
+
end
|
387
|
+
end
|
388
|
+
|
389
|
+
# Iterate the array of Vaultoro::TradingAPI::Trade:
|
390
|
+
@trades.list.each do |trade|
|
391
|
+
puts trade.side #=> 'BUY'
|
392
|
+
puts trade.time #=> 2018-04-13 07:56:36 UTC
|
393
|
+
puts trade.bitcoin_amount #=> 0.00996
|
394
|
+
puts trade.gold_amount #=> 0.062
|
395
|
+
puts trade.gold_price #=> 0.1592
|
396
|
+
puts trade.fee_amount #=> 0.00031407
|
397
|
+
puts trade.fee_currency #=> 'GLD'
|
398
|
+
puts trade.order_id #=> 'rSaKS2'
|
399
|
+
end
|
400
|
+
```
|
401
|
+
|
402
|
+
#### Orders
|
403
|
+
|
404
|
+
No parameters are required for this API call.
|
405
|
+
|
406
|
+
```ruby
|
407
|
+
@orders = Vaultoro::TradingAPI::Orders.new
|
408
|
+
|
409
|
+
result = @orders.fetch #=> true
|
410
|
+
|
411
|
+
# If the fetch method fails it will return false
|
412
|
+
# and populate the errors collection attribute:
|
413
|
+
unless result
|
414
|
+
@orders.errors.each do |error|
|
415
|
+
puts error
|
416
|
+
end
|
417
|
+
end
|
418
|
+
|
419
|
+
# Iterate the array of Vaultoro::TradingAPI::Order:
|
420
|
+
@orders.list.each do |order|
|
421
|
+
puts order.side #=> 'BUY'
|
422
|
+
puts order.bitcoin_amount #=> 0.00996
|
423
|
+
puts order.gold_amount #=> 0.062
|
424
|
+
puts order.gold_price #=> 0.1592
|
425
|
+
puts order.order_id #=> 'rSaKS2'
|
426
|
+
end
|
427
|
+
```
|
428
|
+
|
429
|
+
#### Buy
|
430
|
+
|
431
|
+
This API call requires the following parameters:
|
432
|
+
- `symbol` - Defaults to 'GLD' as this the currently the only symbol
|
433
|
+
- `type` - Either 'limit' or 'market'
|
434
|
+
- `price` - Size range: 0.00002-100000 (expressed in bitcoin, ignored for 'market' orders)
|
435
|
+
|
436
|
+
And one of the following parameters:
|
437
|
+
- `bitcoin` - Size range: 0.0002-100000 (expressed in bitcoin)
|
438
|
+
- `gold` - Size range: 0.001-100000 (expressed in grams)
|
439
|
+
|
440
|
+
```ruby
|
441
|
+
@buy = Vaultoro::TradingAPI::Buy.new
|
442
|
+
|
443
|
+
# Specify a 'limit' order:
|
444
|
+
@buy.type = 'limit'
|
445
|
+
# or a 'market' order:
|
446
|
+
@buy.type = 'market'
|
447
|
+
|
448
|
+
# Buy 100 grams of gold:
|
449
|
+
@buy.gold = 100
|
450
|
+
# or buy 0.5 bitcoin worth of gold:
|
451
|
+
@buy.bitcoin = 0.05
|
452
|
+
# or specify the price per gram in bitcoin if this is a 'market' order:
|
453
|
+
@buy.price = 0.16253
|
454
|
+
|
455
|
+
result = @buy.execute! #=> true
|
456
|
+
|
457
|
+
# If the fetch method fails it will return false
|
458
|
+
# and populate the errors collection attribute:
|
459
|
+
unless result
|
460
|
+
@buy.errors.each do |error|
|
461
|
+
puts error
|
462
|
+
end
|
463
|
+
end
|
464
|
+
|
465
|
+
# Returns an order_id and order_time:
|
466
|
+
@buy.order_id #=> 'rSaKS2'
|
467
|
+
@buy.order_time #=> 2018-04-13 07:56:36 UTC
|
468
|
+
```
|
469
|
+
|
470
|
+
#### Cancel
|
471
|
+
|
472
|
+
This API call requires the following parameter:
|
473
|
+
- `order_id` - An order_id (6 characters)
|
474
|
+
|
475
|
+
```ruby
|
476
|
+
@cancel = Vaultoro::TradingAPI::Cancel.new
|
477
|
+
@cancel.order_id = 'kH7d12'
|
478
|
+
|
479
|
+
result = @cancel.execute! #=> true
|
480
|
+
|
481
|
+
# If the fetch method fails it will return false
|
482
|
+
# and populate the errors collection attribute:
|
483
|
+
unless result
|
484
|
+
@cancel.errors.each do |error|
|
485
|
+
puts error
|
486
|
+
end
|
487
|
+
end
|
488
|
+
|
489
|
+
# Returns true if successful:
|
490
|
+
@cancel.status #=> true
|
491
|
+
```
|
492
|
+
|
493
|
+
#### Sell
|
494
|
+
|
495
|
+
This API call requires the following parameters:
|
496
|
+
- `symbol` - Defaults to 'GLD' as this the currently the only symbol
|
497
|
+
- `type` - Either 'limit' or 'market'
|
498
|
+
- `gold` - Size range: 0.001-100000 (expressed in grams)
|
499
|
+
- `price` - Size range: 0.00002-100000 (expressed in bitcoin, ignored for 'market' orders)
|
500
|
+
|
501
|
+
```ruby
|
502
|
+
@sell = Vaultoro::TradingAPI::Sell.new
|
503
|
+
|
504
|
+
# Specify a 'limit' order:
|
505
|
+
@sell.type = 'limit'
|
506
|
+
# or a 'market' order:
|
507
|
+
@sell.type = 'market'
|
508
|
+
|
509
|
+
# Sell 100 grams of gold:
|
510
|
+
@sell.gold = 100
|
511
|
+
# or specify the price per gram in bitcoin:
|
512
|
+
@sell.price = 0.16253
|
513
|
+
|
514
|
+
result = @sell.execute! #=> true
|
515
|
+
|
516
|
+
# If the fetch method fails it will return false
|
517
|
+
# and populate the errors collection attribute:
|
518
|
+
unless result
|
519
|
+
@sell.errors.each do |error|
|
520
|
+
puts error
|
521
|
+
end
|
522
|
+
end
|
523
|
+
|
524
|
+
# Returns an order_id and order_time:
|
525
|
+
@sell.order_id #=> 'kH7d12'
|
526
|
+
@sell.order_time #=> 2018-04-13 07:56:36 UTC
|
527
|
+
```
|
528
|
+
|
529
|
+
#### Withdraw
|
530
|
+
|
531
|
+
This API call requires the following parameter:
|
532
|
+
- `bitcoin` - The amount of bitcoin to withdraw to your pre-saved withdrawal address (size range: 0.00010001-100000)
|
533
|
+
|
534
|
+
```ruby
|
535
|
+
@withdraw = Vaultoro::TradingAPI::Withdraw.new
|
536
|
+
|
537
|
+
# Specify the amount of bitcoin to withdraw:
|
538
|
+
@withdraw.bitcoin = 0.5
|
539
|
+
|
540
|
+
result = @withdraw.execute! #=> true
|
541
|
+
|
542
|
+
# If the fetch method fails it will return false
|
543
|
+
# and populate the errors collection attribute:
|
544
|
+
unless result
|
545
|
+
@withdraw.errors.each do |error|
|
546
|
+
puts error
|
547
|
+
end
|
548
|
+
end
|
549
|
+
|
550
|
+
# Returns true if successful:
|
551
|
+
@withdraw.status #=> true
|
552
|
+
|
553
|
+
# Reports the address at which the withdrawal was made to:
|
554
|
+
@withdraw.address #=> '3DcT7S4znnpcmYeig89biVwxcFAaCsQNWT'
|
555
|
+
```
|
556
|
+
|
557
|
+
## Testing
|
558
|
+
|
559
|
+
Tests are yet to be written, hence the `pre` version number. Since the next Vaultoro API is currently in discussion and I've been invited to discuss the new API, I decided to hold off on writing tests until I know where this API is heading.
|
560
|
+
|
561
|
+
## Contributing
|
562
|
+
|
563
|
+
1. Fork it
|
564
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
565
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
566
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
567
|
+
5. Create new Pull Request
|
568
|
+
|
569
|
+
## Credit
|
570
|
+
|
571
|
+
This gem was written and is maintained by [Jurgen Jocubeit](https://github.com/JurgenJocubeit), co-founder at [Exavest](https://www.exavest.com).
|
572
|
+
|
573
|
+
## Disclaimer
|
574
|
+
|
575
|
+
The links to [Vaultoro](https://vaultoro.com/?a=109382) on this page contain an affiliate link, please use the links to help toward maintaining this API client.
|
576
|
+
|
577
|
+
## License
|
578
|
+
|
579
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
580
|
+
|
581
|
+
## Copyright
|
582
|
+
|
583
|
+
Copyright 2018 Jurgen Jocubeit. All rights reserved.
|