Skip to content

GetFitnessArgs

interface cAlgo.API

DesktopCLICloud

Represents the custom fitness calculation interface.

Definition

public interface GetFitnessArgs

Namespace: cAlgo.API · Group: Optimization

Examples

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;
        }
    }
}
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
{
  "AccessRights": "None",
  "TimeZone": "UTC"
}

Properties

Name Description
AverageTradeDesktopCLIClouddouble Gets the average profit for all trades in account deposit currency.
CommissionsDesktopCLIClouddouble Gets the commissions of all trades in account deposit currency.
EquityDesktopCLIClouddouble Gets the equity of the account (balance plus unrealized profit and loss).
HistoryDesktopCLICloudHistory Gets all the historical trades.
LosingTradesDesktopCLIClouddouble Gets total number of losing trades.
MaxBalanceDrawdownDesktopCLIClouddouble Gets the maximum amount of balance drawdown in account deposit currency.
MaxBalanceDrawdownPercentagesDesktopCLIClouddouble Gets the maximum amount of balance drawdown in percentage (ex: 40%). It can return a positive value between 0-100.
MaxEquityDrawdownDesktopCLIClouddouble Gets the maximum amount of equity drawdown in account deposit currency.
MaxEquityDrawdownPercentagesDesktopCLIClouddouble Gets the maximum amount of equity drawdown in percentage (ex: 40%). It can return a positive value between 0-100.
NetProfitDesktopCLIClouddouble Gets the net profit of all trades in account deposit currency.
PendingOrdersDesktopCLICloudPendingOrders Gets all pending orders.
PositionsDesktopCLICloudPositions Gets all open positions.
ProfitFactorDesktopCLIClouddouble Gets the Profit Factor - the ratio of Total Net Profit divided by the Total Net Loss.
SwapsDesktopCLIClouddouble Gets the swaps of all trades in account deposit currency.
TotalTradesDesktopCLIClouddouble Gets the total number of trades taken.
WinningTradesDesktopCLIClouddouble Gets the total number of winning trades.
Deprecated members (2)
  • double SharpeRatio {get;} — Deprecated.
  • double SortinoRatio {get;} — Deprecated.