---
id: "T:cAlgo.API.Internals.IAccount"
kind: "interface"
namespace: "cAlgo.API.Internals"
url: "https://help.ctrader.com/ctrader-algo/references/Account/IAccount/"
---

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

# IAccount (interface)

Contains the current account information.

Environments: Desktop supported · CLI supported · Cloud supported.

## Definition

```csharp
public interface IAccount
```

## Examples

C#:

```csharp
Print("Balance: {0} {1}", Account.Balance, Account.Asset.Name);
Print("Equity: {0}, Margin: {1}, Free margin: {2}", Account.Equity, Account.Margin, Account.FreeMargin);
// Margin Level = Equity / Margin * 100, null when no margin is used
if (Account.MarginLevel.HasValue)
    Print("Margin level: {0}%", Account.MarginLevel.Value);
```

Python:

```python
api.Print(f"Balance: {api.Account.Balance} {api.Account.Asset.Name}")
api.Print(f"Equity: {api.Account.Equity}, Margin: {api.Account.Margin}, Free margin: {api.Account.FreeMargin}")
# Margin Level = Equity / Margin * 100, None when no margin is used
if api.Account.MarginLevel is not None:
    api.Print(f"Margin level: {api.Account.MarginLevel}%")
```

config.json:

```json
{
  "AccessRights": "None",
  "TimeZone": "UTC",
  "IsOverlay": true
}
```

C#:

```csharp
using cAlgo.API;

namespace cAlgo
{
    // This sample indicator shows how to use Account object properties to get your trading account data
    public partial class AccountSample : Indicator
    {
        protected override void Initialize()
        {
            var grid = new Grid(16, 2)
            {
                BackgroundColor = Color.Gold,
                Opacity = 0.6,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
            };

            var style = new Style();

            style.Set(ControlProperty.Padding, 5);
            style.Set(ControlProperty.Margin, 5);
            style.Set(ControlProperty.FontWeight, FontWeight.ExtraBold);
            style.Set(ControlProperty.BackgroundColor, Color.Black);

            grid.AddChild(new TextBlock { Text = "Account Info", Style = style, HorizontalAlignment = HorizontalAlignment.Center }, 0, 0, 1, 2);

            grid.AddChild(new TextBlock { Text = "Type", Style = style }, 1, 0);
            grid.AddChild(new TextBlock { Text = Account.AccountType.ToString(), Style = style }, 1, 1);

            grid.AddChild(new TextBlock { Text = "Is Live", Style = style }, 2, 0);
            grid.AddChild(new TextBlock { Text = Account.IsLive.ToString(), Style = style }, 2, 1);

            grid.AddChild(new TextBlock { Text = "Balance", Style = style }, 3, 0);
            grid.AddChild(new TextBlock { Text = Account.Balance.ToString(), Style = style }, 3, 1);

            grid.AddChild(new TextBlock { Text = "Broker Name", Style = style }, 4, 0);
            grid.AddChild(new TextBlock { Text = Account.BrokerName, Style = style }, 4, 1);

            grid.AddChild(new TextBlock { Text = "Currency", Style = style }, 5, 0);
            grid.AddChild(new TextBlock { Text = Account.Asset.Name, Style = style }, 5, 1);

            grid.AddChild(new TextBlock { Text = "Number", Style = style }, 6, 0);
            grid.AddChild(new TextBlock { Text = Account.Number.ToString(), Style = style }, 6, 1);

            grid.AddChild(new TextBlock { Text = "Equity", Style = style }, 7, 0);
            grid.AddChild(new TextBlock { Text = Account.Equity.ToString(), Style = style }, 7, 1);

            grid.AddChild(new TextBlock { Text = "Free Margin", Style = style }, 8, 0);
            grid.AddChild(new TextBlock { Text = Account.FreeMargin.ToString(), Style = style }, 8, 1);

            grid.AddChild(new TextBlock { Text = "Margin", Style = style }, 9, 0);
            grid.AddChild(new TextBlock { Text = Account.Margin.ToString(), Style = style }, 9, 1);

            grid.AddChild(new TextBlock { Text = "Margin Level", Style = style }, 10, 0);
            grid.AddChild(new TextBlock { Text = Account.MarginLevel.ToString(), Style = style }, 10, 1);

            grid.AddChild(new TextBlock { Text = "Precise Leverage", Style = style }, 11, 0);
            grid.AddChild(new TextBlock { Text = Account.PreciseLeverage.ToString(), Style = style }, 11, 1);

            grid.AddChild(new TextBlock { Text = "Stop Out Level", Style = style }, 12, 0);
            grid.AddChild(new TextBlock { Text = Account.StopOutLevel.ToString(), Style = style }, 12, 1);

            grid.AddChild(new TextBlock { Text = "Unrealized Gross Profit", Style = style }, 13, 0);
            grid.AddChild(new TextBlock { Text = Account.UnrealizedGrossProfit.ToString(), Style = style }, 13, 1);

            grid.AddChild(new TextBlock { Text = "Unrealized Net Profit", Style = style }, 14, 0);
            grid.AddChild(new TextBlock { Text = Account.UnrealizedNetProfit.ToString(), Style = style }, 14, 1);

            grid.AddChild(new TextBlock { Text = "User Id", Style = style }, 15, 0);
            grid.AddChild(new TextBlock { Text = Account.UserId.ToString(), Style = style }, 15, 1);

            Chart.AddControl(grid);
        }

        public override void Calculate(int index)
        {
        }
    }
}
```

