vault_of_satoshi 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c1e875eb3e886544c86750cb12fb43185006a3d5
4
- data.tar.gz: b5137743d6835cea4f328bc5db12438bc3ff818a
3
+ metadata.gz: 87632db2ffc03aab733bf817f47f678b08ed6348
4
+ data.tar.gz: 718ee0622641476f747bfde02bb1c5bf97133a32
5
5
  SHA512:
6
- metadata.gz: 80af280d1bfc293b2b7fc611078e6cb279293cf300a9b5071434ceb68b25865fc98154b4d913336c74080ef67b34d96a06bc0841b42d413ac3659fc3ae21fc84
7
- data.tar.gz: 0d17e8956ef6cc1cc5414c49f36b2c2bbdca9eb575560b8dc8b6458b1fd84ba6d43f24d0f9fcfa31e945bcf94498e25a5a7b17fe93e89a7de1409fb661784665
6
+ metadata.gz: 22b6778df04698af7b5fb451b2092f98363c4d05f7ee630c8f5f020d9e6467bd8ff218b1cb97b8cbf2354555a20d6d76df658bf86d692062d02dd5a27590df73
7
+ data.tar.gz: 89b431f8f9390bcefe36933ef681f73814beb1e85d3837413704ae4331e3f727ac3b77fd48b380f0cc45fb497653122c09698ff9cd5b9272c47e2469f16207a9
data/README.md CHANGED
@@ -1,4 +1,179 @@
1
- ## Installation
1
+ ## Getting started
2
+
3
+ ### Installation
2
4
 
3
- gem install 'vault_of_satoshi'
5
+ ```ruby
6
+ gem install 'vault_of_satoshi'
7
+ ```
8
+
9
+ ### Some notes about this library
10
+
11
+ * All responses are returned as `OpenStructs` or `Arrays` of `OpenStructs`, meaning that individual members can be accessed by "dot" syntax or as keys of a `Hash`. For example, `response.date` and `response[:date]` are both valid ways to access the `date` member.
12
+ * The raw API returns `Currency Objects` to represent prices and quantities. This library automatically converts `Currency Objects` into `BigDecimal` in order to retain precision and abstract away the work of converting `Currency Objects` into usable numerical values.
13
+ * For endpoints that require a `Currency Object` as one of the parameters, just use an `Integer`, `Float`, or `BigDecimal`. The library will take care of the rest.
14
+
15
+ ### Setup
16
+
17
+ ```ruby
18
+ api_key = "XXXXXXXXXXXXXXXXXXXXXX"
19
+ api_secret = "XXXXXXXXXXXXXXXXXXXXXX"
20
+ @client = VaultOfSatoshi::API::Client.new(api_key, api_secret)
21
+ ```
22
+
23
+ ## Examples
24
+
25
+ ### Currency
26
+
27
+ ```ruby
28
+ currency = @client.info.currency(currency: 'DOGE')
29
+
30
+ currency.name
31
+ => "Dogecoin"
32
+
33
+ currency.virtual
34
+ => true
35
+
36
+ currency.tradeable
37
+ => true
38
+
39
+ ```
40
+
41
+ ### Account
42
+
43
+ ```ruby
44
+ account = @client.info.account
45
+
46
+ account.created
47
+ => Sat, 01 Feb 2014 03:06:49 +0000
48
+
49
+ account.trade_fee.DOGE.to_f
50
+ => 0.01
51
+
52
+ account.wallets.DOGE.daily_withdrawal_limit.to_f
53
+ => 0.0
54
+ ```
55
+
56
+ ### Balance
57
+
58
+ ```ruby
59
+ @client.info.balance.DOGE.to_f
60
+ => 50.0
61
+ ```
62
+
63
+ ### Wallet Address
64
+
65
+ ```ruby
66
+ @client.info.wallet_address(currency: 'DOGE').wallet_address
67
+ => "DD7WjShc937XEmRbGzrCvxjAFAWKwMb9fi"
68
+ ```
69
+
70
+ ### Wallet History
71
+
72
+ ```ruby
73
+ @client.info.wallet_history(currency: 'DOGE').map(&:transfer_date)
74
+ => [Thu, 20 Feb 2014 01:17:35 +0000, Sat, 22 Feb 2014 15:26:09 +0000]
75
+ ```
76
+
77
+ ### Ticker
78
+
79
+ ```ruby
80
+ ticker = @client.info.ticker(order_currency: 'DOGE', payment_currency: 'USD')
81
+
82
+ ticker.date
83
+ => Sat, 22 Feb 2014 03:57:50 +0000
84
+
85
+ ticker.min_price.to_f
86
+ => 0.00118
87
+
88
+ ticker.average_price.to_f
89
+ => 0.00126
90
+
91
+ ticker.max_price.to_f
92
+ => 0.00132
93
+ ```
94
+
95
+ ### Quote
96
+
97
+ ```ruby
98
+ quote = @client.info.quote(type: 'bid', order_currency: 'DOGE', units: 1000, payment_currency: 'USD', price: 0.0012)
99
+
100
+ quote.rate.to_f
101
+ => 0.01
102
+
103
+ quote.fee.to_f
104
+ => 0.012
105
+
106
+ quote.subtotal.to_f
107
+ => 1.2
108
+
109
+ quote.total.to_f
110
+ => 1.212
111
+ ```
112
+
113
+ ### Orderbook
114
+
115
+ ```ruby
116
+ orderbook = @client.info.orderbook(order_currency: 'DOGE', payment_currency: 'USD', round: 8, count: 10)
117
+
118
+ output = "Price | Quantity \n"
119
+ output += "-----------------------\n"
120
+ orderbook.asks.each do |ask|
121
+ output += sprintf("%0.8f", ask.price)
122
+ output += " | "
123
+ output += sprintf("%0.1f", ask.quantity).rjust(10)
124
+ output += "\n"
125
+ end
126
+
127
+ puts output
128
+
129
+ Price | Quantity
130
+ -----------------------
131
+ 0.00131000 | 2618.0
132
+ 0.00132000 | 20999.9
133
+ 0.00132000 | 20000.0
134
+ 0.00132000 | 1324.2
135
+ 0.00133000 | 60000.0
136
+ 0.00133000 | 100.0
137
+ 0.00133000 | 56000.0
138
+ 0.00134000 | 380000.0
139
+ 0.00135000 | 988320.0
140
+ 0.00137000 | 697000.0
141
+ ```
142
+
143
+ ### Orders
144
+
145
+ ```ruby
146
+ first_order = @client.info.orders.first
147
+
148
+ first_order.status
149
+ => "filled"
150
+
151
+ first_order.order_id
152
+ => 540664
153
+ ```
154
+
155
+ ### Order Detail
156
+
157
+ ```ruby
158
+ @client.info.order_detail(order_id: 540664).first.units_traded.to_f
159
+ => 50.0
160
+ ```
161
+
162
+ ### Place a Trade
163
+
164
+ ```ruby
165
+ order = @client.trade.place(type: 'bid', order_currency: 'DOGE', units: 5, payment_currency: 'USD', price: 0.0010)
166
+
167
+ order.order_id
168
+ => 594853
169
+ ```
170
+
171
+ ### Cancel a Trade
172
+
173
+ ```ruby
174
+ @client.trade.cancel(order_id: 594853)
175
+ ```
176
+
177
+ ## Donations
4
178
 
