Module: Kucoin::Rest::Private::Trading
- Included in:
- Client
- Defined in:
- lib/kucoin/rest/private/trading.rb
Instance Method Summary collapse
- #active_orders(symbol, type: :buy, options: {}) ⇒ Object
- #active_orders_map(symbol, type: :buy, options: {}) ⇒ Object
- #cancel_all_orders(symbol, type: nil, options: {}) ⇒ Object
- #cancel_order(symbol, type: :buy, order_id:, options: {}) ⇒ Object
- #create_buy_order(symbol, price:, amount:, options: {}) ⇒ Object
- #create_order(symbol, type: :buy, price:, amount:, options: {}) ⇒ Object
- #create_sell_order(symbol, price:, amount:, options: {}) ⇒ Object
- #dealt_orders(symbol, type: nil, before: nil, since: nil, limit: nil, page: nil, options: {}) ⇒ Object
- #order_detail(symbol, order_id:, type: :buy, limit: nil, page: nil, options: {}) ⇒ Object
- #symbol_dealt_orders(symbol, type: nil, limit: nil, page: nil, options: {}) ⇒ Object
Instance Method Details
#active_orders(symbol, type: :buy, options: {}) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/kucoin/rest/private/trading.rb', line 53 def active_orders(symbol, type: :buy, options: {}) .merge!(authenticate: true) params = { symbol: symbol.to_s.upcase, type: type.to_s.upcase } response = get("/order/active", params: params, options: )&.fetch("data", []) ::Kucoin::Models::Order.parse(response) if response end |
#active_orders_map(symbol, type: :buy, options: {}) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/kucoin/rest/private/trading.rb', line 65 def active_orders_map(symbol, type: :buy, options: {}) .merge!(authenticate: true) params = { symbol: symbol.to_s.upcase, type: type.to_s.upcase } response = get("/order/active-map", params: params, options: )&.fetch("data", {}) ::Kucoin::Models::Order.parse_map(response) if response end |
#cancel_all_orders(symbol, type: nil, options: {}) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/kucoin/rest/private/trading.rb', line 40 def cancel_all_orders(symbol, type: nil, options: {}) .merge!(authenticate: true) payload = { symbol: symbol.to_s.upcase, type: type.to_s.upcase } payload.delete_if { |key, value| value.nil? || value.to_s.empty? } post("/order/cancel-all", data: payload, options: )&.fetch("success", false) end |
#cancel_order(symbol, type: :buy, order_id:, options: {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/kucoin/rest/private/trading.rb', line 29 def cancel_order(symbol, type: :buy, order_id:, options: {}) .merge!(authenticate: true) payload = { orderOid: order_id, type: type.to_s.upcase } post("/#{symbol}/cancel-order", data: payload, options: )&.fetch("success", false) end |
#create_buy_order(symbol, price:, amount:, options: {}) ⇒ Object
6 7 8 |
# File 'lib/kucoin/rest/private/trading.rb', line 6 def create_buy_order(symbol, price:, amount:, options: {}) create_order(symbol, type: :buy, price: price, amount: amount, options: ) end |
#create_order(symbol, type: :buy, price:, amount:, options: {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/kucoin/rest/private/trading.rb', line 14 def create_order(symbol, type: :buy, price:, amount:, options: {}) .merge!(authenticate: true) payload = { symbol: symbol.to_s.upcase, type: type.to_s.upcase, price: price, amount: amount } response = post("/order", data: payload, options: ) return {success: response&.fetch("success", false), id: response&.dig("data", "orderOid")} end |
#create_sell_order(symbol, price:, amount:, options: {}) ⇒ Object
10 11 12 |
# File 'lib/kucoin/rest/private/trading.rb', line 10 def create_sell_order(symbol, price:, amount:, options: {}) create_order(symbol, type: :sell, price: price, amount: amount, options: ) end |
#dealt_orders(symbol, type: nil, before: nil, since: nil, limit: nil, page: nil, options: {}) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/kucoin/rest/private/trading.rb', line 77 def dealt_orders(symbol, type: nil, before: nil, since: nil, limit: nil, page: nil, options: {}) .merge!(authenticate: true) params = { symbol: symbol.to_s.upcase, type: type.to_s.upcase, before: before, since: since, limit: limit, page: page } params.delete_if { |key, value| value.nil? } response = get("/order/dealt", params: params, options: )&.dig("data", "datas") ::Kucoin::Models::Deal.parse(response) if response end |
#order_detail(symbol, order_id:, type: :buy, limit: nil, page: nil, options: {}) ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/kucoin/rest/private/trading.rb', line 111 def order_detail(symbol, order_id:, type: :buy, limit: nil, page: nil, options: {}) .merge!(authenticate: true) params = { symbol: symbol.to_s.upcase, orderOid: order_id, type: type.to_s.upcase, limit: limit, page: page } params.delete_if { |key, value| value.nil? } response = get("/order/detail", params: params, options: )&.fetch("data", {}) ::Kucoin::Models::Order.new(response) if response end |
#symbol_dealt_orders(symbol, type: nil, limit: nil, page: nil, options: {}) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/kucoin/rest/private/trading.rb', line 95 def symbol_dealt_orders(symbol, type: nil, limit: nil, page: nil, options: {}) .merge!(authenticate: true) params = { symbol: symbol.to_s.upcase, type: type.to_s.upcase, limit: limit, page: page } params.delete_if { |key, value| value.nil? } response = get("/deal-orders", params: params, options: )&.dig("data", "datas") ::Kucoin::Models::Deal.parse(response) if response end |