Skip to content

ErrorCode

enum cAlgo.API

DesktopCLICloud

Enumeration of standard error codes.

Definition

public enum ErrorCode

Namespace: cAlgo.API · Group: Trading

Remarks

Error codes are readable descriptions of the responses returned by the server.

Examples

Example 1

var result = ExecuteMarketOrder(TradeType.Buy, SymbolName, 10000, "myLabel", 20, 40);
if (!result.IsSuccessful)
{
    switch (result.Error)
    {
        case ErrorCode.NoMoney:
            Print("Not enough money to open the position");
            break;
        case ErrorCode.MarketClosed:
            Print("The market is closed");
            break;
        default:
            Print("Order failed: {0}", result.Error);
            break;
    }
}
result = api.ExecuteMarketOrder(TradeType.Buy, api.SymbolName, 10000, "myLabel", 20, 40)
if not result.IsSuccessful:
    if result.Error == ErrorCode.NoMoney:
        api.Print("Not enough money to open the position")
    elif result.Error == ErrorCode.MarketClosed:
        api.Print("The market is closed")
    else:
        api.Print(f"Order failed: {result.Error}")

Example 2

protected override void OnError(Error error)
{
    if (error.Code == ErrorCode.BadVolume)
        Print("Bad volume");
    else if (error.Code == ErrorCode.Disconnected)
        Print("Disconnected");
    else
        Print("Error: {0}", error.Code);
}
def on_error(self, error):
    if error.Code == ErrorCode.BadVolume:
        api.Print("Bad volume")
    elif error.Code == ErrorCode.Disconnected:
        api.Print("Disconnected")
    else:
        api.Print(f"Error: {error.Code}")

Values

Name Value Description
TechnicalError 0 A generic technical error with a trade request.
BadVolume 1 The volume value is not valid
NoMoney 2 There are not enough money in the account to trade with.
MarketClosed 3 The market is closed.
Disconnected 4 The server is disconnected.
EntityNotFound 5 Position does not exist.
Timeout 6 Operation timed out.
UnknownSymbol 7 Unknown symbol.
InvalidStopLossTakeProfit 8 The invalid Stop Loss or Take Profit.
InvalidRequest 9 The invalid request.
NoTradingPermission 10 Occurs when accessing trading API without trading permission.