Class: Bitfex::Api
- Inherits:
-
Object
- Object
- Bitfex::Api
- Defined in:
- lib/bitfex/api.rb
Instance Attribute Summary collapse
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
-
#balances ⇒ Hash<String, Fixnum>
Return account balances.
-
#create_order(operation, pair, amount, price) ⇒ TrueClass
Create new order.
-
#delete_order(id) ⇒ TrueClass
Delete order by id.
-
#initialize(token: nil, server_url: 'https://bitfex.trade') ⇒ Api
constructor
A new instance of Api.
-
#my_orders ⇒ Array<Hash>
Return list of my orders.
-
#orders_list(pair) ⇒ Array<Hash>
Return list of orders for all pairs.
-
#server_url ⇒ String
Server url.
- #server_url=(url) ⇒ Object
Constructor Details
#initialize(token: nil, server_url: 'https://bitfex.trade') ⇒ Api
Returns a new instance of Api.
10 11 12 13 |
# File 'lib/bitfex/api.rb', line 10 def initialize(token: nil, server_url: 'https://bitfex.trade') @token = token @_server_url = server_url end |
Instance Attribute Details
#token ⇒ Object
Returns the value of attribute token.
6 7 8 |
# File 'lib/bitfex/api.rb', line 6 def token @token end |
Instance Method Details
#balances ⇒ Hash<String, Fixnum>
Return account balances
27 28 29 30 31 32 |
# File 'lib/bitfex/api.rb', line 27 def balances response = request_get('/api/v1/user') raise ApiError.new(response['errors'].to_json) unless response['success'] response['balances'] end |
#create_order(operation, pair, amount, price) ⇒ TrueClass
Create new order
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/bitfex/api.rb', line 67 def create_order(operation, pair, amount, price) response = request_post( '/api/v1/orders', order: { pair: pair, operation: operation, amount: amount, price: price } ) raise ApiError.new(response['error'].to_json) unless response['success'] true end |
#delete_order(id) ⇒ TrueClass
Delete order by id
54 55 56 57 58 |
# File 'lib/bitfex/api.rb', line 54 def delete_order(id) response = request_delete("/api/v1/orders/#{id}") raise ApiError.new(response['errors'].to_json) unless response['success'] true end |
#my_orders ⇒ Array<Hash>
Return list of my orders
44 45 46 47 48 |
# File 'lib/bitfex/api.rb', line 44 def my_orders response = request_get('/api/v1/orders/my') raise ApiError.new(response['errors'].to_json) unless response['success'] response['orders'] end |
#orders_list(pair) ⇒ Array<Hash>
Return list of orders for all pairs
36 37 38 39 40 |
# File 'lib/bitfex/api.rb', line 36 def orders_list(pair) response = request_get("/api/v1/orders?pair=#{pair}") raise ApiError.new(response['errors'].to_json) unless response['success'] response['orders'] end |
#server_url ⇒ String
Returns server url.
16 17 18 |
# File 'lib/bitfex/api.rb', line 16 def server_url @_server_url end |
#server_url=(url) ⇒ Object
21 22 23 |
# File 'lib/bitfex/api.rb', line 21 def server_url=(url) @_server_url = url end |