Class: Bitbankcc
- Inherits:
-
Object
- Object
- Bitbankcc
- 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
- #cancel_order(pair, order_id) ⇒ Object
- #create_order(pair, amount, price, side, type, post_only = false, trigger_price = nil) ⇒ Object
-
#initialize(key = nil, secret = nil, params = {}) ⇒ Bitbankcc
constructor
A new instance of Bitbankcc.
- #read_active_orders(pair, count = nil, from_id = nil, end_id = nil, since = nil, _end = nil) ⇒ Object
- #read_balance ⇒ Object
- #read_circuit_break_info(pair) ⇒ Object
- #read_deposit_history(asset, count = nil, since = nil, _end = nil, order = nil) ⇒ Object
- #read_order_books(pair) ⇒ Object
- #read_ticker(pair) ⇒ Object
- #read_trade_history(pair, count = nil, order_id = nil, since = nil, _end = nil, order = nil) ⇒ Object
- #read_transactions(pair, date = '') ⇒ Object
- #read_withdrawal_account(asset) ⇒ Object
- #read_withdrawal_history(asset, count = nil, since = nil, _end = nil, order = nil) ⇒ Object
- #request_withdrawal(asset, uuid, amount, otp_token = nil, sms_token = nil) ⇒ Object
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
69 70 71 72 73 74 75 76 77 |
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 69 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) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 54 def create_order(pair, amount, price, side, type, post_only = false, trigger_price = 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 }.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_balance ⇒ Object
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_circuit_break_info(pair) ⇒ Object
157 158 159 |
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 157 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
94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 94 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_order_books(pair) ⇒ Object
149 150 151 |
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 149 def read_order_books(pair) RestClient.get @@base_public_url + "/#{pair}/depth" end |
#read_ticker(pair) ⇒ Object
145 146 147 |
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 145 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
79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 79 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
153 154 155 |
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 153 def read_transactions(pair, date = '') RestClient.get @@base_public_url + "/#{pair}/transactions" + (date.empty? ? '' : '/' + date) end |
#read_withdrawal_account(asset) ⇒ Object
108 109 110 111 112 113 114 115 116 |
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 108 def read_withdrawal_account(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
131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 131 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
118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/ruby_bitbankcc/bitbankcc.rb', line 118 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 |