# Botting

<figure><img src="/files/jtETQUX6AXZxkUn7YajX" alt=""><figcaption><p>Botting button</p></figcaption></figure>

<figure><img src="/files/wS3QmLEDiVrzuJpTKcEs" 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![](/files/u6IEZNeIZZSr6djhO5Ie)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.treeofalpha.com/tree-terminal/features/botting.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
