Methods & Modules
In a custom trading strategy, you can execute or cancel orders and obtain additional OHLCV data using various methods. These methods can be called as functions without waiting for a return value. Alternatively, you can wait for the Promise to resolve when calling a method, enabling you to create a promise chain using the then
method.
The require module allows you to utilize extra JavaScript modules, such as those freely available on NPM. For instance, tulind enables easy calculation of your own indicator values.
Summary of All Accessible Methods and Built-in Modules
Method | Returns | Essential Information |
---|---|---|
gb.method.buyMarket(amount, pair, exchange) | Promise | Places a market buy order, amount in quote. Exchange is optional. |
gb.method.sellMarket(amount, pair, exchange) | Promise | Places a market sell order, amount in quote. Exchange is optional. |
gb.method.buyLimit(amount, price, pair, exchange) | Promise | Places a limit buy order, amount in quote. Exchange is optional. |
gb.method.sellLimit(amount, price, pair, exchange) | Promise | Places a limit sell order, amount in quote. Exchange is optional. |
gb.method.buyLimitPostOnly(amount, price, pair, exchange) | Promise | Places a limit buy order, amount in quote. Exchange is optional. |
gb.method.sellLimitPostOnly(amount, price, pair, exchange) | Promise | Places a limit sell order, amount in quote. Exchange is optional. |
gb.method.closeMarket(pair, amount, exchange) | Promise | Places a market close order, for futures. Amount in quote. |
gb.method.closeLimit(price, pair, amount, exchange) | Promise | Places a limit close order, for futures. Amount in quote. |
gb.method.cancelOrder(orderId, pair, exchange) | Promise | Cancels a specified open order. Awaiting the promise for this method to resolve is discouraged, as it can take a long time before the exchange confirms cancellation. |
gb.method.getLedger(pair, exchange) | Object | Retrieves Gunbot pair state data from other active trading pairs. |
gb.method.getCandles(interval, period, pair, exchange) | Promise | Obtains additional OHLCV data. Use cautiously, as frequent usage may lead to exceeding exchange API rate limits. |
gb.method.getTrend(pair, exchange, exchange) | Promise | Returns an object with trend data as used in stepgridhybrid/stepgridhedge. Can only be called for actively cycling pairs. Using this method increases API usage significantly, as it requests candle data in 15m, 1h, and 4h timeframes. |
gb.method.setTimeScaleMark(pair, exchange, message) | Mark on chart | Displays any string in a mark on a specific bar of the chart's x-axis. Timestamp is set automatically. |
gb.method.tulind[#parameters#] | array | Access 100+ different indicators using available OHLCV data or your own inputs. |
gunbot.method.require(module) | function | Incorporate your modules using require. To use an external module, place it in a folder called 'user_modules' in the Gunbot root folder. |
An example of a chart timescale mark, which you can set with gb.method.setTimeScaleMark()