Class: Binance::Api::Order

Inherits:
Object
  • Object
show all
Defined in:
lib/binance/api/order.rb

Class Method Summary collapse

Class Method Details

.all!(limit: 500, orderId: nil, recvWindow: 5000, symbol: nil, api_key: nil, api_secret_key: nil) ⇒ Object

Raises:



5
6
7
8
9
10
11
12
13
14
# File 'lib/binance/api/order.rb', line 5

def all!(limit: 500, orderId: nil, recvWindow: 5000, symbol: nil, api_key: nil, api_secret_key: nil)
  raise Error.new(message: "max limit is 500") unless limit <= 500
  raise Error.new(message: "symbol is required") if symbol.nil?
  timestamp = Configuration.timestamp
  params = { limit: limit, orderId: orderId, recvWindow: recvWindow, symbol: symbol, timestamp: timestamp }
  Request.send!(api_key_type: :read_info, path: "/api/v3/allOrders",
                params: params.delete_if { |key, value| value.nil? },
                security_type: :user_data, tld: Configuration.tld, api_key: api_key,
                api_secret_key: api_secret_key)
end

.all_open!(recvWindow: 5000, symbol: nil, api_key: nil, api_secret_key: nil) ⇒ Object

Be careful when accessing without a symbol!



17
18
19
20
21
22
23
# File 'lib/binance/api/order.rb', line 17

def all_open!(recvWindow: 5000, symbol: nil, api_key: nil, api_secret_key: nil)
  timestamp = Configuration.timestamp
  params = { recvWindow: recvWindow, symbol: symbol, timestamp: timestamp }
  Request.send!(api_key_type: :read_info, path: "/api/v3/openOrders",
                params: params, security_type: :user_data, tld: Configuration.tld, api_key: api_key,
                api_secret_key: api_secret_key)
end

.cancel!(orderId: nil, originalClientOrderId: nil, newClientOrderId: nil, recvWindow: nil, symbol: nil, api_key: nil, api_secret_key: nil) ⇒ Object

Raises:



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/binance/api/order.rb', line 25

def cancel!(orderId: nil, originalClientOrderId: nil, newClientOrderId: nil, recvWindow: nil, symbol: nil,
            api_key: nil, api_secret_key: nil)
  raise Error.new(message: "symbol is required") if symbol.nil?
  raise Error.new(message: "either orderid or originalclientorderid " \
                  "is required") if orderId.nil? && originalClientOrderId.nil?
  timestamp = Configuration.timestamp
  params = { orderId: orderId, origClientOrderId: originalClientOrderId,
             newClientOrderId: newClientOrderId, recvWindow: recvWindow,
             symbol: symbol, timestamp: timestamp }.delete_if { |key, value| value.nil? }
  Request.send!(api_key_type: :trading, method: :delete, path: "/api/v3/order",
                params: params, security_type: :trade, tld: Configuration.tld, api_key: api_key,
                api_secret_key: api_secret_key)
end

.create!(icebergQuantity: nil, newClientOrderId: nil, newOrderResponseType: nil, price: nil, quantity: nil, quoteOrderQty: nil, recvWindow: nil, stopPrice: nil, symbol: nil, side: nil, type: nil, timeInForce: nil, test: false, api_key: nil, api_secret_key: nil) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/binance/api/order.rb', line 39

def create!(icebergQuantity: nil, newClientOrderId: nil, newOrderResponseType: nil,
            price: nil, quantity: nil, quoteOrderQty: nil, recvWindow: nil, stopPrice: nil, symbol: nil,
            side: nil, type: nil, timeInForce: nil, test: false, api_key: nil, api_secret_key: nil)
  timestamp = Configuration.timestamp
  params = {
    icebergQty: icebergQuantity, newClientOrderId: newClientOrderId,
    newOrderRespType: newOrderResponseType, price: price, quantity: quantity, quoteOrderQty: quoteOrderQty,
    recvWindow: recvWindow, stopPrice: stopPrice, symbol: symbol, side: side,
    type: type, timeInForce: timeInForce, timestamp: timestamp,
  }.delete_if { |key, value| value.nil? }
  ensure_required_create_keys!(params: params)
  path = "/api/v3/order#{"/test" if test}"
  Request.send!(api_key_type: :trading, method: :post, path: path,
                params: params, security_type: :trade, tld: Configuration.tld, api_key: api_key,
                api_secret_key: api_secret_key)
end

.status!(orderId: nil, originalClientOrderId: nil, recvWindow: nil, symbol: nil, api_key: nil, api_secret_key: nil) ⇒ Object

Raises:



56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/binance/api/order.rb', line 56

def status!(orderId: nil, originalClientOrderId: nil, recvWindow: nil, symbol: nil,
            api_key: nil, api_secret_key: nil)
  raise Error.new(message: "symbol is required") if symbol.nil?
  raise Error.new(message: "either orderid or originalclientorderid " \
                  "is required") if orderId.nil? && originalClientOrderId.nil?
  timestamp = Configuration.timestamp
  params = {
    orderId: orderId, origClientOrderId: originalClientOrderId, recvWindow: recvWindow,
    symbol: symbol, timestamp: timestamp,
  }.delete_if { |key, value| value.nil? }
  Request.send!(api_key_type: :trading, path: "/api/v3/order",
                params: params, security_type: :user_data, tld: Configuration.tld, api_key: api_key,
                api_secret_key: api_secret_key)
end