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



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

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, post_only = false, trigger_price = nil) ⇒ Object



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

def create_order(pair, amount, price, side, type, post_only = false, trigger_price = nil)
  path = "/v1/user/spot/order"
  nonce = Time.now.to_i.to_s
  body = {
    pair: pair,
    amount: amount,
    price: price,
    side: side,
    type: type,
    post_only: post_only,
    trigger_price: trigger_price
  }.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_circuit_break_info(pair) ⇒ Object



149
150
151
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 149

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

#read_deposit_history(asset, count = nil, since = nil, _end = nil, order = nil) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 86

def read_deposit_history(asset, count = nil, since = nil, _end = nil, order = nil)
  path = "/v1/user/deposit_history"
  nonce = Time.now.to_i.to_s
  params = {
    asset: asset,
    count: count,
    since: since,
    end: _end,
    order: order
  }.compact

  request_for_get(path, nonce, params)
end

#read_order_books(pair) ⇒ Object



141
142
143
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 141

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

#read_ticker(pair) ⇒ Object



137
138
139
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 137

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



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

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



145
146
147
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 145

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

#read_withdrawal_account(asset) ⇒ Object



100
101
102
103
104
105
106
107
108
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 100

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

#read_withdrawal_history(asset, count = nil, since = nil, _end = nil, order = nil) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 123

def read_withdrawal_history(asset, count = nil, since = nil, _end = nil, order = nil)
  path = "/v1/user/withdrawal_history"
  nonce = Time.now.to_i.to_s
  params = {
    asset: asset,
    count: count,
    since: since,
    end: _end,
    order: order
  }.compact

  request_for_get(path, nonce, params)
end

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



110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 110

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