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
- #cancel_all_orders(symbol, type: :buy, 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: nil, 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
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/kucoin/rest/private/trading.rb', line 49 def active_orders(symbol, type: :buy, options: {}) .merge!(authenticate: true) params = { symbol: symbol.to_s.upcase, type: type.to_s.upcase } response = parse(get("/order/active", params: params, options: )) end |
#cancel_all_orders(symbol, type: :buy, options: {}) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/kucoin/rest/private/trading.rb', line 38 def cancel_all_orders(symbol, type: :buy, options: {}) .merge!(authenticate: true) payload = { symbol: symbol.to_s.upcase, type: type.to_s.upcase } response = parse(post("/order/cancel-all", data: payload, options: )) end |
#cancel_order(symbol, type: :buy, order_id:, options: {}) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/kucoin/rest/private/trading.rb', line 27 def cancel_order(symbol, type: :buy, order_id:, options: {}) .merge!(authenticate: true) payload = { orderOid: order_id, type: type.to_s.upcase } response = parse(post("/#{symbol}/cancel-order", data: payload, options: )) 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 |
# 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 } parse(post("/order", data: payload, options: )) 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: nil, type: nil, before: nil, since: nil, limit: nil, page: nil, options: {}) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/kucoin/rest/private/trading.rb', line 60 def dealt_orders(symbol: nil, 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 = parse(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
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/kucoin/rest/private/trading.rb', line 94 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 = parse(get("/order/detail", params: params, options: ))&.fetch("data", {}) end |
#symbol_dealt_orders(symbol, type: nil, limit: nil, page: nil, options: {}) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/kucoin/rest/private/trading.rb', line 78 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 = parse(get("/deal-orders", params: params, options: ))&.dig("data", "datas") ::Kucoin::Models::Deal.parse(response) if response end |