---
id: "M:cAlgo.API.Internals.Algo.RefreshData"
kind: "method"
type: "T:cAlgo.API.Internals.Algo"
url: "https://help.ctrader.com/ctrader-algo/references/General/Algo/RefreshData/"
---

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

# Algo.RefreshData

Member of [Algo](https://help.ctrader.com/ctrader-algo/references/General/Algo/index.md).

## RefreshData()

Updates Bars, Positions, PendingOrders, History, etc. And sends postponed events after Thread sleep call. If you put the main thread on sleep by calling Thread sleep method then you have to call RefreshData after Thread wakes up to send the postponed events while thread was sleeping.

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
public void RefreshData()
```

Python:

```python
api.RefreshData() -> None
```

### Examples

C#:

```csharp
var operations = new List<TradeOperation>();
for (var i = 0; i < 5; i++)
    operations.Add(ExecuteMarketOrderAsync(TradeType.Buy, SymbolName, Symbol.VolumeInUnitsMin));
while (operations.Any(operation => operation.IsExecuting))
{
    System.Threading.Thread.Sleep(100);
    // Without RefreshData the trade results are not delivered while the thread sleeps
    RefreshData();
}
Print("Open positions: {0}", Positions.Count);
```

Python:

```python
operations = [api.ExecuteMarketOrderAsync(TradeType.Buy, api.SymbolName, api.Symbol.VolumeInUnitsMin) for i in range(5)]
while any(operation.IsExecuting for operation in operations):
    api.Sleep(100)
    # Without RefreshData the trade results are not delivered while the thread sleeps
    api.RefreshData()
api.Print(f"Open positions: {api.Positions.Count}")
```

