Skip to main content

Custom Trading Strategies Overview

Custom trading strategies enable you to build and execute your own JavaScript code within Gunbot for spot and futures trading.

  • Utilize pre-built trading methods, candle, and indicator data to rapidly develop personalized strategies.
  • Each strategy functions as an async operation, running once every time a trading pair 'cycles' in Gunbot.
  • Implement your own JavaScript modules to enhance functionality.

Key Technical Aspects of the Code Environment

Consider these crucial technical details:

  • Gunbot manages exchange connections, data collection, and strategy availability.
  • Store strategies in individual .js files within a folder named ./customStrategies.
  • There's no specific Gunbot syntax; strategy code is standard JavaScript.
  • Strategy code can access one external object: gb, which includes numerous trading methods and extensive data.
  • While there are no limitations on using the provided trading methods, exchange-related restrictions apply (API rate limits, open orders limits, etc.).
  • No safeguards against double orders or other undesired actions exist; exercise caution.
  • Ensure compatibility with Node v14.4.0 when writing your JavaScript code.
  • The console.log() command logs information to the primary Gunbot console.
  • Code execution occurs inside an async function, allowing you to use the await keyword for retrieving additional data like varying timeframe candle data.
  • Strategies need not return anything; however, you may employ return statements to halt code at desired points.
  • Custom JavaScript modules can be utilized by strategies. Save these in a folder named user_modules within your Gunbot directory.