Class: Bitbankcc

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

Constant Summary collapse

@@base_url =
"https://api.bitbank.cc"
@@base_public_url =
"https://public.bitbank.cc"
@@ssl =
true

Instance Method Summary collapse

Constructor Details

#initialize(key = nil, secret = nil, params = {}) ⇒ Bitbankcc

Returns a new instance of Bitbankcc



15
16
17
18
19
20
21
22
23
24
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 15

def initialize(key = nil, secret = nil, params = {})
  @key = key
  @secret = secret
  if !params[:base_url].nil?
    @@base_url = params[:base_url]
  end
  if !params[:ssl].nil?
    @@ssl = params[:ssl]
  end
end

Instance Method Details

#cancel_order(pair, order_id) ⇒ Object



59
60
61
62
63
64
65
66
67
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 59

def cancel_order(pair, order_id)
  path = "/v1/user/spot/cancel_order"
  nonce = Time.now.to_i.to_s
  body = {
    pair: pair,
    order_id: order_id
  }.to_json
  request_for_post(path, nonce, body)
end

#create_order(pair, amount, price, side, type) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 46

def create_order(pair, amount, price, side, type)
  path = "/v1/user/spot/order"
  nonce = Time.now.to_i.to_s
  body = {
    pair: pair,
    amount: amount,
    price: price,
    side: side,
    type: type
  }.to_json
  request_for_post(path, nonce, body)
end

#read_active_orders(pair, count = nil, from_id = nil, end_id = nil, since = nil, _end = nil) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 32

def read_active_orders(pair, count = nil, from_id = nil, end_id = nil, since = nil, _end = nil)
  path = "/v1/user/spot/active_orders"
  nonce = Time.now.to_i.to_s
  params = {
    pair: pair,
    count: count,
    from_id: from_id,
    end_id: end_id,
    since: since,
    end: _end
  }.compact
  request_for_get(path, nonce, params)
end

#read_balanceObject



26
27
28
29
30
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 26

def read_balance
  path = "/v1/user/assets"
  nonce = Time.now.to_i.to_s
  request_for_get(path, nonce)
end

#read_order_books(pair) ⇒ Object



111
112
113
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 111

def read_order_books(pair)
  RestClient.get @@base_public_url + "/#{pair}/depth"
end

#read_ticker(pair) ⇒ Object



107
108
109
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 107

def read_ticker(pair)
  RestClient.get @@base_public_url + "/#{pair}/ticker"
end

#read_trade_history(pair, count = nil, order_id = nil, since = nil, _end = nil, order = nil) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 69

def read_trade_history(pair, count = nil, order_id = nil, since = nil, _end = nil, order = nil)
  path = "/v1/user/spot/trade_history"
  nonce = Time.now.to_i.to_s
  params = {
    pair: pair,
    count: count,
    order_id: order_id,
    since: since,
    end: _end,
    order: order
  }.compact

  request_for_get(path, nonce, params)
end

#read_transactions(pair, date = '') ⇒ Object



115
116
117
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 115

def read_transactions(pair, date = '')
  RestClient.get @@base_public_url + "/#{pair}/transactions" + (date.empty? ? '' : '/' + date)
end

#read_withdrawal_account(asset) ⇒ Object



84
85
86
87
88
89
90
91
92
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 84

def (asset)
  path = "/v1/user/withdrawal_account"
  nonce = Time.now.to_i.to_s
  params = {
    asset: asset
  }.compact

  request_for_get(path, nonce, params)
end

#request_withdrawal(asset, uuid, amount, otp_token = nil, sms_token = nil) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 94

def request_withdrawal(asset, uuid, amount, otp_token = nil, sms_token = nil)
  path = "/v1/user/request_withdrawal"
  nonce = Time.now.to_i.to_s
  body = {
    asset: asset,
    uuid: uuid,
    amount: amount,
    otp_token: otp_token,
    sms_token: sms_token
  }.compact.to_json
  request_for_post(path, nonce, body)
end