Module: Luno::Orders

Included in:
Client
Defined in:
lib/luno/orders.rb

Instance Method Summary collapse

Instance Method Details

#cancel_order(order_id:) ⇒ Object



86
87
88
89
# File 'lib/luno/orders.rb', line 86

def cancel_order(order_id:)
  path = 'stoporder'
  authorise_and_send(http_method: :post, path: path, params: { order_id: order_id })
end

#create_limit_order(pair:, type:, volume:, price:, post_only: nil, stop_price: nil, stop_direction: nil, base_account_id: nil, counter_account_id: nil, ttl: 10000, client_order_id: nil) ⇒ Object

Currency pair trade Type = “BID” or “ASK” stop_direction: “BELOW” “ABOVE” “RELATIVE_LAST_TRADE” TODO: Figure out



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/luno/orders.rb', line 54

def create_limit_order(
  pair:,
  type:,
  volume:,
  price:,
  post_only: nil,
  stop_price: nil,
  stop_direction: nil,
  base_account_id: nil,
  counter_account_id: nil,
  ttl: 10000,
  client_order_id: nil)
  path = 'postorder'

  params = {
    pair: pair,
    type: type,
    volume: volume,
    price: price,
    ttl: ttl
  }

  params = params.merge({ post_only: post_only }) if post_only
  params = params.merge({ stop_price: stop_price }) if stop_price
  params = params.merge({ stop_direction: stop_direction }) if stop_direction
  params = params.merge({ base_account_id:  }) if 
  params = params.merge({ counter_account_id:  }) if 
  params = params.merge({ client_order_id: client_order_id }) if client_order_id

  authorise_and_send(http_method: :post, path: path, params: params)
end

#create_market_order(pair:, type:, counter_volume: nil, base_volume: nil, base_account_id:, counter_account_id:, ttl: 10000, client_order_id: nil) ⇒ Object

TYPE = “BUY” “SELL”



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/luno/orders.rb', line 22

def create_market_order(
  pair:,
  type:,
  counter_volume: nil, # how much currency to use for a BUY order
  base_volume: nil, # how much crypto to use for a SELL order
  base_account_id: ,
  counter_account_id: ,
  ttl: 10000,
  client_order_id: nil)

  # TODO: Raise exception if counter_volume and base_volume are both nil
  path = 'marketorder'

  params = {
    pair: pair,
    type: type,
    base_account_id: ,
    counter_account_id: ,
    ttl: ttl
  }

  params = params.merge({ counter_volume: counter_volume }) if counter_volume
  params = params.merge({ base_volume: base_volume }) if base_volume
  params = params.merge({ client_order_id: client_order_id }) if client_order_id

  authorise_and_send(http_method: :post, path: path, params: params)
end

#get_fee_information(maker:, taker:) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/luno/orders.rb', line 3

def get_fee_information(maker:, taker:)
  path = "fee_info"
  pair = "#{maker}#{taker}".upcase

  # TODO: Validate pair from constants
  authorise_and_send(http_method: :get, path: path, params: { pair: pair })
end

#list_ordersObject



11
12
13
14
# File 'lib/luno/orders.rb', line 11

def list_orders
  path = "list_orders"
  authorise_and_send(http_method: :get, path: path)
end

#list_tradesObject



16
17
18
19
# File 'lib/luno/orders.rb', line 16

def list_trades
  path = "list_trades"
  authorise_and_send(http_method: :get, path: path)
end