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"
@@auth_method =
"request_time"
@@time_window =
5000
@@ssl =
true

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Bitbankcc.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 17

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

Instance Method Details

#cancel_order(pair, order_id) ⇒ Object



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

def cancel_order(pair, order_id)
  path = "/v1/user/spot/cancel_order"
  nonce = get_current_milisec
  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, position_side = nil) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 60

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



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 40

def read_active_orders(pair, count = nil, from_id = nil, end_id = nil, since = nil, _end = nil)
  path = "/v1/user/spot/active_orders"
  nonce = get_current_milisec
  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



34
35
36
37
38
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 34

def read_balance
  path = "/v1/user/assets"
  nonce = get_current_milisec
  request_for_get(path, nonce)
end

#read_candlestick(pair, candle_type, date) ⇒ Object



170
171
172
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 170

def read_candlestick(pair, candle_type, date)
  RestClient.get @@base_public_url + "/#{pair}/candlestick/#{candle_type}/#{date}"
end

#read_circuit_break_info(pair) ⇒ Object



174
175
176
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 174

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



101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 101

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

  request_for_get(path, nonce, params)
end

#read_margin_positionsObject



54
55
56
57
58
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 54

def read_margin_positions()
  path = "/v1/user/margin/positions"
  nonce = get_current_milisec
  request_for_get(path, nonce)
end

#read_order_books(pair) ⇒ Object



162
163
164
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 162

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

#read_ticker(pair) ⇒ Object



158
159
160
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 158

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



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

def read_trade_history(pair, count = nil, order_id = nil, since = nil, _end = nil, order = nil)
  path = "/v1/user/spot/trade_history"
  nonce = get_current_milisec
  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



166
167
168
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 166

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

#read_user_subscribeObject



152
153
154
155
156
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 152

def read_user_subscribe()
  path = "/v1/user/subscribe"
  nonce = get_current_milisec
  request_for_get(path, nonce)
end

#read_withdrawal_account(asset) ⇒ Object



115
116
117
118
119
120
121
122
123
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 115

def (asset)
  path = "/v1/user/withdrawal_account"
  nonce = get_current_milisec
  params = {
    asset: asset
  }.compact

  request_for_get(path, nonce, params)
end

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



138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 138

def read_withdrawal_history(asset, count = nil, since = nil, _end = nil, order = nil)
  path = "/v1/user/withdrawal_history"
  nonce = get_current_milisec
  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



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

def request_withdrawal(asset, uuid, amount, otp_token = nil, sms_token = nil)
  path = "/v1/user/request_withdrawal"
  nonce = get_current_milisec
  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