# Algorithmic trading

Algorithmic trading is the use of computer-coded rules to generate, route, or execute orders automatically according to specified conditions.

## What it means

An algorithm can handle different parts of a trade: deciding when an order is eligible, dividing a large order into smaller orders, or sending those orders to a broker or trading venue. The rules might depend on time, price, trading volume, or other specified conditions. Some algorithms generate trading signals; others only execute an order that someone has already decided to place.

The distinction matters. An execution algorithm may schedule a purchase without deciding whether the stock belongs in an investor’s portfolio. Automation also does not ensure a fill at a particular price. Actual fills depend on available liquidity, order conditions, market movements, and the broker’s execution arrangements.

## How it is calculated

Algorithmic trading has no single defining formula. A simple time-weighted execution schedule can use `q = Q / N`, where:

- `q` is the target number of shares in each interval.
- `Q` is the total number of shares in the order.
- `N` is the number of equal time intervals over which the order is scheduled.

The formula gives a schedule, not an expected fill price. If `Q / N` is not a whole number, the share quantities must be rounded or allocated across intervals so they sum to `Q`. A live algorithm may also adjust or leave shares unfilled when its price limits or other conditions are not met.

## Worked example

Suppose, hypothetically, an investor has already decided to purchase 1,000 shares of a stock. To illustrate scheduling—not a recommendation—assume an execution algorithm is instructed to split the order across five equal time intervals.

1. Set `Q = 1,000 shares` and `N = 5 intervals`.
2. Calculate `q = 1,000 / 5 = 200 shares per interval`.
3. The algorithm targets five orders of 200 shares each, for a total of 1,000 shares.

Now suppose the hypothetical fills are 200 shares at US$10.00, 200 at US$10.01, 200 at US$10.02, 200 at US$10.03, and 200 at US$10.04. The volume-weighted average fill price is `(200 × 10.00 + 200 × 10.01 + 200 × 10.02 + 200 × 10.03 + 200 × 10.04) / 1,000 = US$10.02 per share`. The gross purchase value is US$10,020, excluding commissions and other charges. Those fills are illustrative: dividing an order does not guarantee that every portion executes.

## Why it matters before you trade

An algorithm’s instructions affect execution, but they do not remove trading costs or risk. Before placing an order, relevant checks include the bid-ask spread, order size relative to average daily volume, possible market impact, volatility, and any price or timing constraints. A schedule that spreads an order over time may reduce the amount sought at once while leaving some shares exposed to later price changes or unfilled.

It is also useful to distinguish an execution benchmark from a promise. Comparing fills with an arrival price or a volume-weighted average price can describe what happened; neither benchmark guarantees what another execution method would have achieved. The appropriate checks depend on the stock, order size, and stated execution conditions.

## How PreTrAIde uses it

PreTrAIde provides pre-trade analysis, not algorithmic order execution. A user builds a stock basket with a buy or sell side, quantity, and execution conditions for each line. Before any order is placed, PreTrAIde assesses the basket and each line and returns a GO, NO-GO, or MODIFY verdict, a model-estimated success probability, a risk assessment, a suggested execution strategy, and plain-language reasoning. These verdicts support decisions; they are not trade recommendations.

Its quantitative layer estimates factors relevant to execution, including bid-ask spread, participation in daily volume, and market impact. PreTrAIde never receives, transmits, or executes an order. Users place any trades themselves with their own broker.

## Common mistakes

- **Treating all algorithms as stock-picking systems.** An execution algorithm can act on a trade decision without making that decision.
- **Assuming an order schedule guarantees fills.** A target of 200 shares per interval is not a completed trade.
- **Confusing automation with low cost.** Spreads, market impact, commissions, and price movements can still affect the result.
- **Assuming a pre-trade check places orders.** Analysis and execution are separate steps.

---
Source: https://pretraide.com/glossary/algorithmic-trading
