Available methods and modules
In a custom strategy, you can place or cancel orders and fetch 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. This allows you to create a promise chain using the then()
method.
The require module allow you to use additional javascript modules, like those freely available on NPM. With tulind you can easily calculate your own indicator values.
Overview of all methods and built-in modules
Method | Returns | Extra info |
---|---|---|
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 |
gb.method.buyLimitPostOnly(amount, price, pair, exchange) | Promise | Places a limit buy order, amount in quote |
gb.method.sellLimitPostOnly(amount, price, pair, exchange) | Promise | Places a limit sell order, amount in quote |
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. It is discouraged to await the promise for this method to resolve, because it can take a very long time before the exchange confirms a cancellation. |
gb.method.getLedger(pair, exchange) | Object | Get pair state for other pairs Use this to retrieve Gunbot pair state data from other active trading pairs, the returned is largely the same as what you'd find in pair state json files. |
gb.method.getCandles(interval, period, pair, exchange) | Promise | Get additional OHLCV data. Easiest to call using Beware: frequent usage can quickly lead to exceeding exchange API rate limits. |
gb.method.getTrend(pair, exchange, version) | Promise | Returns an object with the same trend data as used in stepgridhybrid/stepgridhedge. Can only be called for pairs actively cycling. Calling this method leads to significant additional API usage, because candle data in 15m, 1h and 4h timeframes gets requested. Trend and candle data additionally gets stored to Gunbot pair state. The version prop is optional and defaults to |
gb.method.setTimeScaleMark(pair, exchange, message) | Mark on chart | Timescale marks are the marks on the chart x axis, that by default show details for filled orders. With this method you can display any string in a mark on a specific bar. When multiple messages get stored for the same candle, they will be shown together in one mark. Timestamp is set automatically, no need to include it in the message text. |
gb.method.tulind [#parameters#] | array | Get 100+ different indicators. You can use the available OHLCV data, or use your own inputs. See the example strategies for a usage example. |
gunbot.method.require(module) | function | Bring your own modules using require. See the example strategies for a usage example. To use an external module, first place it in a folder called 'user_modules' in the Gunbot root folder. Then require it in your strategy code, like this: On Linux (and likely macOS): On Windows: The above assumes you have a module in a folder called cryptopanic in the user_modules folder. |