---
id: "T:cAlgo.API.GetFitnessArgs"
kind: "interface"
namespace: "cAlgo.API"
url: "https://help.ctrader.com/ctrader-algo/references/Optimization/GetFitnessArgs/"
---

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

# GetFitnessArgs (interface)

Represents the custom fitness calculation interface.

Environments: Desktop supported · CLI supported · Cloud supported.

## Definition

```csharp
public interface GetFitnessArgs
```

## Examples

C#:

```csharp
using cAlgo.API;

namespace cAlgo.Robots
{
    // This sample shows how to use the GetFitnessArgs to change the default fitness metric of optimizer
    public partial class Test : Robot
    {
        protected override void OnStart()
        {
        }

        protected override double GetFitness(GetFitnessArgs args)
        {
            // Here we are using the win rate as fitness
            // You can use any other value by combining the values of GetFitnessArgs object properties
            return args.TotalTrades == 0 ? 0 : args.WinningTrades / args.TotalTrades;
        }
    }
}
```

Python:

```python
import clr

clr.AddReference("cAlgo.API")

# Import cAlgo API types
from cAlgo.API import *

# Import trading wrapper functions
from robot_wrapper import *

class GetFitnessArgsSample():
    def get_fitness(self, args):
        # Here we are using the win rate as fitness
        # You can use any other value by combining the values of GetFitnessArgs object properties
        if args.TotalTrades == 0:
            return 0
        return args.WinningTrades / args.TotalTrades
```

config.json:

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

## Properties

- `double AverageTrade {get;}` — Gets the average profit for all trades in account deposit currency. [details](https://help.ctrader.com/ctrader-algo/references/Optimization/GetFitnessArgs/AverageTrade/index.md)
- `double Commissions {get;}` — Gets the commissions of all trades in account deposit currency. [details](https://help.ctrader.com/ctrader-algo/references/Optimization/GetFitnessArgs/Commissions/index.md)
- `double Equity {get;}` — Gets the equity of the account (balance plus unrealized profit and loss). [details](https://help.ctrader.com/ctrader-algo/references/Optimization/GetFitnessArgs/Equity/index.md)
- `History History {get;}` — Gets all the historical trades. [details](https://help.ctrader.com/ctrader-algo/references/Optimization/GetFitnessArgs/History/index.md)
- `double LosingTrades {get;}` — Gets total number of losing trades. [details](https://help.ctrader.com/ctrader-algo/references/Optimization/GetFitnessArgs/LosingTrades/index.md)
- `double MaxBalanceDrawdown {get;}` — Gets the maximum amount of balance drawdown in account deposit currency. [details](https://help.ctrader.com/ctrader-algo/references/Optimization/GetFitnessArgs/MaxBalanceDrawdown/index.md)
- `double MaxBalanceDrawdownPercentages {get;}` — Gets the maximum amount of balance drawdown in percentage (ex: 40%). It can return a positive value between 0-100. [details](https://help.ctrader.com/ctrader-algo/references/Optimization/GetFitnessArgs/MaxBalanceDrawdownPercentages/index.md)
- `double MaxEquityDrawdown {get;}` — Gets the maximum amount of equity drawdown in account deposit currency. [details](https://help.ctrader.com/ctrader-algo/references/Optimization/GetFitnessArgs/MaxEquityDrawdown/index.md)
- `double MaxEquityDrawdownPercentages {get;}` — Gets the maximum amount of equity drawdown in percentage (ex: 40%). It can return a positive value between 0-100. [details](https://help.ctrader.com/ctrader-algo/references/Optimization/GetFitnessArgs/MaxEquityDrawdownPercentages/index.md)
- `double NetProfit {get;}` — Gets the net profit of all trades in account deposit currency. [details](https://help.ctrader.com/ctrader-algo/references/Optimization/GetFitnessArgs/NetProfit/index.md)
- `PendingOrders PendingOrders {get;}` — Gets all pending orders. [details](https://help.ctrader.com/ctrader-algo/references/Optimization/GetFitnessArgs/PendingOrders/index.md)
- `Positions Positions {get;}` — Gets all open positions. [details](https://help.ctrader.com/ctrader-algo/references/Optimization/GetFitnessArgs/Positions/index.md)
- `double ProfitFactor {get;}` — Gets the Profit Factor - the ratio of Total Net Profit divided by the Total Net Loss. [details](https://help.ctrader.com/ctrader-algo/references/Optimization/GetFitnessArgs/ProfitFactor/index.md)
- `double Swaps {get;}` — Gets the swaps of all trades in account deposit currency. [details](https://help.ctrader.com/ctrader-algo/references/Optimization/GetFitnessArgs/Swaps/index.md)
- `double TotalTrades {get;}` — Gets the total number of trades taken. [details](https://help.ctrader.com/ctrader-algo/references/Optimization/GetFitnessArgs/TotalTrades/index.md)
- `double WinningTrades {get;}` — Gets the total number of winning trades. [details](https://help.ctrader.com/ctrader-algo/references/Optimization/GetFitnessArgs/WinningTrades/index.md)

## Deprecated members

- `double SharpeRatio {get;}` — Deprecated.
- `double SortinoRatio {get;}` — Deprecated.

