Replies

ctid402288
16 Dec 2024, 10:50 ( Updated at: 16 Dec 2024, 10:52 )

RE: RE: CAlgo objects failing to serialize via ToJson

ctid402288 said: 

EDG777 said: 

I think the error is due to the presence of curly braces that the formatting system interprets as placeholders. To fix it, escape your braces or ensure the string passed to the logging/printing function doesn’t contain unintended formatting tokens.
Maybe it will help:

var jsonString = Account.ToJSON();jsonString = jsonString.Replace("{", "{{").Replace("}", "}}");Print("[OnStart] Account:\n" + jsonString);

Thank you for the tip. It worked fine for the serialising case. But l am finding deserializing the resulting json string back to the object errors with the following:-

15/12/2024 08:35:50.035 | Info | [OnStart] {JsonReaderException} Exception : Invalid property identifier character: {. Path '', line 1, position 1.

This error occurs for both Newtonsoft.json and system.text.json

I finally got this to work. It turns out that the string from ToJSON is not a valid Json. To make it a valid json you also have to convert all double quotes in the string into single quotes as below:-

jsonString = jsonString.Replace("{", "{{").Replace("}", "}}").Replace("\"", "'");

This would transform the string into a valid json which can be deserialized or sent over http. [Always a good etiquette to provide the solution so other can benefit from it]


@ctid402288

ctid402288
16 Dec 2024, 10:40 ( Updated at: 16 Dec 2024, 10:54 )

RE: Update to net8.0

firemyst said: 

Definitely!

 

It should be a relatively easy transition/update since they already have version 6 supported.

Net6.0 is officially out of support  as of 12th November 2024. Which implies CTrader.Automate 1.0.9 is now not production worthy. 

 


@ctid402288

ctid402288
15 Dec 2024, 08:41

RE: CAlgo objects failing to serialize via ToJson

EDG777 said: 

I think the error is due to the presence of curly braces that the formatting system interprets as placeholders. To fix it, escape your braces or ensure the string passed to the logging/printing function doesn’t contain unintended formatting tokens.
Maybe it will help:

var jsonString = Account.ToJSON();jsonString = jsonString.Replace("{", "{{").Replace("}", "}}");Print("[OnStart] Account:\n" + jsonString);

Thank you for the tip. It worked fine for the serialising case. But l am finding deserializing the resulting json string back to the object errors with the following:-

15/12/2024 08:35:50.035 | Info | [OnStart] {JsonReaderException} Exception : Invalid property identifier character: {. Path '', line 1, position 1.

This error occurs for both Newtonsoft.json and system.text.json


@ctid402288

ctid402288
14 Dec 2024, 18:54

Line of code

Print("[OnStart] Account \n: " + Account.ToJSON());

Error message 

14/12/2024 15:40:13.003 | Info | ******************************************************
14/12/2024 15:40:13.066 | Info | [OnStart] {FormatException} Exception : Input string was not in a correct format. Failure to parse near offset 22. Expected an ASCII digit.

CTrader Desktop

OS - MACOS Apple Silicon M2

APP: Ctrader.Automate Version 1.0.9

Desktop Version - 5.0.22


@ctid402288

ctid402288
26 Nov 2024, 08:47 ( Updated at: 26 Nov 2024, 13:35 )

RE: RE: RE: cbot process unexpectedly terminated

ctid402288 said: 

PanagiotisCharalampous said: 

ctid402288 said: 

After a reboot on my machine, upon restarting my cbot l am now experiencing this issue.

21/08/2024 00:33:20.000 | Error | CBot instance [USDCHF, m30] process was unexpectedly terminated.

I have checked all timeout settings of downstream applications and have found they are generously set. Including  HTTP Timeout setting for RestSharp etcThey are all set for long running connections. I cannot understand why CTrader is dropping connection immediately after the connection is established. Please can you help. 

Hi there,

Could you please send us some troubleshooting information the next time this happens? Please paste a link to this discussion inside the text box before you submit it.

Best regards,

Panagiotis


 

I have reverted to CTrader version 4.8(909) and the cbot is working fine on there. I think there is a bug in version 5.0. I need version 5.0 because it is the only version on MacOS with backtesting capability. I would be eternally grateful if you could you sort it out please.

I have reinstalled Ctrader for mac version 5.0.22 and ran the cbot under backtesting and the error has emerged.  See screenshot attached. There id a comms bug in Version 5.0.


@ctid402288

ctid402288
26 Nov 2024, 08:28 ( Updated at: 26 Nov 2024, 13:35 )

RE: RE: cbot process unexpectedly terminated

PanagiotisCharalampous said: 

ctid402288 said: 

After a reboot on my machine, upon restarting my cbot l am now experiencing this issue.

21/08/2024 00:33:20.000 | Error | CBot instance [USDCHF, m30] process was unexpectedly terminated.

I have checked all timeout settings of downstream applications and have found they are generously set. Including  HTTP Timeout setting for RestSharp etcThey are all set for long running connections. I cannot understand why CTrader is dropping connection immediately after the connection is established. Please can you help. 

Hi there,

Could you please send us some troubleshooting information the next time this happens? Please paste a link to this discussion inside the text box before you submit it.

Best regards,

Panagiotis


 

I have reverted to CTrader version 4.8(909) and the cbot is working fine on there. I think there is a bug in version 5.0. I need version 5.0 because it is the only version on MacOS with backtesting capability. I would be eternally grateful if you could you sort it out please.


@ctid402288

ctid402288
26 Nov 2024, 00:25 ( Updated at: 26 Nov 2024, 00:28 )

cbot process unexpectedly terminated

After a reboot on my machine, upon restarting my cbot l am now experiencing this issue.

21/08/2024 00:33:20.000 | Error | CBot instance [USDCHF, m30] process was unexpectedly terminated.

I have checked all timeout settings of downstream applications and have found they are generously set. Including  HTTP Timeout setting for RestSharp etcThey are all set for long running connections. I cannot understand why CTrader is dropping connection immediately after the connection is established. Please can you help. 


@ctid402288

ctid402288
21 Jan 2024, 19:20 ( Updated at: 22 Jan 2024, 06:38 )

RE: RE:

ctid402288 said: 

PanagiotisChar said:

Hi there,

I don't know how it works in Python, but in .Net you need to loop through the list and add the symbols one by one.

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 

That was precisely what l had to do to move forward in the end. Thank you for your response.

Hi, please can you share what you did. I get ProtoAOSymbol object is not iterable error when l try to loop through the message data. Thanks.


@ctid402288

ctid402288
08 Feb 2023, 15:10

RE:

PanagiotisChar said:

Hi there,

I don't know how it works in Python, but in .Net you need to loop through the list and add the symbols one by one.

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 

That was precisely what l had to do to move forward in the end. Thank you for your response.


@ctid402288

ctid402288
25 Jan 2023, 14:37 ( Updated at: 25 Jan 2023, 15:45 )

Check this thread below

 

 

The Klein sample does not work properly, use the console sample and adapt it to your code. You also need a broker to authorize your CTrader account to access the OpenAPI platform. If you are in the UK, you would have your work cut out finding such a broker. Having a CTrader account for desktop or Mobile Apps do not automatically grant you access to the OpenAPI service l have found. Contact your broker to negotiate access.


@ctid402288

ctid402288
25 Jan 2023, 14:06 ( Updated at: 07 Feb 2023, 11:50 )

RESOLVED

The solution was to define the redirect urls correctly. Your redirect should be set to http://localhost:5035/redirect for example. Or https://{your domain url}:[your preferred port}/redirect. Also bear in mind that the OpenAPI Client requires two loops of authentication to get going. You application have to authenticate via Oauth, thereafter, the application also need to authenticate the Account you wish to use for trading. The OAuth authentication requires you to log into the OpenAPI platform and authorize your application to access the platform. This act issues an Authcode to your application which it uses to obtain an Access Token to complete the authentication. From here on, the fun begins.

 

Thank you for your help PanagiotisChar.

 

 

 


@ctid402288

ctid402288
19 Jan 2023, 19:37 ( Updated at: 21 Dec 2023, 09:23 )

RE:

PanagiotisChar said:

Hi there, 

The samples definitely work, probably you are doing something wrong in the process. Try asking in the samples GitHub repository too, maybe you will get some help by Python users.

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

I have retried the Klein sample and it does not work. The basic example on the Python SDK page connects successfuly with my credentials. But it does not carry out a OAuth authentication that

should provide an Authcode. The Console sample successfully conducted a basic OAuth authentication but failed due to redirect URL.

The default redirect URL for the application is as shown below. The authentication process only works when l use the "https://openapi.ctrader.com/apps/4012/playground" redirect URL which fails to provide an Authcode. I have added the second redirect URL which unfortunately produces the error in the image above. Any other permutation of the redirect URL produces the errors that l previously mentioned in my previous posts. I am guessing that this is the case because l do not have a live account yet.

 


@ctid402288

ctid402288
17 Jan 2023, 12:49 ( Updated at: 17 Jan 2023, 12:50 )

RE:

PanagiotisChar said:

Hi there, 

I am not familiar with Python, sorry :(

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

Has anyone ever connected to the CTrader Open Api successfully using Python or the samples offered on the Applications website, l wonder? I am hopeful that those samples has been tested and are fit for purpose. My expectation is that they should be able to establish a connection to the OpenApi platform. 


@ctid402288

ctid402288
16 Jan 2023, 18:32 ( Updated at: 21 Dec 2023, 09:23 )

RE:

PanagiotisChar said:

Hi there, 

This is a different message than the one you posted above. At which point do you get this? Maybe you can record a video or share some screenshots.

You are definitely doing something wrong, if there was a problem on the servers, there would have been hundreds of complaints.

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

Hi there,

I am using the python example based on Klein and Twister to verify the connection. The information provided is from the initial stages of the code as shown below:-

I have adapted this code to test the authentication and the result is what l posted previously. My code is based on the same principle but using flask and connextion. The result is the same. It is probable that the server version has moved on and the sample code is no longer valid. If that is the case, please can you advice me on what has changed?

 

Regards

AO


@ctid402288

ctid402288
16 Jan 2023, 18:32

RE:

PanagiotisChar said:

Hi there, 

This is a different message than the one you posted above. At which point do you get this? Maybe you can record a video or share some screenshots.

You are definitely doing something wrong, if there was a problem on the servers, there would have been hundreds of complaints.

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

Hi there,

 

 


@ctid402288

ctid402288
16 Jan 2023, 18:32

RE:

PanagiotisChar said:

Hi there, 

This is a different message than the one you posted above. At which point do you get this? Maybe you can record a video or share some screenshots.

You are definitely doing something wrong, if there was a problem on the servers, there would have been hundreds of complaints.

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

Hi there,

 

 


@ctid402288

ctid402288
16 Jan 2023, 18:32

RE:

PanagiotisChar said:

Hi there, 

This is a different message than the one you posted above. At which point do you get this? Maybe you can record a video or share some screenshots.

You are definitely doing something wrong, if there was a problem on the servers, there would have been hundreds of complaints.

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

Hi there,

 

 


@ctid402288

ctid402288
14 Jan 2023, 23:02 ( Updated at: 14 Jan 2023, 23:14 )

RE:

PanagiotisChar said:

Hi there, 

The client ID you are using does not seem correct to me

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 

This is the full URI:-

authUri: https://openapi.ctrader.com/apps/auth?client_id=4012_1kzEubcpMG4qFkGmyWjGxvL94iU5eJVSs9jz1xvGTlAbZuQxo3&redirect_uri=http://demo-eu.ctraderapi.com:5035/redirect&scope=trading

authcode: {'errorCode': 'ACCESS_DENIED', 'description': 'Access denied. Make sure the credentials are valid.'}

 

The account is active and the credentials is valid, l checked before putting up this post. There appears to be something wrong at the server end.


@ctid402288

ctid402288
09 Jan 2023, 15:58 ( Updated at: 21 Dec 2023, 09:23 )

RE:

ctid402288 said:

AuthURI is https://openapi.ctrader.com/apps/auth?client_id=4012_1kzE&redirect_uri=http://demo-eu.ctraderapi.com:5035/redirect&scope=trading

I already tried that and got the following Auth error:- {'errorCode': 'ACCESS_DENIED', 'description': 'Access denied. Make sure the credentials are valid.'} The AUTHURI is as follows https://openapi.ctrader.com/apps/auth?client_id=4012_1kzE&redirect_u

I have ran the code with a manually generated set of tokens from the Applications site but Twisted is unable to establish a connection due to the credential issue. l get the following error mesage:

twisted.internet.error.CannotListenError: Couldn't listen on demo-eu.ctraderapi.com:5035: [Errno 49] Can't assign requested address.

And it perpetually tries to reconnect

2023-01-09 14:05:31+0000 [-] Scheduling retry 2 to connect <twisted.internet.endpoints.SSL4ClientEndpoint object at 0x16f804070> in 2.7144583928643655 seconds.

The issue might be with the credential which incidentally has a status of ACTIVE.

 

PanagiotisChar said:

Hi there, 

The client ID is taken from your Open API application

Can you provide us with the exact uri you are using for your request?

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 

 

 


@ctid402288

ctid402288
09 Jan 2023, 15:55

The fix for this is to install OpenSSL

pip3 install pyOpenSSL


@ctid402288