> For the complete documentation index, see [llms.txt](https://quantitative-algorithms-by-max-h.gitbook.io/predator-trading-system/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://quantitative-algorithms-by-max-h.gitbook.io/predator-trading-system/overview/predator-script-documentation/predator-script/commands/trading.md).

# Trading

#### **BuyLongCommand**

Places a long buy order for a specified quantity of a ticker on a given trade date.

* **Constructor Parameters:**
  * `ticker (str)`: The ticker symbol for the asset to be bought.
  * `quantity (int)`: The number of units to be purchased.
  * `trade_date (str)`: The date on which the trade is executed.
* **Methods:**
  * `execute(self, data_provider, simulation)`: Retrieves the current price from `data_provider` and executes a buy order using the `simulation` object. Returns a dictionary containing the details of the trade.
* **Returns:** A dictionary with keys `action`, `type`, `ticker`, `quantity`, and `price`.

**Example Usage:**

```python
buy_command = BuyLongCommand(ticker="AAPL", quantity=10, trade_date="2023-09-02")
trade_details = buy_command.execute(data_provider, simulation)
```

***

**SellLongCommand**

Places a long sell order for a specified quantity of a ticker on a given trade date.

* **Constructor Parameters:**
  * `ticker (str)`: The ticker symbol for the asset to be sold.
  * `quantity (int)`: The number of units to be sold.
  * `trade_date (str)`: The date on which the trade is executed.
* **Methods:**
  * `execute(self, data_provider, simulation)`: Retrieves the current price from `data_provider` and executes a sell order using the `simulation` object. Returns a dictionary containing the details of the trade.
* **Returns:** A dictionary with keys `action`, `type`, `ticker`, `quantity`, and `price`.

**Example Usage:**

```python
sell_command = SellLongCommand(ticker="AAPL", quantity=10, trade_date="2023-09-02")
trade_details = sell_command.execute(data_provider, simulation)
```

***

**SellShort**

Places a short buy order (to close a short position) for a specified quantity of a ticker on a given trade date.

* **Constructor Parameters:**
  * `ticker (str)`: The ticker symbol for the asset to be bought.
  * `quantity (int)`: The number of units to be purchased.
  * `trade_date (str)`: The date on which the trade is executed.
* **Methods:**
  * `execute(self, data_provider, simulation)`: Retrieves the current price from `data_provider` and executes a buy order using the `simulation` object. Returns a dictionary containing the details of the trade.
* **Returns:** A dictionary with keys `action`, `type`, `ticker`, `quantity`, and `price`.

**Example Usage:**

```python
sell_short_command = SellShort(ticker="AAPL", quantity=10, trade_date="2023-09-02")
trade_details = sell_short_command.execute(data_provider, simulation)
```

***

**CoverShort**

Places a short sell order for a specified quantity of a ticker on a given trade date.

* **Constructor Parameters:**
  * `ticker (str)`: The ticker symbol for the asset to be sold.
  * `quantity (int)`: The number of units to be sold.
  * `trade_date (str)`: The date on which the trade is executed.
* **Methods:**
  * `execute(self, data_provider, simulation)`: Retrieves the current price from `data_provider` and executes a sell order using the `simulation` object. Returns a dictionary containing the details of the trade.
* **Returns:** A dictionary with keys `action`, `type`, `ticker`, `quantity`, and `price`.

**Example Usage:**

```python
cover_short_command = CoverShort(ticker="AAPL", quantity=10, trade_date="2023-09-02")
trade_details = cover_short_command.execute(data_provider, simulation)
```

####