Python:

```python
import clr
clr.AddReference("cAlgo.API")

from cAlgo.API import *

class AccountSample():
    def initialize(self):
        grid = Grid(16, 2)
        grid.BackgroundColor = Color.Gold
        grid.Opacity = 0.6
        grid.HorizontalAlignment = HorizontalAlignment.Center
        grid.VerticalAlignment = VerticalAlignment.Center

        self.style = Style()

        self.style.Set(ControlProperty.Padding, 5)
        self.style.Set(ControlProperty.Margin, 5)
        self.style.Set(ControlProperty.FontWeight, FontWeight.ExtraBold)
        self.style.Set(ControlProperty.BackgroundColor, Color.Black)

        headerTextBox = self.getTextBlock("Account Info")
        headerTextBox.HorizontalAlignment = HorizontalAlignment.Center

        grid.AddChild(headerTextBox, 0, 0, 1, 2)
        grid.AddChild(self.getTextBlock("Type"), 1, 0)
        grid.AddChild(self.getTextBlock(str(api.Account.AccountType)), 1, 1)
        grid.AddChild(self.getTextBlock("Is Live"), 2, 0)
        grid.AddChild(self.getTextBlock(str(api.Account.IsLive)), 2, 1)
        grid.AddChild(self.getTextBlock("Balance"), 3, 0)
        grid.AddChild(self.getTextBlock(str(api.Account.Balance)), 3, 1)
        grid.AddChild(self.getTextBlock("Broker Name"), 4, 0)
        grid.AddChild(self.getTextBlock(api.Account.BrokerName), 4, 1)
        grid.AddChild(self.getTextBlock("Currency"), 5, 0)
        grid.AddChild(self.getTextBlock(api.Account.Asset.Name), 5, 1)
        grid.AddChild(self.getTextBlock("Number"), 6, 0)
        grid.AddChild(self.getTextBlock(str(api.Account.Number)), 6, 1)
        grid.AddChild(self.getTextBlock("Equity"), 7, 0)
        grid.AddChild(self.getTextBlock(str(api.Account.Equity)), 7, 1)
        grid.AddChild(self.getTextBlock("Free Margin"), 8, 0)
        grid.AddChild(self.getTextBlock(str(api.Account.FreeMargin)), 8, 1)
        grid.AddChild(self.getTextBlock("Margin"), 9, 0)
        grid.AddChild(self.getTextBlock(str(api.Account.Margin)), 9, 1)
        grid.AddChild(self.getTextBlock("Margin Level"), 10, 0)
        grid.AddChild(self.getTextBlock(str(api.Account.MarginLevel)), 10, 1)
        grid.AddChild(self.getTextBlock("Precise Leverage"), 11, 0)
        grid.AddChild(self.getTextBlock(str(api.Account.PreciseLeverage)), 11, 1)
        grid.AddChild(self.getTextBlock("Stop Out Level"), 12, 0)
        grid.AddChild(self.getTextBlock(str(api.Account.StopOutLevel)), 12, 1)
        grid.AddChild(self.getTextBlock("Unrealized Gross Profit"), 13, 0)
        grid.AddChild(self.getTextBlock(str(api.Account.UnrealizedGrossProfit)), 13, 1)
        grid.AddChild(self.getTextBlock("Unrealized Net Profit"), 14, 0)
        grid.AddChild(self.getTextBlock(str(api.Account.UnrealizedNetProfit)), 14, 1)
        grid.AddChild(self.getTextBlock("User Id"), 15, 0)
        grid.AddChild(self.getTextBlock(str(api.Account.UserId)), 15, 1)

        api.Chart.AddControl(grid)

    def getTextBlock(self, text):
        textBlock = TextBlock()
        textBlock.Text = text
        textBlock.Style = self.style
        return textBlock
```

