---
id: "T:cAlgo.API.RoundingMode"
kind: "enum"
namespace: "cAlgo.API"
url: "https://help.ctrader.com/ctrader-algo/references/MarketData/Symbols/RoundingMode/"
---

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

# RoundingMode (enum)

The rounding mode for normalizing trade volume.

Environments: Desktop supported · CLI supported · Cloud supported.

## Definition

```csharp
public enum RoundingMode
```

## Examples

C#:

```csharp
var riskAmount = Account.Balance * 0.01;
var volume = riskAmount / (20 * Symbol.PipValue);
var normalizedVolume = Symbol.NormalizeVolumeInUnits(volume, RoundingMode.Down);
Print("Raw volume {0}, normalized volume {1}", volume, normalizedVolume);
```

Python:

```python
riskAmount = api.Account.Balance * 0.01
volume = riskAmount / (20 * api.Symbol.PipValue)
normalizedVolume = api.Symbol.NormalizeVolumeInUnits(volume, RoundingMode.Down)
api.Print(f"Raw volume {volume}, normalized volume {normalizedVolume}")
```

C#:

```csharp
using cAlgo.API;

namespace cAlgo
{
    // This sample shows how to normalize volume based on different rounding modes
    public partial class NormalizingVolumeSample : Indicator
    {
        protected override void Initialize()
        {
            var volumeInUnits = Symbol.QuantityToVolumeInUnits(VolumeInLots);
            Print(Symbol.NormalizeVolumeInUnits(volumeInUnits, RoundingMode));
        }

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

Python:

```python
class NormalizingVolumeSample():
    def initialize(self):
        volumeInUnits = api.Symbol.QuantityToVolumeInUnits(api.VolumeInLots)
        api.Print(api.Symbol.NormalizeVolumeInUnits(volumeInUnits, api.RoundingMode))
```

config.json:

```json
{
  "AccessRights": "None",
  "TimeZone": "UTC",
  "IsOverlay": true,
  "Parameters": [
    {
      "Name": "VolumeInLots",
      "DisplayName": "Volume (Lots)",
      "Type": "Double",
      "DefaultValue": 0.01
    },
    {
      "Name": "RoundingMode",
      "DisplayName": "Rounding Mode",
      "Type": "Enum",
      "EnumTypeFullName": "cAlgo.API.RoundingMode",
      "DefaultValue": "ToNearest"
    }
  ]
}
```

## Values

- `RoundingMode.ToNearest` — Round value to the nearest tradable volume.
- `RoundingMode.Down` — Round value down to tradable volume.
- `RoundingMode.Up` — Round value up to tradable volume.

