Module: CBX::Trading

Includes:
Pagination
Defined in:
lib/cbx/trading.rb

Instance Method Summary collapse

Instance Method Details

#accounts(account_id = nil, &block) ⇒ Object

Account methods



7
8
9
10
11
12
13
# File 'lib/cbx/trading.rb', line 7

def accounts(=nil, &block)
  if .nil? then
    get('accounts', nil, &block)
  else
    get('accounts/' + .to_s, nil, &block)
  end
end

#cancel_order(order_id, &block) ⇒ Object



37
38
39
# File 'lib/cbx/trading.rb', line 37

def cancel_order(order_id, &block)
  delete('orders/' + order_id.to_s, nil, &block)
end

#deposit(amount, coinbase_account_id, &block) ⇒ Object

Transfer funds methods



48
49
50
51
# File 'lib/cbx/trading.rb', line 48

def deposit(amount, , &block)
  order = { 'type' => 'deposit', 'amount' => amount, 'coinbase_account_id' =>  }
  post('orders', order, &block)
end

#fills(pagination = {}, &block) ⇒ Object

Fill methods



60
61
62
# File 'lib/cbx/trading.rb', line 60

def fills(pagination = {}, &block)
  get('fills' + paginate(pagination), nil, &block)
end

#holds(account_id, pagination = {}, &block) ⇒ Object



19
20
21
# File 'lib/cbx/trading.rb', line 19

def holds(, pagination = {}, &block)
  get('accounts/' + .to_s + '/holds' + paginate(pagination), nil, &block)
end

#ledger(account_id, pagination = {}, &block) ⇒ Object



15
16
17
# File 'lib/cbx/trading.rb', line 15

def ledger(, pagination = {}, &block)
  get('accounts/' + .to_s + '/ledger' + paginate(pagination), nil, &block)
end

#order(order_id = nil, &block) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/cbx/trading.rb', line 29

def order(order_id=nil, &block)
  if order_id.nil? then
    get('orders', nil, &block)
  else
    get('orders/' + order_id.to_s, nil, &block)
  end
end

#orders(pagination = {}, &block) ⇒ Object

Order methods



25
26
27
# File 'lib/cbx/trading.rb', line 25

def orders(pagination = {}, &block)
  get('orders' + paginate(pagination), nil, &block)
end

#place_order(size, price, side, product_id = 'BTC-USD', &block) ⇒ Object



41
42
43
44
# File 'lib/cbx/trading.rb', line 41

def place_order(size, price, side, product_id='BTC-USD', &block)
  order = { 'size' => size, 'price' => price, 'side' => side, 'product_id' => product_id}
  post('orders', order, &block)
end

#withdraw(amount, coinbase_account_id, &block) ⇒ Object



53
54
55
56
# File 'lib/cbx/trading.rb', line 53

def withdraw(amount, , &block)
  order = { 'type' => 'withdraw', 'amount' => amount, 'coinbase_account_id' =>  }
  post('orders', order, &block)
end