# Command line

<figure><img src="/files/bbretsiNyLoiO12Omb1s" alt=""><figcaption><p>Command line button</p></figcaption></figure>

<figure><img src="/files/lNqrKFmx6Nv9l6YMiXYJ" alt=""><figcaption></figcaption></figure>

This guide introduces the syntax and offers quickstart examples on how to use the CLI.&#x20;

## **Command Syntax**

Commands in Tree Terminal follow a structured format. Understanding **mandatory vs. optional variables** is crucial for effective use.

**Mandatory Variables:**

1. **`{coin}`**:
   * Required for all commands.
   * Specifies the coin symbol (e.g., BTC, ETH).
   * ⚠️ `all` is a reserved keyword in Tree Terminal. If you wish to trade ALLUSDT (on Binance), please use `allusdt` instead of `all`

**Optional Variables:**

2. **`{size}`**:
   * Specifies the position size.
   * Defaults to the **first size** in your trading configuration if omitted.
   * Shorthand:
     * `1k = $1,000`
     * `1m = $1,000,000`
3. **`{account}`**:
   * Refers to the subaccount or trading account.
   * If omitted, the default account is used.
4. **`{price}`**:
   * Limit price for the trade (e.g., `p_41500` for $41,500).
   * Omit for market orders.
5. **`{timeInForce}`**:
   * Specifies order duration:
     * **GTC**: Good Till Canceled.
     * **IOC**: Immediate or Cancel.
6. **`{slippage}`**:
   * Sets acceptable price deviation.
   * Example: `slippage=0.5%`.
7. **`{percent}`**:
   * Contextual variable used for percentage-based actions, such as:
     * **Closing:** Closing 50% of a position.
     * **Creating Limit Orders:** Setting a limit price based on a percentage deviation from the market price.
8. **`{last}`**`:`
   * Refers to the first coin from the most recent notification.
   * Example: `l {last} 10k` executes a long position for the coin from the latest notification&#x20;
9. **`{size1}, {size2}, {size3}`**`:`
   * Correspond to predefined trading sizes in your configuration.
   * Example: `l btc {size2}` uses the second trading size from your setup.

### **Examples**

**Basic Commands:**

1. **Long**:

   ```
   l btc 10k
   ```

   * Long BTC with $10,000.
2. **Short**:

   ```
   s eth 5k binance
   ```

   * Short ETH with $5,000 on Binance.
3. **Close**:

   ```r
   c btc 50%
   ```

   * Close 50% of BTC position across all accounts.
4. **Limit Order**:

   ```
   l btc 10k p_62000
   ```

   * Place a limit order to long BTC at $62,000.
5. **Limit Order**:

   ```
   l btc 10k -1%
   ```

   * Place a limit order to long BTC 1% below current price

***

## Scale Orders

**Command Syntax**

```
{<l or s>} {coin} {size} scale_{count}_{spacing}% p_{price?}
```

Splits your full intended position into `{count}` individual limit orders, each spaced `{spacing}%` apart. The first order is placed at the specified `p_{price}`

**Examples**

* ```
  l btc scale_5_2% p_80000
  ```

  Long BTC in 5 tranches (using your default size), 2% apart, from 80k and below.<br>
* **Click Shortcut:**\
  Assign a hotkey (e.g. `Ctrl+Shift+S`) to run

  ```
  l {coin} 200k scale_5_2%
  ```

  which will place 5 staggered buy orders 2% apart from **each other** for the coin from the mouse's y-axis current price, for total of 200k size.

<figure><img src="/files/SyMyokvkdkDg7qbDvs5B" alt=""><figcaption><p>example of click shortcut</p></figcaption></figure>

***

## **TWAP Features**

TWAP (Time-Weighted Average Price) splits orders into smaller intervals for better execution.

**Syntax:**

```
l {coin} {size_per_twap} twap {account name}
```

**Modifiers:**

* `<70000`: Execute trades only below $70,000.
* `max_200k`: Stop once the position reaches $200,000.
* `until_{time_in_minutes}`: Set time constraints.
* `maker` : twap using only limit orders

{% hint style="info" %}
if no {account name} is specified, the first account will be used
{% endhint %}

**Examples:**

1. Long BTC in intervals:

   ```
   l btc 1k twap_20s {account name}
   ```

   * Long BTC with $1,000 every 20 seconds.
2. Short ETH with a cap:

   ```
   s eth 5k twap max_200k {account name}
   ```
3. Time-limited TWAP:

   ```
   l btc 1k twap_20s until_30m {account name}
   ```

   * Long $1,000 of BTC every 20 seconds for 30 minutes.
4. Using TWAP to close a position:

   ```
   c btc 1% twap {account name}
   ```

   * Close btc position on {account name} via 1% of position size orders and default twap interval

   ```
   c btc 1% twap
   ```

   * ⚠️⚠️⚠️ **Because this has no {account name} it will close btc position on all subaccounts** via 1% of position size orders and default twap interval
