Skip to main content

Buy Order

Places a limit buy order on Gate.io exchange to purchase cryptocurrency at a specified price. The node automatically checks balance and validates the order before submission.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.

Inputs

  • Client Id - The unique client identifier from the Connect node. Can be left empty if using direct credentials.
  • Currency Pair - The trading pair for the order (e.g., BTC_USDT, ETH_USDT). Must use underscore separator.
  • Order Amount - The amount of base currency to buy (e.g., 0.001 for BTC in BTC_USDT pair).
  • Order Price - The price per unit in quote currency. Leave empty to use current market price (last price).

Options

  • Api Key - Gate.io API key credential (optional if using Client Id from Connect node).
  • Secret Key - Gate.io API secret key credential (optional if using Client Id from Connect node).

Output

  • Result - An object containing order details:
    • id - The unique order identifier assigned by Gate.io
    • fee - The trading fee charged for the order
    • create_time - Unix timestamp when the order was created

How It Works

The Buy Order node executes the following steps:

  1. Authenticates using either Client Id or direct credentials
  2. Validates and parses the Currency Pair (e.g., BTC_USDT splits into base=BTC, quote=USDT)
  3. Fetches current ticker data to get the last price
  4. Retrieves your account balance for the quote currency (e.g., USDT)
  5. Uses the provided Order Price, or defaults to last market price if empty
  6. Verifies you have sufficient balance to complete the purchase
  7. Creates a limit buy order on Gate.io spot market
  8. Returns the order details including order ID and fees

Requirements

  • Either a valid Client Id from Connect node OR API credentials
  • Sufficient balance in the quote currency (e.g., USDT for BTC_USDT)
  • Valid trading pair that exists on Gate.io
  • Order amount must meet minimum trading requirements for the pair
  • Trading pair must be active and not suspended

Error Handling

The node will return specific errors in the following cases:

  • ErrInternal - Failed to retrieve input parameters
  • ErrInvalidArg - Currency Pair is empty or invalid format (must be BASE_QUOTE)
  • ErrGetCurrencyPair - Trading pair doesn't exist or is invalid
  • ErrListTickers - Failed to fetch current price data
  • ErrListSpotAccounts - Failed to retrieve account balance or currency not found
  • ErrCheckBalance - Insufficient balance to complete the order
  • ErrCreateOrder - Failed to place the order (may be due to API limits, invalid parameters, etc.)

Usage Notes

  • This node places a limit order that will only execute at the specified price or better
  • The order is placed on the spot market (not margin or futures)
  • Time in force is set to gtc (Good Till Cancelled) - order stays active until filled or cancelled
  • Order amount must be specified in the base currency (first part of the pair)
  • The node automatically fetches and validates the current market price
  • Balance check includes the exact amount needed (amount × price)
  • Fees are deducted separately and returned in the result

Best Practices

  • Always verify sufficient balance before placing orders
  • Use Get Balance node to check available funds beforehand
  • Start with small amounts when testing
  • Store the returned order ID to track or cancel the order later
  • Validate trading pairs using List Pairs before trading
  • Check current price using Get Price before deciding on order price
  • Implement error handling for insufficient balance and order failures
  • Consider using Get Fee to calculate total costs including fees
  • Monitor orders using the returned order ID and Get Order node

Trading Strategy Tips

  • Market Buy: Leave Order Price empty to buy at current market price
  • Limit Buy: Set Order Price below current price to wait for a dip
  • Dollar Cost Averaging: Schedule regular buy orders at market price
  • Support Level: Place buy orders at technical support levels
  • Percentage Below Market: Calculate price as current_price * 0.95 for 5% below market

Example Usage Scenarios

Simple Market Buy

Inputs:
- Client Id: (from Connect node)
- Currency Pair: BTC_USDT
- Order Amount: 0.001
- Order Price: (empty - uses market price)

Result: Buys 0.001 BTC at current market price

Limit Buy at Specific Price

Inputs:
- Client Id: (from Connect node)
- Currency Pair: ETH_USDT
- Order Amount: 0.5
- Order Price: 2000

Result: Places limit order to buy 0.5 ETH at $2000 USDT each

Buy with Direct Credentials

Inputs:
- Client Id: (empty)
- Currency Pair: BTC_USDT
- Order Amount: 0.001
- Order Price: 50000

Options:
- Api Key: (your credential)
- Secret Key: (your credential)

Result: Buys without Connect node using direct authentication

Example Flow: Automated Buy Strategy

[Connect]
|
+-> [Get Price: BTC_USDT]
|
+-> [Calculate: price * 0.98] (2% below market)
|
+-> [Get Balance: USDT]
|
+-> [If: balance > minimum]
| |
| +-> True: [Buy Order]
| | |
| | +-> [Store Order ID]
| | +-> [Log Success]
| |
| +-> False: [Log: Insufficient Balance]
|
+-> [Disconnect]

Example Flow: Price Alert Buy

[Connect]
|
+-> [Loop Every 5 Minutes]
| |
| +-> [Get Price: BTC_USDT]
| |
| +-> [If: price < target_price]
| |
| +-> True: [Buy Order at market price]
| | |
| | +-> [Send notification]
| | +-> [Break Loop]
| |
| +-> False: [Continue Loop]
|
+-> [Disconnect]

Calculating Order Costs

To calculate total cost of an order:

Total Cost = (Order Amount × Order Price) + Fee

Example:

  • Order Amount: 0.1 BTC
  • Order Price: 50000 USDT
  • Fee: 5 USDT (0.01% of 50000)
  • Total: 50005 USDT

Common Errors and Solutions

Insufficient Balance

Error: ErrCheckBalance - Insufficient balance for this order
Solution:
- Check balance with Get Balance node
- Reduce order amount
- Ensure you're checking the correct quote currency

Invalid Currency Pair

Error: ErrInvalidArg - Currency Pair is invalid. It should be like 'BTC_USDT' format
Solution:
- Use underscore separator: BTC_USDT (not BTCUSDT or BTC-USDT)
- Verify pair exists using List Pairs node
- Check for typos in currency symbols

Order Creation Failed

Error: ErrCreateOrder
Possible causes:
- Order amount below minimum for the pair
- Price is too far from market price
- Trading pair is suspended
- API rate limit exceeded
- Invalid order parameters
  • Connect - Establishes the client session needed for this node
  • Get Balance - Check available funds before placing orders
  • Get Price - Get current market price to decide on order price
  • Get Order - Monitor the placed order using the returned order ID
  • Cancel Order - Cancel the order if not yet filled
  • List My Orders - View all your active orders
  • Get Fee - Check trading fees before placing orders