> For the complete documentation index, see [llms.txt](https://docs.treeofalpha.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.treeofalpha.com/tree-terminal/features/botting.md). Agents can also search and read this documentation through its [MCP server](https://docs.treeofalpha.com/~gitbook/mcp).

# Botting

The Botting Component in Tree Terminal enables users to automate trading decisions based on real-time news and tweets. This guide explains its usage, search and command logic, and common patterns.

<figure><img src="https://4050888585-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCRtZpSFx87el6yevMYSx%2Fuploads%2FoF0P3abDz9ygiuA5kcuy%2Fboutons(7).png?alt=media&amp;token=95aea87a-adb6-4bcc-b47f-340858e39585" alt=""><figcaption><p>Botting button</p></figcaption></figure>

<figure><img src="https://4050888585-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCRtZpSFx87el6yevMYSx%2Fuploads%2F8RyrLKgfN9rRljJhAbCI%2FBotting.png?alt=media&amp;token=c69fddb7-e25e-4811-9e5e-966a919976ea" alt=""><figcaption></figcaption></figure>

## **Usage**&#x20;

This component should be used with **caution**. It allows the user to locally bot news & tweets received by Tree Terminal.

Main websocket is selected by default, you can also add your own Websocket in the field "News" in general settings.

Users should:

1. Focus on non-obvious events, rather than hyper-optimized events like **listings**, which are highly competitive.
2. Define **specific, actionable conditions** using regex, JavaScript, or keywords in the *search box*.
3. Pair these conditions with ***commands*** to trigger trades.
4. Test and validate all configurations before deploying.
5. Activate pushover if they would like to be notified when the botting criteria fires.

## Core Features

### **Search logic**

The **search box** defines conditions to trigger commands. It supports plain **text**, **regex**, and **JavaScript**.

#### Simple regex:

```
bitcoin|solana|ethereum
```

Explaination:

* Matches news containing "bitcoin," "solana," or "ethereum."&#x20;
* If a match is found, it will trigger whatever command is paired.

#### Javascript example:

{% code overflow="wrap" %}

```
+shouldEnter = /dwf/i.test(content) && /invest/i.test(content) && !/recap/i.test(content);+
```

{% endcode %}

Explanation:

* `content`: News or tweet title.
* `shouldEnter`: A variable that determines whether the bot will act.
* This checks if `content` includes "dwf" and "invest" but excludes "recap."
* Note that javascript in search logic must be encapsulated with "+"
* If shouldEnter evaluates to True, the paired command will activate and Tree Terminal will enter into a position.

## **Command**

Defines the action triggered when search -

1. Plain text has a match
2. Regex finds a match
3. Javascript's shouldEnter resolves to True

{% hint style="info" %}
Any command that works in the command-line also works in the "command" field of the botting component.
{% endhint %}

You can also use:

* &#x20;`{coin}` to reference the first coin in the "suggestions" of the news. Ex: `l {coin} 50k`
* `{coin!=BTC,ETH,BNB}` to provide a blacklist of coins that Tree Terminal should not long here

#### Basic Command

```
l {coin} 100k binance
```

* Longs the first coin in the news with 100k, on binance subaccount

#### Blacklist Coins:

```
l {coin!=BTC,ETH,BNB} 150k
```

* Excludes BTC, ETH and BNB, longs on first subaccount defined in priority of accounts

#### Multiple Commands:

```
l btc 100k binance; l {coin} 50k binance
```

* Executes commands sequentially, always forces a BTC long, alongside first coin from news item

## Practical Example

### ETF Scenario

#### Search

{% code overflow="wrap" %}

```
+shouldEnter = /Possible Bitcoin ETF Approval/i.test(content) && !window.longedETF; if(shouldEnter) window.longedETF = true;+
```

{% endcode %}

#### Command

```
l btc 100k 
```

**Explanation**:

* If the content contains "Possible Bitcoin ETF Approval" and the ETF hasn’t been longed, the bot executes a long on BTC.

## Key Notes

* **Two Reserved Variables in "Search's" Javascript**
  * `content`: The title of the news or tweet.
  * `shouldEnter`: Boolean to decide if a command should execute.
* **Avoid Obvious Events**:
  * Focus on niche or non-obvious scenarios where edge cases exist, instead of over-competitive events like listings (heavily optimized botters)
* **Testing**:
  * Always test search logic and commands independently to avoid unintended behavior.
  * Use [regex testing site](https://regex101.com/) to check your search box syntax
    * Specify variant to ECMAScript![](https://4050888585-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCRtZpSFx87el6yevMYSx%2Fuploads%2FOcPSCOn0H6oMoEG42roG%2Fimage.png?alt=media\&token=43d7e09f-814b-456f-9515-66d3020b0e93)
