---
id: "T:cAlgo.API.TradeOperation"
kind: "class"
namespace: "cAlgo.API"
url: "https://help.ctrader.com/ctrader-algo/references/Trading/TradeOperation/"
---

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

# TradeOperation (class)

Provides access to the properties describing an asynchronous trade operation.

Environments: Desktop supported · CLI supported · Cloud supported.

## Definition

```csharp
public sealed class TradeOperation
```

## Examples

C#:

```csharp
var operation = ExecuteMarketOrderAsync(TradeType.Buy, SymbolName, 10000, "myLabel", result => Print("Order completed: {0}", result.IsSuccessful));
Print("Operation is executing: {0}", operation.IsExecuting);
```

Python:

```python
operation = api.ExecuteMarketOrderAsync(TradeType.Buy, api.SymbolName, 10000, "myLabel", lambda result: api.Print(f"Order completed: {result.IsSuccessful}"))
api.Print(f"Operation is executing: {operation.IsExecuting}")
```

C#:

```csharp
private TradeOperation _operation;

protected override void OnStart()
{
    _operation = ExecuteMarketOrderAsync(TradeType.Buy, SymbolName, Symbol.VolumeInUnitsMin, OnTradeResult);
}

protected override void OnTick()
{
    if (_operation != null && !_operation.IsExecuting)
    {
        Print(_operation.ToString());
        _operation = null;
    }
}

private void OnTradeResult(TradeResult result)
{
    Print("Trade operation successful: {0}", result.IsSuccessful);
}
```

Python:

```python
def on_start(self):
    self.operation = api.ExecuteMarketOrderAsync(TradeType.Buy, api.SymbolName, api.Symbol.VolumeInUnitsMin, self.on_trade_result)

def on_tick(self):
    if self.operation is not None and not self.operation.IsExecuting:
        api.Print(self.operation.ToString())
        self.operation = None

def on_trade_result(self, result):
    api.Print(f"Trade operation successful: {result.IsSuccessful}")
```

## Properties

- `public bool IsExecuting {get;}` — True if a trade operation is being executed, false if it completed [details](https://help.ctrader.com/ctrader-algo/references/Trading/TradeOperation/IsExecuting/index.md)
- `public TradeResult TradeResult {get;}` — The result of a trade operation [details](https://help.ctrader.com/ctrader-algo/references/Trading/TradeOperation/TradeResult/index.md)

