Class: Vexapion::Coincheck

Inherits:
BaseExchanges show all
Defined in:
lib/vexapion/coincheck.rb

Overview

coincheckのAPIラッパークラスです。各メソッドの戻り値は下記URLを参照してください。

Instance Method Summary collapse

Methods inherited from BaseExchanges

#do_command, #error_check, #get_nonce, #set_min_interval, #set_verify_mode

Constructor Details

#initialize(key = nil, secret = nil) ⇒ Coincheck

Returns a new instance of Coincheck.



13
14
15
16
17
18
19
# File 'lib/vexapion/coincheck.rb', line 13

def initialize(key = nil, secret = nil)
	super(key, secret)

	@public_url = "https://coincheck.com/api/"
	@private_url = "https://coincheck.com/api/"
	set_verify_mode(OpenSSL::SSL::VERIFY_NONE)
end

Instance Method Details

#accountsHash

アカウント情報

Returns:

  • (Hash)


295
296
297
# File 'lib/vexapion/coincheck.rb', line 295

def accounts
	get('accounts')
end

#balanceHash

残高

Returns:

  • (Hash)


254
255
256
# File 'lib/vexapion/coincheck.rb', line 254

def balance
	get('accounts/balance')
end

#bank_accountsHash

銀行口座一覧

Returns:

  • (Hash)


304
305
306
# File 'lib/vexapion/coincheck.rb', line 304

def bank_accounts
	get('bank_accounts')
end

#bank_withdraw(id, amount, currency = 'JPY', is_fast = false) ⇒ Hash

日本円出金申請

Parameters:

  • id (Integer)

    銀行口座一覧のID

  • amount (Integer)

    金額

  • currency (String) (defaults to: 'JPY')

    通貨名 現在はJPYのみ。省略時デフォルト‘JPY’

  • is_fast (Boolean) (defaults to: false)

    高速出金オプション 省略時デフォルトはfalse

Returns:

  • (Hash)


346
347
348
349
350
351
352
353
354
355
# File 'lib/vexapion/coincheck.rb', line 346

def bank_withdraw(id, amount, currency = 'JPY', is_fast = false)
	params = {
		'bank_account_id' => id,
		'amount'   => amount,
		'currency' => currency,
		'is_fast'  => is_fast
	}

	post('withdraws', params)
end

#bank_withdraw_historyHash

日本円出金履歴

Returns:

  • (Hash)


336
337
338
# File 'lib/vexapion/coincheck.rb', line 336

def bank_withdraw_history
	get('withdraws')
end

#borrow(currency, amount) ⇒ Hash

借入申請

Parameters:

  • currency (String)

    借りたい通貨

  • amount (Float)

    借りたい量

Returns:

  • (Hash)


370
371
372
373
374
# File 'lib/vexapion/coincheck.rb', line 370

def borrow(currency, amount)
	params = { 'amount' => amount, 'currency' => currency }

	post('lending/borrows', params)
end

#borrow_listHash

借入中一覧

Returns:

  • (Hash)


378
379
380
# File 'lib/vexapion/coincheck.rb', line 378

def borrow_list
	get('lending/borrows/matches')
end

#cancel(id) ⇒ Hash

注文のキャンセル

Parameters:

  • id (Integer)

    キャンセルしたい注文ID

Returns:

  • (Hash)


227
228
229
# File 'lib/vexapion/coincheck.rb', line 227

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

#cancel_bank_withdraw(id) ⇒ Hash

日本円出金申請のキャンセル

Parameters:

  • id (Integer)

    出金申請のID

Returns:

  • (Hash)


360
361
362
# File 'lib/vexapion/coincheck.rb', line 360

def cancel_bank_withdraw(id)
	delete("withdraws/#{id}")
end

#close_position(pair, close_position, position_id, rate, amount) ⇒ Hash

レバレッジ決済売買

Parameters:

  • pair (String)

    現在は‘btc_jpy’のみ

  • close_position (String)

    ‘long’ or ‘short’

  • position_id (Integer)

    ポジションID

  • rate (Integer)

    注文のレート 例28000

  • amount (Float)

    注文での量 例0.1

Returns:

  • (Hash)


