Skip to main content

What are Custom Strategies?

In Gunbot, custom strategies allow users to develop and execute their JavaScript strategy code for both spot and futures trading. These strategies leverage Gunbot's built-in exchange connectivity, trading methods, market data, and indicators, offering a powerful tool for personalized trading automation.

Features of Custom Strategies

Custom strategies in Gunbot are defined by their flexibility and technical integration:

  • Integration with Built-in Methods: Utilize Gunbot's extensive range of trading methods and indicators.
  • Execution Cycle: Operate as an asynchronous (async) function, running once per 'cycle' for each trading pair.

Environment for Custom Strategy Code

Understanding the environment in which custom strategies operate is crucial:

  • Gunbot's Role: Gunbot manages exchange connections and data collection, providing essential data to your strategy.
  • Execution Cycle: Each custom strategy is an async function, executed per cycle for a trading pair.
  • Strategy File Location: Custom strategies should be saved in ./customStrategies directory.
  • Language: Strategies are written in plain JavaScript, without requiring specific Gunbot syntax.
  • Interacting with gb Object: The gb object offers access to various trading methods and data.

Technical Considerations and Limitations

When working with custom strategies, consider these aspects:

  • Attention to Safety: Unlike built-in strategies, custom strategies don't have inherent safeguards.
  • Node.js Compatibility: Ensure compatibility with Node v14.4.0.
  • Logging: Use console.log() for logging within the Gunbot console.
  • Asynchronous Operations: Leverage the async nature for fetching additional data.
  • Return Statements: Use return to control the flow of your strategy function.

Custom Modules

Enhance your strategies with custom JavaScript modules:

  • Adding Modules: Store custom modules in the user_modules folder within your Gunbot installation.