Class: Virtex::Client
Constant Summary collapse
- VIRTEX_SIGNIFICANT_DIGITS =
From 0.000000001 to 10,000,000
16
- BASE_URI =
'https://cavirtex.com/api2'
Instance Method Summary collapse
-
#balance ⇒ Object
Authenticated.
- #cancel_order!(id) ⇒ Object
-
#initialize(api_key = nil, api_secret = nil, options = {}) ⇒ Client
constructor
A new instance of Client.
- #new_order!(mode, amount, currencypair, price, opts = {}) ⇒ Object
-
#orderbook(currencypair) ⇒ Object
Unauthenticated.
- #orders(opts = {}) ⇒ Object
- #ticker(currencypair) ⇒ Object
- #tradebook(currencypair, opts = {}) ⇒ Object
- #trades(opts = {}) ⇒ Object
- #transactions(currency, opts = {}) ⇒ Object
- #withdraw!(amount, currency, address) ⇒ Object
Constructor Details
#initialize(api_key = nil, api_secret = nil, options = {}) ⇒ Client
Returns a new instance of Client.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/virtex/client.rb', line 12 def initialize(api_key=nil, api_secret=nil, ={}) @api_key = api_key @api_secret = api_secret # defaults [:base_uri] ||= BASE_URI @base_uri = [:base_uri] .each do |k,v| self.class.send k, v end end |
Instance Method Details
#balance ⇒ Object
Authenticated
43 44 45 |
# File 'lib/virtex/client.rb', line 43 def balance do_request '/user/balance.json' end |
#cancel_order!(id) ⇒ Object
74 75 76 |
# File 'lib/virtex/client.rb', line 74 def cancel_order! id do_request '/user/order_cancel.json', { post: { 'id' => id } } end |
#new_order!(mode, amount, currencypair, price, opts = {}) ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/virtex/client.rb', line 63 def new_order! mode, amount, currencypair, price, opts = {} params = { 'mode' => mode, 'amount' => amount, 'price' => price, 'currencypair' => currencypair }.merge(opts) do_request '/user/order.json', { post: params } end |
#orderbook(currencypair) ⇒ Object
Unauthenticated
26 27 28 |
# File 'lib/virtex/client.rb', line 26 def orderbook currencypair do_request '/orderbook.json', { get: { 'currencypair' => currencypair } } end |
#orders(opts = {}) ⇒ Object
47 48 49 |
# File 'lib/virtex/client.rb', line 47 def orders opts = {} do_request '/user/orders.json', { post: opts } end |
#ticker(currencypair) ⇒ Object
37 38 39 |
# File 'lib/virtex/client.rb', line 37 def ticker currencypair do_request '/ticker.json', { get: { 'currencypair' => currencypair } } end |
#tradebook(currencypair, opts = {}) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/virtex/client.rb', line 30 def tradebook currencypair, opts = {} params = { 'currencypair' => currencypair }.merge(opts) do_request '/trades.json', { get: params } end |
#trades(opts = {}) ⇒ Object
51 52 53 |
# File 'lib/virtex/client.rb', line 51 def trades opts = {} do_request '/user/trades.json', { post: opts } end |
#transactions(currency, opts = {}) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/virtex/client.rb', line 55 def transactions currency, opts = {} params = { 'currency' => currency }.merge(opts) do_request '/user/transactions.json', { post: params } end |
#withdraw!(amount, currency, address) ⇒ Object
78 79 80 81 82 83 84 85 |
# File 'lib/virtex/client.rb', line 78 def withdraw! amount, currency, address params = { 'amount' => amount, 'currency' => currency, 'address' => address } do_request '/user/withdraw.json', { post: params } end |