179
+ If you find this library useful, considering sending a donation! My Dogecoin address is `DD7WjShc937XEmRbGzrCvxjAFAWKwMb9fi`.
@@ -67,7 +67,7 @@ module VaultOfSatoshi
67
67
  end
68
68
 
69
69
  def parse_currency_object(object)
70
- BigDecimal.new(object["value"]).round(object["precision"])
70
+ BigDecimal.new(object["value"]).truncate(object["precision"])
71
71
  end
72
72
 
73
73
  def parse_boolean(int)
@@ -1,3 +1,3 @@
1
1
  module VaultOfSatoshi
2
- VERSION = "0.9.0"
2
+ VERSION = "0.9.1"
3
3
  end
@@ -24,4 +24,42 @@ describe VaultOfSatoshi::API::Info do
24
24
  end
25
25
  end
26
26
 
27
+ describe "#balance" do
28
+ it "should return the expected fields" do
29
+ data = api_client.info.balance(currency: 'BTC')
30
+ data.should be_kind_of(BigDecimal)
31
+ end
32
+ end
33
+
34
+ describe "#wallet_address" do
35
+ it "should return the expected fields" do
36
+ data = api_client.info.wallet_address(currency: 'BTC')
37
+ data.to_h.keys.should include(:wallet_address, :currency)
38
+ end
39
+ end
40
+
41
+ describe "#ticker" do
42
+ it "should return the expected fields" do
43
+ data = api_client.info.ticker(order_currency: 'BTC', payment_currency: 'USD')
44
+ data.to_h.keys.should include(
45
+ :date, :opening_price, :closing_price, :min_price, :max_price,
46
+ :average_price, :units_traded, :volume_1day, :volume_7day
47
+ )
48
+ end
49
+ end
50
+
51
+ describe "#quote" do
52
+ it "should return the expected fields" do
53
+ data = api_client.info.quote(type: 'bid', order_currency: 'BTC', units: 1, payment_currency: 'USD', price: 10.0)
54
+ data.to_h.keys.should include(:rate, :subtotal, :fee, :total)
55
+ end
56
+ end
57
+
58
+ describe "#orderbook" do
59
+ it "should return the expected fields" do
60
+ data = api_client.info.orderbook(order_currency: 'BTC', payment_currency: 'USD')
61
+ data.to_h.keys.should include(:timestamp, :order_currency, :payment_currency, :bids, :asks)
62
+ end
63
+ end
64
+
27
65
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vault_of_satoshi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Bonetti