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.
@@ -0,0 +1,16 @@
1
+ module Vaultoro
2
+ module TradingAPI
3
+ class Trade
4
+ include Virtus.model
5
+
6
+ attribute :side, String
7
+ attribute :time, Time
8
+ attribute :bitcoin_amount, Float
9
+ attribute :gold_amount, Float
10
+ attribute :gold_price, Float
11
+ attribute :fee_amount, Float
12
+ attribute :fee_currency, String
13
+ attribute :order_id, String
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,65 @@
1
+ module Vaultoro
2
+ module TradingAPI
3
+ class Trades < Base
4
+ attribute :list, Array[Trade]
5
+ attribute :since, DateTime
6
+ attribute :count, Integer
7
+
8
+ def fetch
9
+ @errors.clear
10
+
11
+ params = {}
12
+ params.merge!(since: since.to_i) if since
13
+ params.merge!(count: count.to_i) if count
14
+
15
+ response = Client.get("/mytrades", params)
16
+ code = response.code rescue ""
17
+
18
+ case code
19
+ when '200'
20
+ hash = JSON.parse(response.body)
21
+
22
+ @status = hash['status'].upcase
23
+
24
+ if @status == 'SUCCESS'
25
+ hash['data'].each do |trades|
26
+ trades['b'] do |buy|
27
+ @list << Trade.new(
28
+ side: 'BUY',
29
+ time: DateTime.parse(buy['Time']),
30
+ bitcoin_amount: buy['BTC_Amount'].to_f,
31
+ gold_amount: buy['Gold_Amount'].to_f,
32
+ gold_price: buy['Gold_Price'].to_f,
33
+ fee_amount: buy['GLDFee'].to_f,
34
+ fee_currency: 'GLD',
35
+ order_id: buy.fetch('Order_ID', nil)
36
+ )
37
+ end
38
+
39
+ trades['s'] do |sell|
40
+ @list << Trade.new(
41
+ side: 'SELL',
42
+ time: DateTime.parse(buy['Time']),
43
+ bitcoin_amount: buy['BTC_Amount'].to_f,
44
+ gold_amount: buy['Gold_Amount'].to_f,
45
+ gold_price: buy['Gold_Price'].to_f,
46
+ fee_amount: buy['BTCFee'].to_f,
47
+ fee_currency: 'BTC',
48
+ order_id: sell.fetch('Order_ID', nil)
49
+ )
50
+ end
51
+ end
52
+ else
53
+ set_errors(response)
54
+ return false
55
+ end
56
+
57
+ return true
58
+ else
59
+ set_errors(response)
60
+ return false
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,36 @@
1
+ module Vaultoro
2
+ module TradingAPI
3
+ class Withdraw < Base
4
+ attribute :bitcoin, Float # Size range: 0.00010001-100000
5
+ attribute :address, String
6
+
7
+ def execute!
8
+ ensure_attribute_has_value :btc
9
+ return false if @errors.any?
10
+
11
+ params = { btc: @bitcoin }
12
+
13
+ response = Client.post("/withdraw", params)
14
+ code = response.code rescue ""
15
+
16
+ case code
17
+ when '200'
18
+ hash = JSON.parse(response.body)
19
+
20
+ @status = hash['status'].upcase
21
+ @address = hash['data']['address']
22
+
23
+ unless @status == 'SUCCESS'
24
+ set_errors(response)
25
+ return false
26
+ end
27
+
28
+ return true
29
+ else
30
+ set_errors(response)
31
+ return false
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,11 @@
1
+ module Vaultoro
2
+ module VERSION
3
+ MAJOR = 0
4
+ MINOR = 1
5
+ TINY = 0
6
+ PRE = nil
7
+ STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
8
+ SUMMARY = "Vaultoro Ruby Gem v#{STRING}"
9
+ DESCRIPTION = "A ruby API client for vaultoro.com, a global bitcoin and physical gold exchange."
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vaultoro
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jurgen Jocubeit
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-01-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: virtus
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.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
+ description: A ruby API client for vaultoro.com, a global bitcoin and physical gold
42
+ exchange.
43
+ email:
44
+ - support@exavest.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - CHANGELOG.md
50
+ - LICENSE.md
51
+ - README.md
52
+ - lib/vaultoro.rb
53
+ - lib/vaultoro/base.rb
54
+ - lib/vaultoro/basic_api/bid_ask.rb
55
+ - lib/vaultoro/basic_api/buy_orders.rb
56
+ - lib/vaultoro/basic_api/client.rb
57
+ - lib/vaultoro/basic_api/latest_price.rb
58
+ - lib/vaultoro/basic_api/latest_trades.rb
59
+ - lib/vaultoro/basic_api/market_data.rb
60
+ - lib/vaultoro/basic_api/order.rb
61
+ - lib/vaultoro/basic_api/order_book.rb
62
+ - lib/vaultoro/basic_api/price_volume.rb
63
+ - lib/vaultoro/basic_api/sell_orders.rb
64
+ - lib/vaultoro/basic_api/trade.rb
65
+ - lib/vaultoro/basic_api/transaction.rb
66
+ - lib/vaultoro/basic_api/transactions.rb
67
+ - lib/vaultoro/configuration.rb
68
+ - lib/vaultoro/trading_api/balance.rb
69
+ - lib/vaultoro/trading_api/balances.rb
70
+ - lib/vaultoro/trading_api/buy.rb
71
+ - lib/vaultoro/trading_api/cancel.rb
72
+ - lib/vaultoro/trading_api/client.rb
73
+ - lib/vaultoro/trading_api/order.rb
74
+ - lib/vaultoro/trading_api/orders.rb
75
+ - lib/vaultoro/trading_api/sell.rb
76
+ - lib/vaultoro/trading_api/trade.rb
77
+ - lib/vaultoro/trading_api/trades.rb
78
+ - lib/vaultoro/trading_api/withdraw.rb
79
+ - lib/vaultoro/version.rb
80
+ homepage: https://github.com/exavest/vaultoro
81
+ licenses:
82
+ - MIT
83
+ metadata:
84
+ copyright: Copyright 2018 Jurgen Jocubeit
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: '2.2'
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.13
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: Vaultoro Ruby Gem v0.1.0
105
+ test_files: []