---
id: "T:cAlgo.API.HistoricalTrade"
kind: "interface"
namespace: "cAlgo.API"
url: "https://help.ctrader.com/ctrader-algo/references/Trading/History/HistoricalTrade/"
---

> Documentation index for agents: https://help.ctrader.com/ctrader-algo/llms.txt · machine index: https://help.ctrader.com/ctrader-algo/api.json

# HistoricalTrade (interface)

Represents the historical trade interface.

Environments: Desktop supported · CLI supported · Cloud supported.

## Definition

```csharp
public interface HistoricalTrade
```

## Examples

C#:

```csharp
var lastTenTrades = History.OrderByDescending(trade => trade.ClosingTime).Take(10);
foreach (var trade in lastTenTrades)
    Print("{0} {1} {2} units, opened {3}, closed {4}, net profit {5}", trade.SymbolName, trade.TradeType, trade.VolumeInUnits, trade.EntryTime, trade.ClosingTime, trade.NetProfit);
```

Python:

```python
lastTenTrades = sorted(api.History, key=lambda trade: trade.ClosingTime, reverse=True)[:10]
for trade in lastTenTrades:
    api.Print(f"{trade.SymbolName} {trade.TradeType} {trade.VolumeInUnits} units, opened {trade.EntryTime}, closed {trade.ClosingTime}, net profit {trade.NetProfit}")
```

C#:

```csharp
protected override void OnStart()
{
    Positions.Closed += OnPositionsClosed;
}

private void OnPositionsClosed(PositionClosedEventArgs args)
{
    var trade = History.FindByPositionId(args.Position.Id).LastOrDefault();
    if (trade != null)
        Print("Trade closed at {0}, pips {1}, balance {2}", trade.ClosingPrice, trade.Pips, trade.Balance);
}
```

Python:

```python
def on_start(self):
    api.Positions.Closed += self.on_positions_closed

def on_positions_closed(self, args):
    trades = api.History.FindByPositionId(args.Position.Id)
    if len(trades) > 0:
        trade = trades[len(trades) - 1]
        api.Print(f"Trade closed at {trade.ClosingPrice}, pips {trade.Pips}, balance {trade.Balance}")
```

## Properties

- `double Balance {get;}` — Account balance after the Deal was filled [details](https://help.ctrader.com/ctrader-algo/references/Trading/History/HistoricalTrade/Balance/index.md)
- `string Channel {get;}` — Gets the channel via which the trade was executed in a string format. [details](https://help.ctrader.com/ctrader-algo/references/Trading/History/HistoricalTrade/Channel/index.md)
- `Deal ClosingDeal {get;}` — Gets the closing deal. [details](https://help.ctrader.com/ctrader-algo/references/Trading/History/HistoricalTrade/ClosingDeal/index.md)
- `int ClosingDealId {get;}` — Gets the unique closing deal identifier. [details](https://help.ctrader.com/ctrader-algo/references/Trading/History/HistoricalTrade/ClosingDealId/index.md)
- `double ClosingPrice {get;}` — The execution price of the Closing Deal. [details](https://help.ctrader.com/ctrader-algo/references/Trading/History/HistoricalTrade/ClosingPrice/index.md)
- `DateTime ClosingTime {get;}` — Time of the Closing Deal. [details](https://help.ctrader.com/ctrader-algo/references/Trading/History/HistoricalTrade/ClosingTime/index.md)
- `string Comment {get;}` — The comment. [details](https://help.ctrader.com/ctrader-algo/references/Trading/History/HistoricalTrade/Comment/index.md)
- `double Commissions {get;}` — Commission owed. [details](https://help.ctrader.com/ctrader-algo/references/Trading/History/HistoricalTrade/Commissions/index.md)
- `double EntryPrice {get;}` — The VWAP (Volume Weighted Average Price) of the Opening Deals that are closed. [details](https://help.ctrader.com/ctrader-algo/references/Trading/History/HistoricalTrade/EntryPrice/index.md)
- `DateTime EntryTime {get;}` — Time of the Opening Deal, or the time of the first Opening deal that was closed. [details](https://help.ctrader.com/ctrader-algo/references/Trading/History/HistoricalTrade/EntryTime/index.md)
- `double GrossProfit {get;}` — Profit and loss before swaps and commission [details](https://help.ctrader.com/ctrader-algo/references/Trading/History/HistoricalTrade/GrossProfit/index.md)
- `string Label {get;}` — The label. [details](https://help.ctrader.com/ctrader-algo/references/Trading/History/HistoricalTrade/Label/index.md)
- `double NetProfit {get;}` — Profit and loss including swaps and commissions [details](https://help.ctrader.com/ctrader-algo/references/Trading/History/HistoricalTrade/NetProfit/index.md)
- `double Pips {get;}` — Represents the winning or loosing pips [details](https://help.ctrader.com/ctrader-algo/references/Trading/History/HistoricalTrade/Pips/index.md)
- `int PositionId {get;}` — Gets the position unique identifier. [details](https://help.ctrader.com/ctrader-algo/references/Trading/History/HistoricalTrade/PositionId/index.md)
- `double Quantity {get;}` — The Quantity (in lots) that was closed by the Closing Deal [details](https://help.ctrader.com/ctrader-algo/references/Trading/History/HistoricalTrade/Quantity/index.md)
- `double Swap {get;}` — Swap is the overnight interest rate if any, accrued on the position. [details](https://help.ctrader.com/ctrader-algo/references/Trading/History/HistoricalTrade/Swap/index.md)
- `Symbol Symbol {get;}` — Gets the trade symbol. [details](https://help.ctrader.com/ctrader-algo/references/Trading/History/HistoricalTrade/Symbol/index.md)
- `string SymbolName {get;}` — Gets the symbol name. [details](https://help.ctrader.com/ctrader-algo/references/Trading/History/HistoricalTrade/SymbolName/index.md)
- `TradeType TradeType {get;}` — The TradeType of the Opening Deal. [details](https://help.ctrader.com/ctrader-algo/references/Trading/History/HistoricalTrade/TradeType/index.md)
- `double VolumeInUnits {get;}` — The Volume that was closed by the Closing Deal. [details](https://help.ctrader.com/ctrader-algo/references/Trading/History/HistoricalTrade/VolumeInUnits/index.md)

## Deprecated members

- `string SymbolCode {get;}` — Use SymbolName instead
- `long Volume {get;}` — Use VolumeInUnits instead

