cbot licensig intergration

Created at 07 Feb 2024, 15:38
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!
FO

FOREXNUGGETS

Joined 24.12.2023

cbot licensig intergration
07 Feb 2024, 15:38


Greetings,

 

May you kindly check the below where l am going wrong or potential errors as when l try to intergrate with the cbot it begins to misfunction though the build was a success.

Also during back testing it stops opening orders.


using System;
using System.Net.Http;
using System.Threading.Tasks;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;

namespace Licensing
{
   public class LicenseValidator
   {
       private const string LicenseApiBaseUrl = "https://.............";

       public async Task<bool> ValidateLicense(string applicationId, string apiKey, string licenseSerialNumber)
       {
           var hostId = GenerateHostId();
           var deviceTag = GenerateDeviceTag();

           using (var client = new HttpClient())
           {
               var requestBody = $@"{{
                   ""app_id"": ""{applicationId}"",
                   ""api_key"": ""{apiKey}"",
                   ""host_id"": ""{hostId}"",
                   ""serial"": ""{licenseSerialNumber}"",
                   ""code"": ""2708231"",
                   ""version"": ""1.2"",
                   ""device_tag"": ""{deviceTag}""
               }}";

               var content = new StringContent(requestBody, System.Text.Encoding.UTF8, "application/json");

               var response = await client.PostAsync($"{LicenseApiBaseUrl}/licenses/valid", content);

               return response.IsSuccessStatusCode;
           }
       }

       public async Task<bool> CheckActivationStatus(string licenseSerialNumber, string applicationId, string apiKey)
       {
           using (var client = new HttpClient())
           {
               var response = await client.GetAsync($"{LicenseApiBaseUrl}/activations/{licenseSerialNumber}?app_id={applicationId}&api_key={apiKey}");

               return response.IsSuccessStatusCode;
           }
       }

       public async Task<bool> DeactivateActivation(string activationId, string applicationId, string apiKey)
       {
           using (var client = new HttpClient())
           {
               var response = await client.DeleteAsync($"{LicenseApiBaseUrl}/activations/{activationId}?app_id={applicationId}&api_key={apiKey}");

               return response.IsSuccessStatusCode;
           }
       }

       private string GenerateHostId()
       {
           return "GeneratedHostId";
       }

       private string GenerateDeviceTag()
       {
           return "GeneratedDeviceTag";
       }
   }

   

       private string licenseSerialNumber = "YourLicenseSerialNumber";
       private string applicationId = "YourApplicationId";
       private string apiKey = "YourApiKey";
       private string activationId = "GeneratedActivationId"; // Replace with your actual activation ID

       protected override void OnStart()
       {
           if (ValidateLicense().Result)
           {
               Positions.Closed += OnPositionsClosed;
               PlaceNextOrder();
           }
           else
           {
               Print("License validation failed. Please check your licensing.");
               Stop();
           }
       }

       private async Task<bool> ValidateLicense()
       {
           var licenseValidator = new LicenseValidator();
           return await licenseValidator.ValidateLicense(applicationId, apiKey, licenseSerialNumber);
       }


@FOREXNUGGETS
Replies

PanagiotisCharalampous
08 Feb 2024, 06:52

Hi there,

It seems you are using a third party licensing service which we are not familiar with. Maybe you should try contacting the licensing service provider first.

Best regards,

Panagiotis


@PanagiotisCharalampous

FOREXNUGGETS
08 Feb 2024, 07:58 ( Updated at: 08 Feb 2024, 09:41 )

RE: cbot licensig intergration

PanagiotisCharalampous said: 

Hi there,

It seems you are using a third party licensing service which we are not familiar with. Maybe you should try contacting the licensing service provider first.

Best regards,

Panagiotis

Greetings Panagiotis,

Thank you very much for the response.

l understand your response. in this case which licensing service providers are you familiar with perhaps l can check what they offer.


@FOREXNUGGETS

FOREXNUGGETS
08 Feb 2024, 07:58 ( Updated at: 08 Feb 2024, 09:41 )

RE: cbot licensig intergration

PanagiotisCharalampous said: 

Hi there,

It seems you are using a third party licensing service which we are not familiar with. Maybe you should try contacting the licensing service provider first.

Best regards,

Panagiotis

Greetings Panagiotis,

Thank you very much for the response.

l understand your response. in this case which licensing service providers are you familiar with perhaps l can check what they offer.


@FOREXNUGGETS

PanagiotisCharalampous
08 Feb 2024, 09:43

RE: RE: cbot licensig intergration

FOREXNUGGETS said: 

PanagiotisCharalampous said: 

Hi there,

It seems you are using a third party licensing service which we are not familiar with. Maybe you should try contacting the licensing service provider first.

Best regards,

Panagiotis

Greetings Panagiotis,

Thank you very much for the response.

l understand your response. in this case which licensing service providers are you familiar with perhaps l can check what they offer.

I haven't used one for ages and I would not be able to support you on that. For such integrations you should get support from the providers directly


@PanagiotisCharalampous