187
188
189
190
191
192
193
194
195
196
197
# File 'lib/vexapion/coincheck.rb', line 187

def close_position(pair, close_position, position_id, rate, amount)
	params = {
		'pair'        => pair.downcase,
		'order_type'  => "close_#{close_position.downcase}",
		'position_id' => position_id.to_i,
		'rate'        => rate.to_f,
		'amount'      => amount.to_f
	}

	post('exchange/orders', params) 
end

#close_position_market_order(pair, close_position, position_id, amount) ⇒ Hash Also known as: close_position_without_limit

レバレッジ決済取引(成行)

Parameters:

  • pair (String)

    現在は‘btc_jpy’のみ

  • close_position (String)

    ‘long’ or ‘short’

  • position_id (Integer)

    ポジションID

  • amount (Float)

    注文での量 例0.1

Returns:

  • (Hash)


205
206
207
208
209
210
211
212
213
214
# File 'lib/vexapion/coincheck.rb', line 205

def close_position_market_order(pair, close_position, position_id, amount)
	params = {
		'pair'        => pair.downcase,
		'order_type'  => "close_#{close_position.downcase}",
		'position_id' => position_id.to_i,
		'amount'      => amount.to_f
	}

	post('exchange/orders', params)
end

#delete_bank_account(id) ⇒ Hash

銀行口座の削除

Parameters:

  • id (Integer)

    銀行口座一覧のID

Returns:

  • (Hash)


330
331
332
# File 'lib/vexapion/coincheck.rb', line 330

def (id)
	delete("bank_accounts/#{id}")
end

#deposit_accelerate(id) ⇒ Hash

ビットコインの高速入金

Parameters:

  • id (Integer)

    高速入金させたいビットコイン受取履歴のID

Returns:

  • (Hash)


289
290
291
# File 'lib/vexapion/coincheck.rb', line 289

def deposit_accelerate(id)
	post("deposit_money/#{id}/fast")
end

#deposit_history(currency = 'BTC') ⇒ Hash

ビットコイン受取履歴

Parameters:

  • currency (String) (defaults to: 'BTC')

    現在はBTCのみ対応。省略時のデフォルトはBTC

Returns:

  • (Hash)


282
283
284
# File 'lib/vexapion/coincheck.rb', line 282

def deposit_history(currency = 'BTC')
	get('deposit_money', 'currency' =>  currency)
end

#from_leverage(currency, amount) ⇒ Hash

レバレッジアカウントから振替

Parameters:

  • currency (String)

    通貨 現在はJPYのみ

  • amount (Float)

    移動する数量

Returns:

  • (Hash)


405
406
407
408
409
# File 'lib/vexapion/coincheck.rb', line 405

def from_leverage(currency, amount)
	params = { 'currency' => currency, 'amount' => amount }

	post('exchange/transfers/from_leverage', params)
end

#leverage_balanceHash

レバレッジアカウントの残高

Returns:

  • (Hash)


260
261
262
# File 'lib/vexapion/coincheck.rb', line 260

def leverage_balance
	get('accounts/leverage_balance')
end

#market_buy(pair, amount_jpy, stop_loss_rate = '') ⇒ Hash

成行注文buyの時はamountにJPYの数量を指定する(amount_jpy円分買うという指定方法)

Parameters:

  • pair (String)

    現在は‘btc_jpy’のみ

  • amount_jpy (Float)

    注文での量 例5000

  • stop_loss_rate (Integer) (defaults to: '')

    省略可 逆指値レート

Returns:

  • (Hash)


115
116
117
118
119
120
121
122
123
124
# File 'lib/vexapion/coincheck.rb', line 115

def market_buy(pair, amount_jpy, stop_loss_rate = '')
	params = {
		'pair'       => pair.downcase,
		'order_type' => "market_buy",
		'market_buy_amount' => amount_jpy
	}
	params['stop_loss_rate'] = stop_loss_rate if stop_loss_rate != ''

	post('exchange/orders', params)
end

#market_order_leverage(pair, order_type, amount, stop_loss_rate = '') ⇒ Hash

レバレッジ新規取引(成行)

Parameters:

  • pair (String)

    現在は‘btc_jpy’のみ

  • order_type (String)

    ‘sell’ or ‘buy’

  • amount (Float)

    注文での量 例0.1

  • stop_loss_rate (Integer) (defaults to: '')

    省略可 逆指値レート

