excoin 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +32 -0
  3. data/Gemfile +13 -0
  4. data/LICENSE.txt +674 -0
  5. data/README.md +278 -0
  6. data/Rakefile +9 -0
  7. data/config/config.example.yml +16 -0
  8. data/excoin.gemspec +26 -0
  9. data/lib/account/account.rb +116 -0
  10. data/lib/account/deposit.rb +20 -0
  11. data/lib/account/order.rb +43 -0
  12. data/lib/account/orders.rb +138 -0
  13. data/lib/account/trade.rb +26 -0
  14. data/lib/account/trades.rb +59 -0
  15. data/lib/account/wallet.rb +72 -0
  16. data/lib/account/withdrawal.rb +27 -0
  17. data/lib/exchange/candlestick_chart.rb +33 -0
  18. data/lib/exchange/candlestick_data.rb +20 -0
  19. data/lib/exchange/exchange.rb +75 -0
  20. data/lib/exchange/market.rb +50 -0
  21. data/lib/exchange/order.rb +23 -0
  22. data/lib/exchange/order_depth_chart.rb +41 -0
  23. data/lib/exchange/order_depth_data.rb +23 -0
  24. data/lib/exchange/orders.rb +119 -0
  25. data/lib/exchange/trade.rb +26 -0
  26. data/lib/exchange/trades.rb +68 -0
  27. data/lib/excoin.rb +45 -0
  28. data/lib/excoin/api.rb +212 -0
  29. data/lib/excoin/version.rb +10 -0
  30. data/spec/fixtures/cassette_library/account_cancel_order_erb.yml +59 -0
  31. data/spec/fixtures/cassette_library/account_issue_order_erb.yml +59 -0
  32. data/spec/fixtures/cassette_library/account_view_order_erb.yml +59 -0
  33. data/spec/fixtures/cassette_library/exc_recent_trades.yml +157 -0
  34. data/spec/fixtures/cassette_library/exc_recent_trades_count.yml +62 -0
  35. data/spec/fixtures/cassette_library/exc_recent_trades_timestamp.yml +142 -0
  36. data/spec/fixtures/cassette_library/exchange_candlestick_chart_data.yml +58 -0
  37. data/spec/fixtures/cassette_library/exchange_candlestick_chart_data_duration.yml +58 -0
  38. data/spec/fixtures/cassette_library/exchange_open_orders.yml +58 -0
  39. data/spec/fixtures/cassette_library/exchange_open_orders_type.yml +58 -0
  40. data/spec/fixtures/cassette_library/exchange_order_depth_chart_data.yml +58 -0
  41. data/spec/fixtures/cassette_library/excoin_wallet_reserves.yml +59 -0
  42. data/spec/fixtures/cassette_library/excoin_wallets_summary.yml +65 -0
  43. data/spec/fixtures/cassette_library/excoin_wallets_summary_coin.yml +59 -0
  44. data/spec/fixtures/cassette_library/multi_exchange_summ.yml +58 -0
  45. data/spec/fixtures/cassette_library/multi_exchange_summ_currency.yml +58 -0
  46. data/spec/fixtures/cassette_library/single_exchange_summ.yml +58 -0
  47. data/spec/fixtures/cassette_library/single_exchange_summary.yml +58 -0
  48. data/spec/lib/account/account_spec.rb +136 -0
  49. data/spec/lib/account/orders_spec.rb +51 -0
  50. data/spec/lib/account/trades_spec.rb +52 -0
  51. data/spec/lib/account/wallet_spec.rb +67 -0
  52. data/spec/lib/exchange/candlestick_chart_spec.rb +23 -0
  53. data/spec/lib/exchange/exchange_spec.rb +38 -0
  54. data/spec/lib/exchange/market_spec.rb +23 -0
  55. data/spec/lib/exchange/order_depth_chart_spec.rb +20 -0
  56. data/spec/lib/exchange/orders_spec.rb +47 -0
  57. data/spec/lib/exchange/trades_spec.rb +50 -0
  58. data/spec/lib/excoin/api_spec.rb +228 -0
  59. data/spec/lib/excoin_spec.rb +28 -0
  60. data/spec/spec_helper.rb +46 -0
  61. data/spec/support/vcr.rb +21 -0
  62. metadata +209 -0
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe Excoin do
4
+ subject {Excoin}
5
+
6
+ it "returns Excoin::Account object"
7
+ # cli = subject.account
8
+ # expect cli.name.class.to eq String
9
+ # end
10
+
11
+ it "returns Excoin::Market::Exchange object"
12
+ # cli = subject.exchange
13
+ # # something to prove this works
14
+ # end
15
+
16
+ it "returns Excoin::Market object"
17
+ # cli = subject.market
18
+ # # something to prove this works
19
+ # end
20
+
21
+ it "as a function"
22
+ # cli = subject.api
23
+ # expect(cli.class).to eq(Excoin::API)
24
+ # something to prove this works
25
+ # end
26
+
27
+
28
+ end
@@ -0,0 +1,46 @@
1
+ require 'yaml'
2
+ require 'json'
3
+ require 'webmock/rspec'
4
+ require 'vcr'
5
+
6
+ require File.expand_path('../lib/excoin.rb', File.dirname(__FILE__))
7
+ Dir[File.expand_path("support/**/*.rb", File.dirname(__FILE__))].each { |f| require f }
8
+
9
+ # API settings
10
+ config = YAML::load_file(File.expand_path('../../config/config.yml', __FILE__))
11
+ $api_key = config["API_key"]
12
+ $currency = "BTC"
13
+ $commodity = "BLK"
14
+ $type = "BID"
15
+ $count = 25
16
+
17
+ VCR.use_cassette("account_summary", match_requests_on: [:method, :uri_without_timestamp]) do
18
+ account = Excoin.api.account_summary
19
+ wallet = account["active_wallets"].select{ |h| h["currency"] == $currency }.first
20
+ $amount = wallet["available_balance"]
21
+ $address = wallet["address"]
22
+ VCR.use_cassette("single_exchange_summary", match_requests_on: [:method, :uri_without_timestamp]) do
23
+ if $type == "BID"
24
+ $price = Excoin.api.exchange_summary($currency, $commodity)["top_bid"]
25
+ else
26
+ $price = Excoin.api.exchange_summary($currency, $commodity)["lowest_ask"]
27
+ end
28
+ end
29
+ end
30
+
31
+ VCR.use_cassette("account_view_order", match_requests_on: [:method, :uri_without_timestamp], record: :new_episodes) do
32
+ orders = Excoin.api.account_open_orders($currency, $commodity)
33
+ $order = orders['orders'].first['orders'].first
34
+ $order_id = $order['id']
35
+ $order_data = JSON.parse('{"id":"BTC-BLK-BID-NewOrderlKmc4gDXKc","timestamp":"2014-07-21 19:06:45 UTC","type":"BID","price":"0.00035","commodity_amount":"4.5","currency_amount":"0.00157500","status":"pending"}')
36
+ end
37
+
38
+ # Trade test data
39
+ $trade_data = JSON.parse('{"action":"trade","timestamp":"2014-07-21 19:06:45 UTC","unix_timestamp":"1405969605","currency":"BTC","currency_name":"Bitcoin","commodity":"BLK","commodity_name":"Blackcoin","type":"BUY","price":"0.00000032","sent":"0.09478962","received":"412128.80177019","fee":"618.19320265","net_received":"411510.60856753"}')
40
+ $exchange_trade_data = JSON.parse('{"action":"trade","timestamp":"2014-07-21 19:06:45 UTC","unix_timestamp":"1405969605","type":"BUY","price":"0.00000032","currency_amount":"0.09478962","commodity_amount":"412128.80177019"}')
41
+
42
+ RSpec.configure do |c|
43
+ c.color = true
44
+ end
45
+
46
+
@@ -0,0 +1,21 @@
1
+ require 'vcr'
2
+
3
+ VCR.configure do |c|
4
+ c.cassette_library_dir = 'spec/fixtures/cassette_library'
5
+ c.hook_into :webmock
6
+ c.allow_http_connections_when_no_cassette = true
7
+ c.default_cassette_options = { :record => :once }
8
+ c.configure_rspec_metadata!
9
+
10
+ c.register_request_matcher :uri_without_timestamp do |request_1, request_2|
11
+ uri1, uri2 = request_1.uri, request_2.uri
12
+ timestamp_suffix = %r(\?expire=\d+\z)
13
+ if uri1.match(timestamp_suffix)
14
+ r1_without_id = uri1.gsub(timestamp_suffix, "")
15
+ r2_without_id = uri2.gsub(timestamp_suffix, "")
16
+ uri1.match(timestamp_suffix) && uri2.match(timestamp_suffix) && r1_without_id == r2_without_id
17
+ else
18
+ uri1 == uri2
19
+ end
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,209 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: excoin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - YT
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-19 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.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.1'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: webmock
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 1.20.4
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 1.20.4
69
+ - !ruby/object:Gem::Dependency
70
+ name: vcr
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 2.9.3
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 2.9.3
83
+ description: Excoin wrapper provides all the basic API functionality with an additional
84
+ abstraction to make accessing the data easier and more efficient. This will be used
85
+ as a library for writing bots for the Excoin crypto currency exchange.
86
+ email:
87
+ - yt@exco.in
88
+ executables: []
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - ".gitignore"
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - config/config.example.yml
98
+ - excoin.gemspec
99
+ - lib/account/account.rb
100
+ - lib/account/deposit.rb
101
+ - lib/account/order.rb
102
+ - lib/account/orders.rb
103
+ - lib/account/trade.rb
104
+ - lib/account/trades.rb
105
+ - lib/account/wallet.rb
106
+ - lib/account/withdrawal.rb
107
+ - lib/exchange/candlestick_chart.rb
108
+ - lib/exchange/candlestick_data.rb
109
+ - lib/exchange/exchange.rb
110
+ - lib/exchange/market.rb
111
+ - lib/exchange/order.rb
112
+ - lib/exchange/order_depth_chart.rb
113
+ - lib/exchange/order_depth_data.rb
114
+ - lib/exchange/orders.rb
115
+ - lib/exchange/trade.rb
116
+ - lib/exchange/trades.rb
117
+ - lib/excoin.rb
118
+ - lib/excoin/api.rb
119
+ - lib/excoin/version.rb
120
+ - spec/fixtures/cassette_library/account_cancel_order_erb.yml
121
+ - spec/fixtures/cassette_library/account_issue_order_erb.yml
122
+ - spec/fixtures/cassette_library/account_view_order_erb.yml
123
+ - spec/fixtures/cassette_library/exc_recent_trades.yml
124
+ - spec/fixtures/cassette_library/exc_recent_trades_count.yml
125
+ - spec/fixtures/cassette_library/exc_recent_trades_timestamp.yml
126
+ - spec/fixtures/cassette_library/exchange_candlestick_chart_data.yml
127
+ - spec/fixtures/cassette_library/exchange_candlestick_chart_data_duration.yml
128
+ - spec/fixtures/cassette_library/exchange_open_orders.yml
129
+ - spec/fixtures/cassette_library/exchange_open_orders_type.yml
130
+ - spec/fixtures/cassette_library/exchange_order_depth_chart_data.yml
131
+ - spec/fixtures/cassette_library/excoin_wallet_reserves.yml
132
+ - spec/fixtures/cassette_library/excoin_wallets_summary.yml
133
+ - spec/fixtures/cassette_library/excoin_wallets_summary_coin.yml
134
+ - spec/fixtures/cassette_library/multi_exchange_summ.yml
135
+ - spec/fixtures/cassette_library/multi_exchange_summ_currency.yml
136
+ - spec/fixtures/cassette_library/single_exchange_summ.yml
137
+ - spec/fixtures/cassette_library/single_exchange_summary.yml
138
+ - spec/lib/account/account_spec.rb
139
+ - spec/lib/account/orders_spec.rb
140
+ - spec/lib/account/trades_spec.rb
141
+ - spec/lib/account/wallet_spec.rb
142
+ - spec/lib/exchange/candlestick_chart_spec.rb
143
+ - spec/lib/exchange/exchange_spec.rb
144
+ - spec/lib/exchange/market_spec.rb
145
+ - spec/lib/exchange/order_depth_chart_spec.rb
146
+ - spec/lib/exchange/orders_spec.rb
147
+ - spec/lib/exchange/trades_spec.rb
148
+ - spec/lib/excoin/api_spec.rb
149
+ - spec/lib/excoin_spec.rb
150
+ - spec/spec_helper.rb
151
+ - spec/support/vcr.rb
152
+ homepage: https://exco.in
153
+ licenses:
154
+ - GPL
155
+ metadata: {}
156
+ post_install_message:
157
+ rdoc_options: []
158
+ require_paths:
159
+ - lib
160
+ - config
161
+ required_ruby_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ required_rubygems_version: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ version: '0'
171
+ requirements: []
172
+ rubyforge_project:
173
+ rubygems_version: 2.2.2
174
+ signing_key:
175
+ specification_version: 4
176
+ summary: A sophisticiated ruby wrapper for the excoin crypto currency exchange.
177
+ test_files:
178
+ - spec/fixtures/cassette_library/account_cancel_order_erb.yml
179
+ - spec/fixtures/cassette_library/account_issue_order_erb.yml
180
+ - spec/fixtures/cassette_library/account_view_order_erb.yml
181
+ - spec/fixtures/cassette_library/exc_recent_trades.yml
182
+ - spec/fixtures/cassette_library/exc_recent_trades_count.yml
183
+ - spec/fixtures/cassette_library/exc_recent_trades_timestamp.yml
184
+ - spec/fixtures/cassette_library/exchange_candlestick_chart_data.yml
185
+ - spec/fixtures/cassette_library/exchange_candlestick_chart_data_duration.yml
186
+ - spec/fixtures/cassette_library/exchange_open_orders.yml
187
+ - spec/fixtures/cassette_library/exchange_open_orders_type.yml
188
+ - spec/fixtures/cassette_library/exchange_order_depth_chart_data.yml
189
+ - spec/fixtures/cassette_library/excoin_wallet_reserves.yml
190
+ - spec/fixtures/cassette_library/excoin_wallets_summary.yml
191
+ - spec/fixtures/cassette_library/excoin_wallets_summary_coin.yml
192
+ - spec/fixtures/cassette_library/multi_exchange_summ.yml
193
+ - spec/fixtures/cassette_library/multi_exchange_summ_currency.yml
194
+ - spec/fixtures/cassette_library/single_exchange_summ.yml
195
+ - spec/fixtures/cassette_library/single_exchange_summary.yml
196
+ - spec/lib/account/account_spec.rb
197
+ - spec/lib/account/orders_spec.rb
198
+ - spec/lib/account/trades_spec.rb
199
+ - spec/lib/account/wallet_spec.rb
200
+ - spec/lib/exchange/candlestick_chart_spec.rb
201
+ - spec/lib/exchange/exchange_spec.rb
202
+ - spec/lib/exchange/market_spec.rb
203
+ - spec/lib/exchange/order_depth_chart_spec.rb
204
+ - spec/lib/exchange/orders_spec.rb
205
+ - spec/lib/exchange/trades_spec.rb
206
+ - spec/lib/excoin/api_spec.rb
207
+ - spec/lib/excoin_spec.rb
208
+ - spec/spec_helper.rb
209
+ - spec/support/vcr.rb