Module: Binance::Spot::Trade
- Included in:
- Binance::Spot
- Defined in:
- lib/binance/spot/trade.rb
Overview
This module includes all spot trading methods, including:
-
place orders (spot and oco)
-
query orders (spot and oco)
-
cancel orders (spot and oco)
-
account information
-
my trades
Instance Method Summary collapse
-
#account(**kwargs) ⇒ Object
Account Information (USER_DATA).
-
#all_order_list(**kwargs) ⇒ Object
Query all OCO (USER_DATA).
-
#all_orders(symbol:, **kwargs) ⇒ Object
All Orders (USER_DATA).
-
#amend_keep_priority(symbol:, newQty:, **kwargs) ⇒ Object
Order Amend Keep Priority (TRADE).
-
#cancel_open_orders(symbol:, **kwargs) ⇒ Object
Cancel all Open Orders on a Symbol (TRADE).
-
#cancel_order(symbol:, **kwargs) ⇒ Object
Cancel Order (TRADE).
-
#cancel_order_list(symbol:, **kwargs) ⇒ Object
Cancel OCO (TRADE).
-
#cancel_replace(symbol:, side:, type:, cancelReplaceMode:, **kwargs) ⇒ Object
Cancel an Existing Order and Send a New Order (TRADE).
-
#commission_rate(symbol:) ⇒ Object
Query Commission Rates (USER_DATA).
-
#get_order(symbol:, **kwargs) ⇒ Object
Query Order (USER_DATA).
-
#get_order_rate_limit(**kwargs) ⇒ Object
Query Current Order Count Usage (TRADE).
-
#my_allocations(symbol:, **kwargs) ⇒ Object
Query Allocations (USER_DATA).
-
#my_filters(symbol:, **kwargs) ⇒ Object
Query relevant filters (USER_DATA).
-
#my_prevented_matches(symbol:, **kwargs) ⇒ Object
Query Prevented Matches (USER_DATA).
-
#my_trades(symbol:, **kwargs) ⇒ Object
Account Trade List (USER_DATA).
-
#new_oco_order(symbol:, side:, quantity:, aboveType:, belowType:, **kwargs) ⇒ Object
New OCO (TRADE).
-
#new_oco_order_list(symbol:, side:, quantity:, aboveType:, belowType:, **kwargs) ⇒ Object
New Order list - OCO (TRADE).
-
#new_opo_order_list(symbol:, workingType:, workingSide:, workingPrice:, workingQuantity:, pendingType:, pendingSide:, **kwargs) ⇒ Object
New Order List - OPO (TRADE).
-
#new_opoco_order_list(symbol:, workingType:, workingSide:, workingPrice:, workingQuantity:, pendingSide:, pendingAboveType:, **kwargs) ⇒ Object
New Order List - OPOCO (TRADE).
-
#new_order(symbol:, side:, type:, **kwargs) ⇒ Object
New Order.
-
#new_order_test(symbol:, side:, type:, **kwargs) ⇒ Object
TestNew Order.
-
#new_oto_order_list(symbol:, workingType:, workingSide:, workingPrice:, workingQuantity:, pendingType:, pendingSide:, pendingQuantity:, **kwargs) ⇒ Object
New Order list - OTO (TRADE).
-
#new_otoco_order_list(symbol:, workingType:, workingSide:, workingPrice:, workingQuantity:, pendingSide:, pendingQuantity:, pendingAboveType:, **kwargs) ⇒ Object
New Order list - OTOCO (TRADE).
-
#open_order_list(**kwargs) ⇒ Object
Query Open OCO (USER_DATA).
-
#open_orders(**kwargs) ⇒ Object
Current Open Orders (USER_DATA).
-
#order_amendments(symbol:, orderId:, **kwargs) ⇒ Object
Query Order Amendments (USER_DATA).
-
#order_list(**kwargs) ⇒ Object
Query OCO (USER_DATA).
Instance Method Details
#account(**kwargs) ⇒ Object
Account Information (USER_DATA)
GET /api/v3/account
290 291 292 |
# File 'lib/binance/spot/trade.rb', line 290 def account(**kwargs) @session.sign_request(:get, '/api/v3/account', params: kwargs) end |
#all_order_list(**kwargs) ⇒ Object
Query all OCO (USER_DATA)
GET /api/v3/allOrderList
Retrieves all OCO based on provided optional parameters
267 268 269 |
# File 'lib/binance/spot/trade.rb', line 267 def all_order_list(**kwargs) @session.sign_request(:get, '/api/v3/allOrderList', params: kwargs) end |
#all_orders(symbol:, **kwargs) ⇒ Object
All Orders (USER_DATA)
GET /api/v3/allOrders
Get all account orders; active, canceled, or filled.
164 165 166 167 168 |
# File 'lib/binance/spot/trade.rb', line 164 def all_orders(symbol:, **kwargs) Binance::Utils::Validation.require_param('symbol', symbol) @session.sign_request(:get, '/api/v3/allOrders', params: kwargs.merge(symbol: symbol)) end |
#amend_keep_priority(symbol:, newQty:, **kwargs) ⇒ Object
Order Amend Keep Priority (TRADE)
PUT /api/v3/order/amend/keepPriority
461 462 463 464 465 466 467 468 469 470 |
# File 'lib/binance/spot/trade.rb', line 461 def amend_keep_priority(symbol:, newQty:, **kwargs) Binance::Utils::Validation.require_param('symbol', symbol) Binance::Utils::Validation.require_param('newQty', newQty) @session.sign_request(:put, '/api/v3/order/amend/keepPriority', params: kwargs.merge( symbol: symbol, newQty: newQty )) end |
#cancel_open_orders(symbol:, **kwargs) ⇒ Object
Cancel all Open Orders on a Symbol (TRADE)
DELETE /api/v3/openOrders
113 114 115 116 117 |
# File 'lib/binance/spot/trade.rb', line 113 def cancel_open_orders(symbol:, **kwargs) Binance::Utils::Validation.require_param('symbol', symbol) @session.sign_request(:delete, '/api/v3/openOrders', params: kwargs.merge(symbol: symbol)) end |
#cancel_order(symbol:, **kwargs) ⇒ Object
Cancel Order (TRADE)
DELETE /api/v3/order
98 99 100 101 102 |
# File 'lib/binance/spot/trade.rb', line 98 def cancel_order(symbol:, **kwargs) Binance::Utils::Validation.require_param('symbol', symbol) @session.sign_request(:delete, '/api/v3/order', params: kwargs.merge(symbol: symbol)) end |
#cancel_order_list(symbol:, **kwargs) ⇒ Object
Cancel OCO (TRADE)
DELETE /api/v3/orderList
231 232 233 234 235 |
# File 'lib/binance/spot/trade.rb', line 231 def cancel_order_list(symbol:, **kwargs) Binance::Utils::Validation.require_param('symbol', symbol) @session.sign_request(:delete, '/api/v3/orderList', params: kwargs.merge(symbol: symbol)) end |
#cancel_replace(symbol:, side:, type:, cancelReplaceMode:, **kwargs) ⇒ Object
Cancel an Existing Order and Send a New Order (TRADE)
POST /api/v3/order/cancelReplace
434 435 436 437 438 439 440 441 442 443 444 445 446 447 |
# File 'lib/binance/spot/trade.rb', line 434 def cancel_replace(symbol:, side:, type:, cancelReplaceMode:, **kwargs) Binance::Utils::Validation.require_param('symbol', symbol) Binance::Utils::Validation.require_param('side', side) Binance::Utils::Validation.require_param('type', type) Binance::Utils::Validation.require_param('cancelReplaceMode', cancelReplaceMode) @session.sign_request(:post, '/api/v3/order/cancelReplace', params: kwargs.merge( symbol: symbol, side: side, type: type, cancelReplaceMode: cancelReplaceMode )) end |
#commission_rate(symbol:) ⇒ Object
Query Commission Rates (USER_DATA)
GET /api/v3/account/commission
364 365 366 367 368 |
# File 'lib/binance/spot/trade.rb', line 364 def commission_rate(symbol:) Binance::Utils::Validation.require_param('symbol', symbol) @session.sign_request(:get, '/api/v3/account/commission', params: { symbol: symbol }) end |
#get_order(symbol:, **kwargs) ⇒ Object
Query Order (USER_DATA)
GET /api/v3/order
130 131 132 133 134 |
# File 'lib/binance/spot/trade.rb', line 130 def get_order(symbol:, **kwargs) Binance::Utils::Validation.require_param('symbol', symbol) @session.sign_request(:get, '/api/v3/order', params: kwargs.merge(symbol: symbol)) end |
#get_order_rate_limit(**kwargs) ⇒ Object
Query Current Order Count Usage (TRADE)
GET /api/v3/rateLimit/order
318 319 320 |
# File 'lib/binance/spot/trade.rb', line 318 def get_order_rate_limit(**kwargs) @session.sign_request(:get, '/api/v3/rateLimit/order', params: kwargs) end |
#my_allocations(symbol:, **kwargs) ⇒ Object
Query Allocations (USER_DATA)
GET /api/v3/myAllocations
352 353 354 355 356 |
# File 'lib/binance/spot/trade.rb', line 352 def my_allocations(symbol:, **kwargs) Binance::Utils::Validation.require_param('symbol', symbol) @session.sign_request(:get, '/api/v3/myAllocations', params: kwargs.merge(symbol: symbol)) end |
#my_filters(symbol:, **kwargs) ⇒ Object
Query relevant filters (USER_DATA)
GET /api/v3/myFilters
396 397 398 399 400 |
# File 'lib/binance/spot/trade.rb', line 396 def my_filters(symbol:, **kwargs) Binance::Utils::Validation.require_param('symbol', symbol) @session.sign_request(:get, '/api/v3/myFilters', params: kwargs.merge(symbol: symbol)) end |
#my_prevented_matches(symbol:, **kwargs) ⇒ Object
Query Prevented Matches (USER_DATA)
GET /api/v3/myPreventedMatches
334 335 336 337 338 |
# File 'lib/binance/spot/trade.rb', line 334 def my_prevented_matches(symbol:, **kwargs) Binance::Utils::Validation.require_param('symbol', symbol) @session.sign_request(:get, '/api/v3/myPreventedMatches', params: kwargs.merge(symbol: symbol)) end |
#my_trades(symbol:, **kwargs) ⇒ Object
Account Trade List (USER_DATA)
GET /api/v3/myTrades
307 308 309 |
# File 'lib/binance/spot/trade.rb', line 307 def my_trades(symbol:, **kwargs) @session.sign_request(:get, '/api/v3/myTrades', params: kwargs.merge(symbol: symbol)) end |
#new_oco_order(symbol:, side:, quantity:, aboveType:, belowType:, **kwargs) ⇒ Object
New OCO (TRADE)
POST /api/v3/order/oco
Send in a new OCO
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/binance/spot/trade.rb', line 203 def new_oco_order(symbol:, side:, quantity:, aboveType:, belowType:, **kwargs) Binance::Utils::Validation.require_param('symbol', symbol) Binance::Utils::Validation.require_param('side', side) Binance::Utils::Validation.require_param('quantity', quantity) Binance::Utils::Validation.require_param('aboveType', aboveType) Binance::Utils::Validation.require_param('belowType', belowType) @session.sign_request(:post, '/api/v3/order/oco', params: kwargs.merge( symbol: symbol, side: side, quantity: quantity, aboveType: aboveType, belowType: belowType )) end |
#new_oco_order_list(symbol:, side:, quantity:, aboveType:, belowType:, **kwargs) ⇒ Object
New Order list - OCO (TRADE)
POST /api/v3/orderList/oco
509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 |
# File 'lib/binance/spot/trade.rb', line 509 def new_oco_order_list(symbol:, side:, quantity:, aboveType:, belowType:, **kwargs) Binance::Utils::Validation.require_param('symbol', symbol) Binance::Utils::Validation.require_param('side', side) Binance::Utils::Validation.require_param('quantity', quantity) Binance::Utils::Validation.require_param('aboveType', aboveType) Binance::Utils::Validation.require_param('belowType', belowType) @session.sign_request(:post, '/api/v3/orderList/oco', params: kwargs.merge( symbol: symbol, side: side, quantity: quantity, aboveType: aboveType, belowType: belowType )) end |
#new_opo_order_list(symbol:, workingType:, workingSide:, workingPrice:, workingQuantity:, pendingType:, pendingSide:, **kwargs) ⇒ Object
New Order List - OPO (TRADE)
POST /api/v3/orderList/opo
698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 |
# File 'lib/binance/spot/trade.rb', line 698 def new_opo_order_list(symbol:, workingType:, workingSide:, workingPrice:, workingQuantity:, pendingType:, pendingSide:, **kwargs) params = { symbol: symbol, workingType: workingType, workingSide: workingSide, workingPrice: workingPrice, workingQuantity: workingQuantity, pendingType: pendingType, pendingSide: pendingSide } params.each do |name, value| Binance::Utils::Validation.require_param(name.to_s, value) end @session.sign_request(:post, '/api/v3/orderList/opo', params: kwargs.merge(params)) end |
#new_opoco_order_list(symbol:, workingType:, workingSide:, workingPrice:, workingQuantity:, pendingSide:, pendingAboveType:, **kwargs) ⇒ Object
New Order List - OPOCO (TRADE)
POST /api/v3/orderList/opoco
765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 |
# File 'lib/binance/spot/trade.rb', line 765 def new_opoco_order_list( symbol:, workingType:, workingSide:, workingPrice:, workingQuantity:, pendingSide:, pendingAboveType:, **kwargs ) params = { symbol: symbol, workingType: workingType, workingSide: workingSide, workingPrice: workingPrice, workingQuantity: workingQuantity, pendingSide: pendingSide, pendingAboveType: pendingAboveType } params.each do |name, value| Binance::Utils::Validation.require_param(name.to_s, value) end @session.sign_request(:post, '/api/v3/orderList/opoco', params: kwargs.merge(params)) end |
#new_order(symbol:, side:, type:, **kwargs) ⇒ Object
New Order
POST /api/v3/order
send in a new order
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/binance/spot/trade.rb', line 75 def new_order(symbol:, side:, type:, **kwargs) Binance::Utils::Validation.require_param('symbol', symbol) Binance::Utils::Validation.require_param('side', side) Binance::Utils::Validation.require_param('type', type) @session.sign_request(:post, '/api/v3/order', params: kwargs.merge( symbol: symbol, side: side, type: type )) end |
#new_order_test(symbol:, side:, type:, **kwargs) ⇒ Object
TestNew Order
POST /api/v3/order/test
send in a new order to test the request, no order is really generated.
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/binance/spot/trade.rb', line 35 def new_order_test(symbol:, side:, type:, **kwargs) Binance::Utils::Validation.require_param('symbol', symbol) Binance::Utils::Validation.require_param('side', side) Binance::Utils::Validation.require_param('type', type) @session.sign_request(:post, '/api/v3/order/test', params: kwargs.merge( symbol: symbol, side: side, type: type )) end |
#new_oto_order_list(symbol:, workingType:, workingSide:, workingPrice:, workingQuantity:, pendingType:, pendingSide:, pendingQuantity:, **kwargs) ⇒ Object
New Order list - OTO (TRADE)
POST /api/v3/orderList/oto
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 |
# File 'lib/binance/spot/trade.rb', line 563 def new_oto_order_list( symbol:, workingType:, workingSide:, workingPrice:, workingQuantity:, pendingType:, pendingSide:, pendingQuantity:, **kwargs ) params = { symbol: symbol, workingType: workingType, workingSide: workingSide, workingPrice: workingPrice, workingQuantity: workingQuantity, pendingType: pendingType, pendingSide: pendingSide, pendingQuantity: pendingQuantity } params.each do |name, value| Binance::Utils::Validation.require_param(name.to_s, value) end @session.sign_request(:post, '/api/v3/orderList/oto', params: kwargs.merge(params)) end |
#new_otoco_order_list(symbol:, workingType:, workingSide:, workingPrice:, workingQuantity:, pendingSide:, pendingQuantity:, pendingAboveType:, **kwargs) ⇒ Object
New Order list - OTOCO (TRADE)
POST /api/v3/orderList/otoco
642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 |
# File 'lib/binance/spot/trade.rb', line 642 def new_otoco_order_list(symbol:, workingType:, workingSide:, workingPrice:, workingQuantity:, pendingSide:, pendingQuantity:, pendingAboveType:, **kwargs) params = { symbol: symbol, workingType: workingType, workingSide: workingSide, workingPrice: workingPrice, workingQuantity: workingQuantity, pendingSide: pendingSide, pendingQuantity: pendingQuantity, pendingAboveType: pendingAboveType } params.each do |name, value| Binance::Utils::Validation.require_param(name.to_s, value) end @session.sign_request(:post, '/api/v3/orderList/otoco', params: kwargs.merge(params)) end |
#open_order_list(**kwargs) ⇒ Object
Query Open OCO (USER_DATA)
GET /api/v3/openOrderList
279 280 281 |
# File 'lib/binance/spot/trade.rb', line 279 def open_order_list(**kwargs) @session.sign_request(:get, '/api/v3/openOrderList', params: kwargs) end |
#open_orders(**kwargs) ⇒ Object
Current Open Orders (USER_DATA)
GET /api/v3/openOrders
145 146 147 |
# File 'lib/binance/spot/trade.rb', line 145 def open_orders(**kwargs) @session.sign_request(:get, '/api/v3/openOrders', params: kwargs) end |
#order_amendments(symbol:, orderId:, **kwargs) ⇒ Object
Query Order Amendments (USER_DATA)
GET /api/v3/order/amendments
381 382 383 384 385 386 |
# File 'lib/binance/spot/trade.rb', line 381 def order_amendments(symbol:, orderId:, **kwargs) Binance::Utils::Validation.require_param('symbol', symbol) Binance::Utils::Validation.require_param('orderId', orderId) @session.sign_request(:get, '/api/v3/order/amendments', params: kwargs.merge(symbol: symbol, orderId: orderId)) end |
#order_list(**kwargs) ⇒ Object
Query OCO (USER_DATA)
GET /api/v3/orderList
Retrieves a specific OCO based on provided optional parameters
249 250 251 |
# File 'lib/binance/spot/trade.rb', line 249 def order_list(**kwargs) @session.sign_request(:get, '/api/v3/orderList', params: kwargs) end |