Returns:

  • (Hash)


169
170
171
172
173
174
175
176
177
178
# File 'lib/vexapion/coincheck.rb', line 169

def market_order_leverage(pair, order_type, amount, stop_loss_rate = '')
	params = {
		'pair'        => pair.downcase,
		'amount'      => amount.to_f,
		'order_type'  => "leverage_#{order_type.downcase}"
	}
	params['stop_loss_rate'] = stop_loss_rate if stop_loss_rate != ''

	post('exchange/orders', params)
end

#market_sell(pair, amount, stop_loss_rate = '') ⇒ Hash

成行注文sellの時はamountにBTCの数量を指定する

Parameters:

  • pair (String)

    現在は‘btc_jpy’のみ

  • amount (Float)

    注文での量 例0.1

  • stop_loss_rate (Integer) (defaults to: '')

    省略可 逆指値レート

Returns:

  • (Hash)


132
133
134
135
136
137
138
139
140
141
# File 'lib/vexapion/coincheck.rb', line 132

def market_sell(pair, amount, stop_loss_rate = '')
	params = {
		'pair'       => pair.downcase,
		'order_type' => "market_sell",
		'amount'     => amount
	}
	params['stop_loss_rate'] = stop_loss_rate if stop_loss_rate != ''

	post('exchange/orders', params)
end

#opensHash

未約定の注文一覧

Returns:

  • (Hash)


220
221
222
# File 'lib/vexapion/coincheck.rb', line 220

def opens
	get('exchange/orders/opens')
end

#order(pair, order_type, rate, amount, stop_loss_rate = '') ⇒ Hash

Parameters:

  • pair (String)

    現在は‘btc_jpy’のみ

  • order_type (String)

    ‘sell’ or ‘buy’

  • rate (Integer)

    注文での金額 例28000

  • amount (Float)

    注文での量 例0.1

  • stop_loss_rate (Integer) (defaults to: '')

    省略可 逆指値レート

Returns:

  • (Hash)


97
98
99
100
101
102
103
104
105
106
107
# File 'lib/vexapion/coincheck.rb', line 97

def order(pair, order_type, rate, amount, stop_loss_rate = '')
	params = {
		'rate'        => rate,
		'amount'      => amount,
		'pair'        => pair.downcase,
		'order_type'  => order_type.downcase
	}
	params['stop_loss_rate'] = stop_loss_rate if stop_loss_rate != ''

	post('exchange/orders', params)
end

#order_booksHash

板情報

Returns:

  • (Hash)


44
45
46
# File 'lib/vexapion/coincheck.rb', line 44

def order_books
	public_get('order_books')
end

#order_leverage(pair, order_type, rate, amount, stop_loss_rate = '') ⇒ Hash

レバレッジ新規取引

Parameters:

  • pair (String)

    現在は‘btc_jpy’のみ

  • order_type (String)

    ‘sell’ or ‘buy’

  • rate (Integer)

    注文のレート 例28000

  • amount (Float)

    注文での量 例0.1

  • stop_loss_rate (Integer) (defaults to: '')

    省略可 逆指値レート

Returns:

  • (Hash)


151
152
153
154
155
156
157
158
159
160
161
# File 'lib/vexapion/coincheck.rb', line 151

def order_leverage(pair, order_type, rate, amount, stop_loss_rate = '')
	params = {
		'pair'        => pair.downcase,
		'rate'        => rate.to_f,
		'amount'      => amount.to_f,
		'order_type'  => "leverage_#{order_type.downcase}"
	}
	params['stop_loss_rate'] = stop_loss_rate if stop_loss_rate != ''

	post('exchange/orders', params)
end

#position(status = '') ⇒ Hash

ポジション一覧

Parameters:

  • status (String) (defaults to: '')

    省略可 ‘open’/‘closed’を指定出来ます

Returns:

  • (Hash)


246
247
248
249
250
# File 'lib/vexapion/coincheck.rb', line 246

def position(status='')
	params = Hash.new
	params['status'] = status  if status != ''  
	get('exchange/leverage/positions', params)
end

