Module: Binance::Spot::Convert

Included in:
Binance::Spot
Defined in:
lib/binance/spot/convert.rb

Overview

Convert endpoints

Instance Method Summary collapse

Instance Method Details

#convert_accept_quote(quoteId:, **kwargs) ⇒ Object

Accept Quote (TRADE)

POST /sapi/v1/convert/acceptQuote

Parameters:

  • quoteId (String)
  • kwargs (Hash)

Options Hash (**kwargs):

  • :recvWindow (Integer)

    The value cannot be greater than 60000

See Also:



62
63
64
65
66
67
68
# File 'lib/binance/spot/convert.rb', line 62

def convert_accept_quote(quoteId:, **kwargs)
  Binance::Utils::Validation.require_param('quoteId', quoteId)

  @session.sign_request(:post, '/sapi/v1/convert/acceptQuote', params: kwargs.merge(
    quoteId: quoteId
  ))
end

#convert_asset_info(**kwargs) ⇒ Object

Query order quantity precision per asset (USER_DATA)

GET /sapi/v1/convert/assetInfo

Parameters:

  • kwargs (Hash)

Options Hash (**kwargs):

  • :recvWindow (Integer)

    The value cannot be greater than 60000

See Also:



27
28
29
# File 'lib/binance/spot/convert.rb', line 27

def convert_asset_info(**kwargs)
  @session.sign_request(:get, '/sapi/v1/convert/assetInfo', params: kwargs)
end

#convert_exchange_info(**kwargs) ⇒ Object

List All Convert Pairs

GET /sapi/v1/convert/exchangeInfo

Parameters:

  • kwargs (Hash)

Options Hash (**kwargs):

  • :fromAsset (String)

    Either fromAsset or toAsset or both should be send. User spends coin

  • :toAsset (String)

    Either fromAsset or toAsset or both should be send. User spends coin

See Also:



16
17
18
# File 'lib/binance/spot/convert.rb', line 16

def convert_exchange_info(**kwargs)
  @session.sign_request(:get, '/sapi/v1/convert/exchangeInfo', params: kwargs)
end

#convert_get_quote(fromAsset:, toAsset:, **kwargs) ⇒ Object

Send Quote Request (USER_DATA)

POST /sapi/v1/convert/getQuote

Parameters:

  • fromAsset (String)
  • toAsset (String)
  • kwargs (Hash)

Options Hash (**kwargs):

  • :fromAmount (Float)

    Either fromAmount or toAmount should be specified. When specified, it is the amount you will be debited after the conversion

  • :toAmount (Float)

    Either fromAmount or toAmount should be specified. When specified, it is the amount you will be credited after the conversion

  • :walletType (String)

    SPOT or FUNDING. Default is SPOT

  • :validTime (String)

    10s, 30s, 1m, default 10s

  • :recvWindow (Integer)

    The value cannot be greater than 60000

See Also:



44
45
46
47
48
49
50
51
52
# File 'lib/binance/spot/convert.rb', line 44

def convert_get_quote(fromAsset:, toAsset:, **kwargs)
  Binance::Utils::Validation.require_param('fromAsset', fromAsset)
  Binance::Utils::Validation.require_param('toAsset', toAsset)

  @session.sign_request(:post, '/sapi/v1/convert/getQuote', params: kwargs.merge(
    fromAsset: fromAsset,
    toAsset: toAsset
  ))
end

#convert_limit_cancel_order(orderId:, **kwargs) ⇒ Object

Cancel limit order (USER_DATA)

POST /sapi/v1/convert/limit/cancelOrder

Parameters:

  • orderId (String)
  • kwargs (Hash)

Options Hash (**kwargs):

  • :recvWindow (Integer)

    The value cannot be greater than 60000

See Also:



141
142
143
144
145
146
147
# File 'lib/binance/spot/convert.rb', line 141

def convert_limit_cancel_order(orderId:, **kwargs)
  Binance::Utils::Validation.require_param('orderId', orderId)

  @session.sign_request(:post, '/sapi/v1/convert/limit/cancelOrder', params: kwargs.merge(
    orderId: orderId
  ))
