Algo Compiler v8 for Cloud?

Created at 02 Sep 2024, 20:36
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
EL

elia.morling

Joined 02.09.2024

Algo Compiler v8 for Cloud?
02 Sep 2024, 20:36


In the cTrader app on Mac, I am being asked to install .NET SDK to compile cbot algos. It wants to install V8, but the cTrader Cloud uses V6? When I compile with V8 I get errors in the Cloud. When I uninstall V8 and install V6 it doesnt show int he cTrader app? Very confusing.


@elia.morling
Replies

PanagiotisCharalampous
03 Sep 2024, 05:56

Hi there,

Can you describe your problem using screenshots so that we can understand what you are looking at?

Best regards,

Panagiotis


@PanagiotisCharalampous

elia.morling
03 Sep 2024, 10:14 ( Updated at: 03 Sep 2024, 11:37 )

RE: Algo Compiler v8 for Cloud?

PanagiotisCharalampous said: 

Hi there,

Can you describe your problem using screenshots so that we can understand what you are looking at?

Best regards,

Panagiotis

Sorry, seems like compiled v8 works in Cloud. Issue is rather with the code itself, which may run locally but not in Cloud.

A few follow up quetions:
1. Is there sample of a script which can run in Cloud and able to call external service (assuming it needs to be web socket and port 25345)?
2. How to debug cbots in cloud? I am not seeing any errors whatsoever?


@elia.morling

elia.morling
03 Sep 2024, 10:14 ( Updated at: 03 Sep 2024, 11:37 )

RE: Algo Compiler v8 for Cloud?

PanagiotisCharalampous said: 

Hi there,

Can you describe your problem using screenshots so that we can understand what you are looking at?

Best regards,

Panagiotis

Sorry, seems like compiled v8 works in Cloud. Issue is rather with the code itself, which may run locally but not in Cloud.

A few follow up quetions:
1. Is there sample of a script which can run in Cloud and able to call external service (assuming it needs to be web socket and port 25345)?
2. How to debug cbots in cloud? I am not seeing any errors whatsoever?


@elia.morling

PanagiotisCharalampous
03 Sep 2024, 11:44

RE: RE: Algo Compiler v8 for Cloud?

elia.morling said: 

PanagiotisCharalampous said: 

Hi there,

Can you describe your problem using screenshots so that we can understand what you are looking at?

Best regards,

Panagiotis

Sorry, seems like compiled v8 works in Cloud. Issue is rather with the code itself, which may run locally but not in Cloud.

A few follow up quetions:
1. Is there sample of a script which can run in Cloud and able to call external service (assuming it needs to be web socket and port 25345)?
2. How to debug cbots in cloud? I am not seeing any errors whatsoever?

Hi there,

Unfortunately I do not have an example script for you. You can see your cloud instance's log in the Instance Information tab 


@PanagiotisCharalampous

elia.morling
03 Sep 2024, 19:54

RE: RE: RE: Algo Compiler v8 for Cloud?

Thanks, yes I found this tab.

The code below works perfectly locally. All it does it connect to a websocket, and prints OnStart…

When I run this in the cloud I get no errors, and no prints either. Should I not see a Print statement with this?