#rate(pair, order_type, price = '', amount = '') ⇒ Hash

レート取得

Parameters:

  • pair (String)

    必須 現在は‘btc_jpy’のみ

  • order_type (String)

    必須 ‘sell’ or ‘buy’

  • price (Integer) (defaults to: '')

    省略可 注文での金額 例28000

  • amount (Float) (defaults to: '')

    省略可 注文での量 例0.1

Returns:

  • (Hash)


54
55
56
57
58
59
60
61
62
63
# File 'lib/vexapion/coincheck.rb', line 54

def rate(pair, order_type, price='', amount='')
	params = {
		'pair'        =>  pair.downcase,
		'order_type'  =>  order_type,
	}
	params['price'] = price if price != ''
	params['amount'] = amount if amount != ''

	public_get('exchange/orders/rate')
end

#regist_bank_account(bank, branch, type, number_str, name) ⇒ Hash

銀行口座の登録

Parameters:

  • bank (String)

    銀行名

  • branch (String)

    支店名

  • type (String)

    口座の種類 (普通口座 futsu / 当座預金口座 toza)

  • number_str (String)

    口座番号 例:‘0123456’

  • name (String)

    口座名義

Returns:

  • (Hash)


315
316
317
318
319
320
321
322
323
324
325
# File 'lib/vexapion/coincheck.rb', line 315

def (bank, branch, type, number_str, name)
	params = {
		'bank_name'         => bank,
		'branch_name'       => branch,
		'bank_account_type' => type,
		'number'            => number_str,
		'name'              => name
	}

	post('bank_accounts', params)
end

#repayment(id) ⇒ Hash

返済

Parameters:

  • id (Integer)

    借入中一覧のID

Returns:

  • (Hash)


385
386
387
# File 'lib/vexapion/coincheck.rb', line 385

def repayment(id)
	post("lending/borrows/#{id}/repay")
end

#sales_rate(pair, price = '', amount = '') ⇒ Hash

販売所レート取得

Parameters:

  • pair (String)

    (‘btc_jpy’, ‘eth_jpy’, ‘zec_btc’ …etc)

Returns:

  • (Hash)


68
69
70
71
72
73
74
# File 'lib/vexapion/coincheck.rb', line 68

def sales_rate(pair, price='', amount='')
	params = {
		'pair' => pair.downcase,
	}

	public_get('exchange/orders/rate', params)
end

#send_history(currency = 'BTC') ⇒ Hash

ビットコイン送金履歴

Parameters:

  • currency (String) (defaults to: 'BTC')

    現在はBTCのみ対応。省略時のデフォルトはBTC

Returns:

  • (Hash)


275
276
277
# File 'lib/vexapion/coincheck.rb', line 275

def send_history(currency = 'BTC')
	get('send_money', 'currency' =>  currency)
end

#send_money(address, amount) ⇒ Hash

ビットコインの送金

Parameters:

  • address (String)

    送り先のビットコインアドレス

  • amount (Float)

    送りたいビットコインの量

Returns:

  • (Hash)


268
269
270
# File 'lib/vexapion/coincheck.rb', line 268

def send_money(address, amount)
	post('send_money', 'address' => address, 'amount' => amount)
end

#tickerHash

ティッカー

Returns:

  • (Hash)


32
33
34
# File 'lib/vexapion/coincheck.rb', line 32

def ticker
	public_get('ticker')
end

#to_leverage(currency, amount) ⇒ Hash

レバレッジアカウントへ振替

Parameters:

  • currency (String)

    通貨 現在はJPYのみ

  • amount (Float)

    移動する数量

Returns:

  • (Hash)


395
396
397
398
399
# File 'lib/vexapion/coincheck.rb', line 395

def to_leverage(currency, amount)
	params = { 'currency' => currency, 'amount' => amount }

	post('exchange/transfers/to_leverage', params)
end

#tradesArray

取引履歴

Returns:

  • (Array)


38
39
40
# File 'lib/vexapion/coincheck.rb', line 38

def trades
	public_get('trades')
end

#transactionsHash

約定履歴(ページネーション)

Returns:

  • (Hash)


233
234
235
# File 'lib/vexapion/coincheck.rb', line 233

def transactions
	get('exchange/orders/transactions')
end