## Properties

- `AccountType AccountType {get;}` — Returns the current account type. [details](https://help.ctrader.com/ctrader-algo/references/Account/IAccount/AccountType/index.md)
- `Asset Asset {get;}` — Gets the account deposit asset/currency [details](https://help.ctrader.com/ctrader-algo/references/Account/IAccount/Asset/index.md)
- `double Balance {get;}` — Returns the balance of the current account. [details](https://help.ctrader.com/ctrader-algo/references/Account/IAccount/Balance/index.md)
- `string BrokerName {get;}` — Returns the broker name of the current account. [details](https://help.ctrader.com/ctrader-algo/references/Account/IAccount/BrokerName/index.md)
- `DateTime CreationTime {get;}` — Gets the account creation time. [details](https://help.ctrader.com/ctrader-algo/references/Account/IAccount/CreationTime/index.md)
- `double Credit {get;}` — Gets the credit of the current account. [details](https://help.ctrader.com/ctrader-algo/references/Account/IAccount/Credit/index.md)
- `double Equity {get;}` — Represents the equity of the current account (balance minus Unrealized Net Loss plus Unrealized Net Profit plus Bonus). [details](https://help.ctrader.com/ctrader-algo/references/Account/IAccount/Equity/index.md)
- `double FreeMargin {get;}` — Represents the free margin of the current account. [details](https://help.ctrader.com/ctrader-algo/references/Account/IAccount/FreeMargin/index.md)
- `bool IsLive {get;}` — Defines if the account is Live or Demo. True if the Account is Live, False if it is a Demo. [details](https://help.ctrader.com/ctrader-algo/references/Account/IAccount/IsLive/index.md)
- `double Margin {get;}` — Represents the margin of the current account. [details](https://help.ctrader.com/ctrader-algo/references/Account/IAccount/Margin/index.md)
- `double? MarginLevel {get;}` — Represents the margin level of the current account. Margin Level (in %) is calculated using this formula: Equity / Margin * 100 [details](https://help.ctrader.com/ctrader-algo/references/Account/IAccount/MarginLevel/index.md)
- `int Number {get;}` — Returns the number of the current account, e.g. 123456. [details](https://help.ctrader.com/ctrader-algo/references/Account/IAccount/Number/index.md)
- `double PreciseLeverage {get;}` — Gets the precise account leverage value. [details](https://help.ctrader.com/ctrader-algo/references/Account/IAccount/PreciseLeverage/index.md)
- `double StopOutLevel {get;}` — Stop Out level is a lowest allowed Margin Level for account. If Margin Level is less than Stop Out, position will be closed sequentially until Margin Level is greater than Stop Out. [details](https://help.ctrader.com/ctrader-algo/references/Account/IAccount/StopOutLevel/index.md)
- `TotalMarginCalculationType TotalMarginCalculationType {get;}` — Type of total margin requirements per Symbol. [details](https://help.ctrader.com/ctrader-algo/references/Account/IAccount/TotalMarginCalculationType/index.md)
- `double UnrealizedGrossProfit {get;}` — Gets the Unrealized Gross profit value. [details](https://help.ctrader.com/ctrader-algo/references/Account/IAccount/UnrealizedGrossProfit/index.md)
- `double UnrealizedNetProfit {get;}` — Gets the Unrealized Net profit value. [details](https://help.ctrader.com/ctrader-algo/references/Account/IAccount/UnrealizedNetProfit/index.md)
- `long UserId {get;}` — Gets the user ID. [details](https://help.ctrader.com/ctrader-algo/references/Account/IAccount/UserId/index.md)
- `string UserNickName {get;}` — Gets the user nick name. [details](https://help.ctrader.com/ctrader-algo/references/Account/IAccount/UserNickName/index.md)

## Events

- `event Action<AccountSwitchedEventArgs> Switched;` — Occurs when user switch his account. [details](https://help.ctrader.com/ctrader-algo/references/Account/IAccount/Switched/index.md)

## Deprecated members

- `string Currency {get;}` — Use Account.Asset.Name instead
- `int Leverage {get;}` — Use PreciseLeverage instead
- `IReadonlyList<Position> Positions {get;}` — Use Positions instead
- `IReadonlyList<PendingOrder> PendingOrders {get;}` — Use PendingOrders instead