end

#convert_limit_place_order(baseAsset:, quoteAsset:, limitPrice:, side:, expiredType:, **kwargs) ⇒ Object

Place limit order (USER_DATA)

POST /sapi/v1/convert/limit/placeOrder

Parameters:

  • baseAsset (String)

    base asset (use the response fromIsBase from GET /sapi/v1/convert/exchangeInfo api to check which one is baseAsset)

  • quoteAsset (String)

    quote asset

  • limitPrice (Float)

    Symbol limit price (from baseAsset to quoteAsset)

  • side (String)

    BUY or SELL

  • expiredType (String)

    1_D, 3_D, 7_D, 30_D (D means day)

  • kwargs (Hash)

Options Hash (**kwargs):

  • :baseAmount (Float)

    Base asset amount. (One of baseAmount or quoteAmount is required)

  • :quoteAmount (Float)

    Quote asset amount. (One of baseAmount or quoteAmount is required)

  • :walletType (String)

    SPOT or FUNDING or SPOT_FUNDING. It is to use which type of assets. Default is SPOT.

  • :recvWindow (Integer)

    The value cannot be greater than 60000

See Also:



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/binance/spot/convert.rb', line 117

def convert_limit_place_order(baseAsset:, quoteAsset:, limitPrice:, side:, expiredType:, **kwargs)
  Binance::Utils::Validation.require_param('baseAsset', baseAsset)
  Binance::Utils::Validation.require_param('quoteAsset', quoteAsset)
  Binance::Utils::Validation.require_param('limitPrice', limitPrice)
  Binance::Utils::Validation.require_param('side', side)
  Binance::Utils::Validation.require_param('expiredType', expiredType)

  @session.sign_request(:post, '/sapi/v1/convert/limit/placeOrder', params: kwargs.merge(
    baseAsset: baseAsset,
    quoteAsset: quoteAsset,
    limitPrice: limitPrice,
    side: side,
    expiredType: expiredType
  ))
end

#convert_limit_query_open_orders(**kwargs) ⇒ Object

Query limit open orders (USER_DATA)

POST /sapi/v1/convert/limit/queryOpenOrders

Parameters:

  • kwargs (Hash)

Options Hash (**kwargs):

  • :recvWindow (Integer)

    The value cannot be greater than 60000

See Also:



156
157
158
# File 'lib/binance/spot/convert.rb', line 156

def convert_limit_query_open_orders(**kwargs)
  @session.sign_request(:post, '/sapi/v1/convert/limit/queryOpenOrders', params: kwargs)
end

#convert_order_status(**kwargs) ⇒ Object

Order status (USER_DATA)

GET /sapi/v1/convert/orderStatus

Parameters:

  • kwargs (Hash)

Options Hash (**kwargs):

  • :orderId (String)

    Either orderId or quoteId is required

  • :quoteId (String)

    Either orderId or quoteId is required

See Also:



98
99
100
# File 'lib/binance/spot/convert.rb', line 98

def convert_order_status(**kwargs)
  @session.sign_request(:get, '/sapi/v1/convert/orderStatus', params: kwargs)
end

#convert_trade_flow(startTime:, endTime:, **kwargs) ⇒ Object

Get Convert Trade History (USER_DATA)

GET /sapi/v1/convert/tradeFlow

Parameters:

  • startTime (Integer)
  • endTime (Integer)
  • kwargs (Hash)

Options Hash (**kwargs):

  • :limit (Integer)

    default 100, max 1000

  • :recvWindow (Integer)

    The value cannot be greater than 60000

See Also:



80
81
82
83
84
85
86
87
88
# File 'lib/binance/spot/convert.rb', line 80

def convert_trade_flow(startTime:, endTime:, **kwargs)
  Binance::Utils::Validation.require_param('startTime', startTime)
  Binance::Utils::Validation.require_param('endTime', endTime)

  @session.sign_request(:get, '/sapi/v1/convert/tradeFlow', params: kwargs.merge(
    startTime: startTime,
    endTime: endTime
  ))
end