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

#disconnect, #do_command, #get_nonce, #set_min_interval, #set_verify_mode

Constructor Details

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

:stopdoc:



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

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)


297
298
299
# File 'lib/vexapion/coincheck.rb', line 297

def accounts
	get('accounts')
end

#balanceHash

残高

Returns:

  • (Hash)


256
257
258
# File 'lib/vexapion/coincheck.rb', line 256

def balance
	get('accounts/balance')
end

#bank_accountsHash

銀行口座一覧

Returns:

  • (Hash)


306
307
308
# File 'lib/vexapion/coincheck.rb', line 306

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)


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

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)


338
339
340
# File 'lib/vexapion/coincheck.rb', line 338

def bank_withdraw_history
	get('withdraws')
end

#borrow(currency, amount) ⇒ Hash

借入申請

Parameters:

  • currency (String)

    借りたい通貨

  • amount (Float)

    借りたい量

Returns:

  • (Hash)


372
373
374
375
376
# File 'lib/vexapion/coincheck.rb', line 372

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

	post('lending/borrows', params)
end

#borrow_listHash

借入中一覧

Returns:

  • (Hash)


380
381
382
# File 'lib/vexapion/coincheck.rb', line 380

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

#cancel(id) ⇒ Hash

注文のキャンセル

Parameters:

  • id (Integer)

    キャンセルしたい注文ID

Returns:

  • (Hash)


229
230
231
# File 'lib/vexapion/coincheck.rb', line 229

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

#cancel_bank_withdraw(id) ⇒ Hash

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

Parameters:

  • id (Integer)

    出金申請のID

Returns:

  • (Hash)


362
363
364
# File 'lib/vexapion/coincheck.rb', line 362

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)


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

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)


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

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)


332
333
334
# File 'lib/vexapion/coincheck.rb', line 332

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

#deposit_accelerate(id) ⇒ Hash

ビットコインの高速入金

Parameters:

  • id (Integer)

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

Returns:

  • (Hash)


291
292
293
# File 'lib/vexapion/coincheck.rb', line 291

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)


284
285
286
# File 'lib/vexapion/coincheck.rb', line 284

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

#from_leverage(currency, amount) ⇒ Hash

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

Parameters:

  • currency (String)

    通貨 現在はJPYのみ

  • amount (Float)

    移動する数量

Returns:

  • (Hash)


407
408
409
410
411
# File 'lib/vexapion/coincheck.rb', line 407

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

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

#leverage_balanceHash

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

Returns:

  • (Hash)


262
263
264
# File 'lib/vexapion/coincheck.rb', line 262

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)


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

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)


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

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)


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

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)


222
223
224
# File 'lib/vexapion/coincheck.rb', line 222

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)


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

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)


46
47
48
# File 'lib/vexapion/coincheck.rb', line 46

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)


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

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)


248
249
250
251
252
# File 'lib/vexapion/coincheck.rb', line 248

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)


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

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)


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

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)


387
388
389
# File 'lib/vexapion/coincheck.rb', line 387

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)


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

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)


277
278
279
# File 'lib/vexapion/coincheck.rb', line 277

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

#send_money(address, amount) ⇒ Hash

ビットコインの送金

Parameters:

  • address (String)

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

  • amount (Float)

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

Returns:

  • (Hash)


270
271
272
# File 'lib/vexapion/coincheck.rb', line 270

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

#tickerHash

ティッカー

Returns:

  • (Hash)


34
35
36
# File 'lib/vexapion/coincheck.rb', line 34

def ticker
	public_get('ticker')
end

#to_leverage(currency, amount) ⇒ Hash

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

Parameters:

  • currency (String)

    通貨 現在はJPYのみ

  • amount (Float)

    移動する数量

Returns:

  • (Hash)


397
398
399
400
401
# File 'lib/vexapion/coincheck.rb', line 397

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

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

#tradesArray

取引履歴

Returns:

  • (Array)


40
41
42
# File 'lib/vexapion/coincheck.rb', line 40

def trades
	public_get('trades')
end

#transactionsHash

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

Returns:

  • (Hash)


235
236
237
# File 'lib/vexapion/coincheck.rb', line 235

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