Class: Abucoins::API

Inherits:
Object
  • Object
show all
Defined in:
lib/abucoins/abucoins.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(passphrase:, key:, secret:, url: 'https://api.abucoins.com') ⇒ API

Returns a new instance of API.

[View source]

12
13
14
15
16
17
# File 'lib/abucoins/abucoins.rb', line 12

def initialize(passphrase:, key:, secret:, url: 'https://api.abucoins.com')
  @passphrase = passphrase
  @key = key
  @secret = secret
  @url = url
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.


7
8
9
# File 'lib/abucoins/abucoins.rb', line 7

def key
  @key
end

#passphraseObject (readonly)

Returns the value of attribute passphrase.


7
8
9
# File 'lib/abucoins/abucoins.rb', line 7

def passphrase
  @passphrase
end

#secretObject (readonly)

Returns the value of attribute secret.


7
8
9
# File 'lib/abucoins/abucoins.rb', line 7

def secret
  @secret
end

#urlObject (readonly)

Returns the value of attribute url.


7
8
9
# File 'lib/abucoins/abucoins.rb', line 7

def url
  @url
end

Instance Method Details

#accountsObject

[View source]

58
59
60
# File 'lib/abucoins/abucoins.rb', line 58

def accounts
  get('/accounts')
end

#cancel_order(id) ⇒ Object

[View source]

54
55
56
# File 'lib/abucoins/abucoins.rb', line 54

def cancel_order(id)
  delete("/orders/#{id}")
end

#create_order(side:, hidden: false, time_in_force: nil, size:, price:, product_id:, type: 'limit', cancel_after: nil, post_only: nil) ⇒ Object

[View source]

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/abucoins/abucoins.rb', line 35

def create_order(side:, hidden: false, time_in_force: nil, size:, price:, product_id:, type: 'limit', cancel_after: nil, post_only: nil)
  opts = {
    side: side,
    hidden: hidden,
    size: size,
    price: price,
    product_id: product_id,
    type: type
  }
  opts[:time_in_force] = time_in_force unless time_in_force.nil?
  opts[:cancel_after] = cancel_after unless cancel_after.nil?
  opts[:post_only] = post_only unless post_only.nil?
  order = post('/orders', opts)

  raise Abucoins::CreateOrderException.new(order['error'] || order['message']) unless order['id']

  order
end

#deposits(opts = {}) ⇒ Object

[View source]

79
80
81
# File 'lib/abucoins/abucoins.rb', line 79

def deposits(opts={})
  get('/deposits/history', opts)
end

#deposits_crypto(currency:, method:) ⇒ Object

[View source]

62
63
64
65
66
67
# File 'lib/abucoins/abucoins.rb', line 62

def deposits_crypto(currency:, method:)
  post('/deposits/crypto', {
    currency: currency,
    method: method
  })
end

#fills(args = nil) ⇒ Object

[View source]

31
32
33
# File 'lib/abucoins/abucoins.rb', line 31

def fills(args = nil)
  get('/fills', params: args)
end

#order(id) ⇒ Object

[View source]

27
28
29
# File 'lib/abucoins/abucoins.rb', line 27

def order(id)
  get("/orders/#{id}")
end

#orders(args = {}) ⇒ Object

[View source]

23
24
25
# File 'lib/abucoins/abucoins.rb', line 23

def orders(args = {})
  get('/orders', params: args)
end

#productsObject

[View source]

19
20
21
# File 'lib/abucoins/abucoins.rb', line 19

def products
  get('/products')
end

#withdrawals(opts = {}) ⇒ Object

[View source]

83
84
85
# File 'lib/abucoins/abucoins.rb', line 83

def withdrawals(opts={})
  get('/withdrawals/history', opts)
end

#withdrawals_crypto(amount:, currency:, method:, address:, tag: nil) ⇒ Object

[View source]

69
70
71
72
73
74
75
76
77
# File 'lib/abucoins/abucoins.rb', line 69

def withdrawals_crypto(amount:, currency:, method:, address:, tag: nil)
  post('/withdrawals/crypto', {
    amount: amount,
    currency: currency,
    method: method,
    address: address,
    tag: tag,
  })
end