Skip to content

ErrorCode

Summary

Enumeration of standard error codes.

Remarks

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

Signature

1
public enum ErrorCode

Namespace

cAlgo.API

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 using cAlgo.API;
 namespace cAlgo.Robots;
 [Robot(AccessRights = AccessRights.None, AddIndicators = true)]
 public class ConsoleTest : Robot
 {
     protected override void OnError(Error error)
     {
         //  Print the error to the log
         switch (error.Code)
         {
             case ErrorCode.BadVolume:
                 Print("Bad Volume");
                 break;
             case ErrorCode.TechnicalError:
                 Print("Technical Error");
                 break;
             case ErrorCode.NoMoney:
                 Print("No Money");
                 break;
             case ErrorCode.Disconnected:
                 Print("Disconnected");
                 break;
             case ErrorCode.MarketClosed:
                 Print("Market Closed");
                 break;
         }
     }
 }
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
 import clr
 clr.AddReference("cAlgo.API")
 # Import cAlgo API types
 from cAlgo.API import *
 # Import trading wrapper functions
 from robot_wrapper import *
 class Test():
     def on_error(self, error):
         #  Print the error to the log
         match error.Code:
             case ErrorCode.BadVolume:
                 print("Bad Volume")
             case ErrorCode.TechnicalError:
                 print("Technical Error")
             case ErrorCode.NoMoney:
                 print("No Money")
             case ErrorCode.Disconnected:
                 print("Disconnected")
             case ErrorCode.MarketClosed:
                 print("Market Closed")

Fields

TechnicalError

Summary

A generic technical error with a trade request.

Signature

1
ErrorCode.TechnicalError;

Return Value

ErrorCode

Examples

1
2
3
4
5
6
7
 protected override void OnError(Error error)
 {
     if (error.Code == ErrorCode.TechnicalError)
     {
         Print("Error. Confirm that the trade command parameters are valid");
     }
 }

BadVolume

Summary

The volume value is not valid

Signature

1
ErrorCode.BadVolume;

Return Value

ErrorCode

Examples

1
2
3
4
5
6
7
 protected override void OnError(Error error)
 {
     if (error.Code == ErrorCode.BadVolume)
     {
         Print("Invalid Volume amount");
     }
 }

NoMoney

Summary

There are not enough money in the account to trade with.

Signature

1
ErrorCode.NoMoney;

Return Value

ErrorCode

Examples

1
2
3
4
5
6
7
 protected override void OnError(Error error)
 {
     if (error.Code == ErrorCode.NoMoney)
     {
         Print("Not enough money to trade.");
     }
 }

MarketClosed

Summary

The market is closed.

Signature

1
ErrorCode.MarketClosed;

Return Value

ErrorCode

Examples

1
2
3
4
5
6
7
 protected override void OnError(Error error)
 {
     if (error.Code == ErrorCode.MarketClosed)
     {
         Print("The market is closed.");
     }
 }

Disconnected

Summary

The server is disconnected.

Signature

1
ErrorCode.Disconnected;

Return Value

ErrorCode

Examples

1
2
3
4
5
6
7
 protected override void OnError(Error error)
 {
     if (error.Code == ErrorCode.Disconnected)
     {
         Print("The server is disconnected.");
     }
 }

EntityNotFound

Summary

Position does not exist.

Signature

1
ErrorCode.EntityNotFound;

Return Value

ErrorCode

Examples

1
2
3
4
5
6
7
 protected override void OnError(Error error)
 {
     if (error.Code == ErrorCode.EntityNotFound)
     {
         Print("Position not found");
     }
 }

Timeout

Summary

Operation timed out.

Signature

1
ErrorCode.Timeout;

Return Value

ErrorCode

Examples

1
2
3
4
5
6
7
 protected override void OnError(Error error)
 {
     if (error.Code == ErrorCode.Timeout)
     {
         Print("Operation timed out");
     }
 }

UnknownSymbol

Summary

Unknown symbol.

Signature

1
ErrorCode.UnknownSymbol;

Return Value

ErrorCode

Examples

1
2
3
4
5
6
7
 protected override void OnError(Error error)
 {
     if (error.Code == ErrorCode.UnknownSymbol)
     {
         Print("Unknown symbol.");
     }
 }

InvalidStopLossTakeProfit

Summary

The invalid Stop Loss or Take Profit.

Signature

1
ErrorCode.InvalidStopLossTakeProfit;

Return Value

ErrorCode

Examples

1
2
3
4
5
6
7
 protected override void OnError(Error error)
 {
     if (error.Code == ErrorCode.InvalidStopLossTakeProfit)
     {
         Print("The invalid Stop Loss or Take Profit.");
     }
 }

InvalidRequest

Summary

The invalid request.

Signature

1
ErrorCode.InvalidRequest;

Return Value

ErrorCode

Examples

1
2
3
4
5
6
7
 protected override void OnError(Error error)
 {
     if (error.Code == ErrorCode.InvalidRequest)
     {
         Print("The invalid request.");
     }
 }

NoTradingPermission

Summary

Occurs when accessing trading API without trading permission.

Signature

1
ErrorCode.NoTradingPermission;

Return Value

ErrorCode

Examples

1
2
3
4
5
6
7
 protected override void OnError(Error error)
 {
     if (error.Code == ErrorCode.NoTradingPermission)
     {
         Print("The invalid request.");
     }
 }