Getting started with your 1st strategy

Status
Not open for further replies.

Ekliptor

Administrator
Staff member
Requirements:
  • This tutorial assumes that you have at least some basic JavaScript coding experience.
  • Ideally you are already familiar with TypeScript and know how classes, interfaces and inheritance work in TypeScript.


Getting started:

There is an example strategy available on Github.
It's possible to write your first and completely working strategy with 50-100 lines of code. This example above shows more features of WolfBot strategies which only advanced strategies need to implement. See NOOP.ts for a minimal example.

Strategies are located at:
/src/Strategies
Just copy and rename NOOP.ts or ExampleStrategy.ts (or any other strategy) as a template to create your own strategy.

Your strategy will look at technical indicators, trades, prices, candles, crawled data from the web,... and then call one of the following functions:
JavaScript:
this.emitBuy(this.defaultWeight, "my reason to buy");
this.emitSell(this.defaultWeight, "my reason to sell");
this.emitClose(this.defaultWeight, "my reason to close");
Those functions are usually called from within any of the following functions inside your strategy:
JavaScript:
candleTick();
checkIndicators();
tick();
However, you can call them from anywhere you want inside your strategy.

Your strategy can include its own configuration supplied by the user. Simply place the following at the top of your strategy file:
JavaScript:
interface ExampleStrategyAction extends TechnicalStrategyAction {
    myValue: number;
    myBool: boolean;
}
The above code will result in the following JSON config being available in all config files (config is loaded automatically):
JSON:
"strategies": {
        "ExampleStrategy": {
          "myValue": 123.55,
          "myBool": false
        }
}
Configuration files are located at: /config


Lending an arbitrage strategies work essentially the same way. They inherit most of their functions from common parent classes. They are located at:
/src/Arbitrage/Strategies
/src/Lending/Strategies

Feel free to ask any questions in this section of the forum if you need help developing your own strategies.
 
Last edited:
Status
Not open for further replies.