using System;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo.Robots
{
    [Robot(AccessRights = AccessRights.None, AddIndicators = true)]
    public class AlgoBot2 : Robot
    {
        
        // Defining the necessary WebSocketClientOptions
        private static WebSocketClientOptions _webSocketClientOptions = new WebSocketClientOptions 
        {
            KeepAliveInterval = new TimeSpan(0, 1, 30),
            UseDefaultCredentials = true,
        };
        
        // Initialising the WebSocketClient
        private WebSocketClient _webSocketClient = new WebSocketClient(_webSocketClientOptions);
        
        // Defining the target URI where the AI service is available
        private readonly Uri _targetUri = new Uri("wss://custom-subdomain.loca.lt");
 
        protected override void OnStart()
        {
            Print("OnStart...");
            
            _webSocketClient.Connect(_targetUri);
            
            // Serialize JSON data
            string jsonMessage = System.Text.Json.JsonSerializer.Serialize(new { hello = "world" });
            _webSocketClient.Send(jsonMessage);
            
            _webSocketClient.TextReceived += webSocketClient_TextReceived;
        }

        protected override void OnBarClosed()
        {
            // Attaining data for the current bar that has just closed
            // and the preceding bar
            var currentBar = Bars.LastBar;
            var previousBar = Bars.Last(Bars.Count - 2);
            
            // Creating a prompt for market analysis based on bar data
            string marketPrompt = @$"
            For the current bar, the high, low, open, and close were the following:
            {currentBar.High}, {currentBar.Low}, {currentBar.Open}, {currentBar.Close}. For the previous bar,
            these values were {previousBar.High}, {previousBar.Low}, {previousBar.Open}, {previousBar.Close}.
            Make predictions about the future.
            ";
            
            // Sending the new prompt to the AI service
            _webSocketClient.Send(marketPrompt);
        }

        protected void webSocketClient_TextReceived(WebSocketClientTextReceivedEventArgs obj)
        {
            Print("Received message");
        }

        protected override void OnStop()
        {
            // Disposing of the WebSocketClient to avoid memory leaks
            _webSocketClient.Close(WebSocketClientCloseStatus.NormalClosure);
        }
    }
}

@elia.morling

PanagiotisCharalampous
04 Sep 2024, 05:55

RE: RE: RE: RE: Algo Compiler v8 for Cloud?

elia.morling said: 

Thanks, yes I found this tab.

The code below works perfectly locally. All it does it connect to a websocket, and prints OnStart…

When I run this in the cloud I get no errors, and no prints either. Should I not see a Print statement with this?

using System;using cAlgo.API;using cAlgo.API.Collections;using cAlgo.API.Indicators;using cAlgo.API.Internals;namespace cAlgo.Robots{    [Robot(AccessRights = AccessRights.None, AddIndicators = true)]    public class AlgoBot2 : Robot    {                // Defining the necessary WebSocketClientOptions        private static WebSocketClientOptions _webSocketClientOptions = new WebSocketClientOptions         {            KeepAliveInterval = new TimeSpan(0, 1, 30),            UseDefaultCredentials = true,        };                // Initialising the WebSocketClient        private WebSocketClient _webSocketClient = new WebSocketClient(_webSocketClientOptions);                // Defining the target URI where the AI service is available        private readonly Uri _targetUri = new Uri("wss://custom-subdomain.loca.lt");         protected override void OnStart()        {            Print("OnStart...");                        _webSocketClient.Connect(_targetUri);                        // Serialize JSON data            string jsonMessage = System.Text.Json.JsonSerializer.Serialize(new { hello = "world" });            _webSocketClient.Send(jsonMessage);                        _webSocketClient.TextReceived += webSocketClient_TextReceived;        }        protected override void OnBarClosed()        {            // Attaining data for the current bar that has just closed            // and the preceding bar            var currentBar = Bars.LastBar;            var previousBar = Bars.Last(Bars.Count - 2);                        // Creating a prompt for market analysis based on bar data            string marketPrompt = @$"            For the current bar, the high, low, open, and close were the following:            {currentBar.High}, {currentBar.Low}, {currentBar.Open}, {currentBar.Close}. For the previous bar,            these values were {previousBar.High}, {previousBar.Low}, {previousBar.Open}, {previousBar.Close}.            Make predictions about the future.            ";                        // Sending the new prompt to the AI service            _webSocketClient.Send(marketPrompt);        }        protected void webSocketClient_TextReceived(WebSocketClientTextReceivedEventArgs obj)        {            Print("Received message");        }        protected override void OnStop()        {            // Disposing of the WebSocketClient to avoid memory leaks            _webSocketClient.Close(WebSocketClientCloseStatus.NormalClosure);        }    }}

Can you share a screenshot of the cBot log as well?


@PanagiotisCharalampous