5. Using TWAP to close all positions:

   ```
   c all 1% twap
   ```

   * Close all positions via 1% of position size orders and default twap interval

**How to cancel:**

There are two ways:

1. Go to "open orders" and you will see your twap there. Click on the cancel button to stop the twap.
2. Type `cancel <ticker>` , but do note this will cancel all outstanding limit / stop loss orders for the ticker as well.&#x20;

***

## **Custom Commands**

Custom commands build on the syntax and examples above, allowing users to simplify repetitive trading actions.

**Adding Custom Commands:**

Go to the **"Shortcuts"** field in General Settings and add commands.

<figure><img src="/files/KPbKCUJTmNoZ14E5Syx3" alt=""><figcaption></figcaption></figure>

**Supported Variables:**

* `{coin}`, `{size}`, `{timeInForce}`, `{account}`, `{cmd}`, `{slippage}`, `{percent}, {last}, {size(n)}`.

**Use Cases:**

1. Rename commands for better readability.
2. Split orders across accounts for simultaneous entries.
3. Define commands for specific time-in-force options (e.g., GTC vs. IOC).

***

## Telegram Integration

These commands can also be used with [Telegram](https://t.me/TreeTerminal_Bot) and Discord bots by enabling them in the Trading field found in the general settings.

<figure><img src="/files/vnDcTbnWnE5Yp3zARE3D" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
"account" command is unique to telegram and discord bot and will return your account balances and positions. Try it!
{% endhint %}

#### These commands are specifically designed for users accessing Tree Terminal remotely via **Telegram** or **Discord**. They allow quick management of positions, balances, and orders.

#### **1. Accounts**

* **Command**:

  ```
  accounts
  ```
* Displays all current positions and account balances across connected accounts.

***

#### **2. Cancel `<ticker>`**

* **Command**:

  ```mathematica
  cancel <ticker>
  ```
* Cancels all active TWAPs and pending orders associated with the specified ticker.
* **Example**:

  ```mathematica
  cancel BTC
  ```

  * Stops all TWAPs and cancels all orders for BTC.

***

#### **3. Orders**

* **Command**:

  ```
  orders
  ```
* Lists all active orders currently placed across your accounts.
* **Caution**:\
  Be mindful when using this command if you have many scale orders set, as it may produce a large amount of output and cause spam in Telegram or Discord.

***

## **Key Notes and Best Practices**

1. **Defaults**:
   * `{size}` defaults to the first size in your trading configuration.
   * `{account}` defaults to the main account if unspecified.
2. **Testing**:
   * Test all commands in a safe environment with small sizes.

## Advanced Features

1. **Tracking Twitter Accounts**:
   * Add or remove Twitter accounts to monitor using simple commands:
     * **Add Account**:

       ```csharp
       add <handle>
       ```

       Example: `add elonmusk` will start tracking Elon Musk’s tweets.
     * **Delete Account**:

       ```css
       del <handle>
       ```

       Example: `del elonmusk` will stop tracking Elon Musk’s tweets.
     * **Add Account with extra tracking**

       ```css
       add <handle> all
       ```

       Example: `add elonmusk all` will start tracking Elon Musk’s tweets, retweets, follows, replies, bio and picture changes.
2. **Tracking Specific Tweets**:
   * Track specific tweets for potential deletions:

     ```diff
     !track <tweet URL>
     ```

     Example: `!track https://twitter.com/elonmusk/status/123456789` will notify you if that tweet is deleted.
3. **Shortening Keywords for Commands**
   1. **Custom Aliases**:
      * You can map commands to shorter keywords for faster execution.

        ```perl
        pos -> account
        ```

        * Instead of typing `account`, simply use `pos` to view all your balances and positions on Tree Terminal.
   2. **Why Use Aliases?**
      * Save time and effort during fast-paced trading.
      * Simplify repetitive actions with intuitive shortcuts
4. **Shortcuts for Closing TWAPs**:

   ```r
   cwap {coin} {account} -> c {coin} 1% twap {account}
   ```

   * Example: `cwap btc binance` will execute `c btc 1% twap binance`, closing 1% of your BTC position per interval on the Binance account.
5. **Left click entry last headline on size4**:

   ```sql
   l {last} {size4} -> ctrl+left
   ```

   * Pressing `ctrl+left` will long the coin from the last notification with the fourth trading size.
6. **Wait** command

   ```sql
   wait 500; l btc 5m

   l doge 1m; wait 500; l doge 2m
   ```

   * Wait allows you to pause before a command or between two commands.
   * Unit is always in ms, so 500ms would be 0.5s
7. **SL** command

   ```sql
   sl btc -2% 25%
   ```

   * sl 25% of the btc position 2% below current price.


---

# 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/command-line.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.
