Skip to content

Commit 9aa534c

Browse files
authored
CNT-663: Add Compilation Robot (spotware#29)
1 parent 7668e8d commit 9aa534c

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed

Robots/.samples.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565
{
6666
"name": "Commodity Channel Index Sample"
6767
},
68+
{
69+
"name": "Compilation Robot"
70+
},
6871
{
6972
"name": "CoordinatesConversion Sample"
7073
},
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30011.22
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Compilation Robot", "Compilation Robot\Compilation Robot.csproj", "{569816c4-6ab8-4c81-aa59-b13056da93b1}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{569816c4-6ab8-4c81-aa59-b13056da93b1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{569816c4-6ab8-4c81-aa59-b13056da93b1}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{569816c4-6ab8-4c81-aa59-b13056da93b1}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{569816c4-6ab8-4c81-aa59-b13056da93b1}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// -------------------------------------------------------------------------------------------------
2+
//
3+
// This code is a cTrader Algo API example.
4+
//
5+
// The code is provided as a sample only and does not guarantee any particular outcome or profit of any kind. Use it at your own risk.
6+
//
7+
// This example cBot generates and saves algorithms by compiling .csproj files.
8+
//
9+
// -------------------------------------------------------------------------------------------------
10+
11+
12+
13+
14+
using System;
15+
using cAlgo.API;
16+
using cAlgo.API.Collections;
17+
using cAlgo.API.Indicators;
18+
using cAlgo.API.Internals;
19+
20+
namespace cAlgo.Robots
21+
{
22+
[Robot(AccessRights = AccessRights.FullAccess)]
23+
public class CompilationRobot : Robot
24+
{
25+
26+
protected override void OnStart()
27+
{
28+
CompilationOptions options = new CompilationOptions
29+
{
30+
IncludeSourceCode = true,
31+
OutputAlgoFilePath = @"C:\Users\{preferred path}\NameOfAlgo.algo"
32+
};
33+
34+
CompilationResult resultSync = Compiler.Compile(@"C:\Users\{path to project}\NameOfCbot.csproj", options);
35+
Print(resultSync.Succeeded);
36+
}
37+
}
38+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net6.0</TargetFramework>
4+
</PropertyGroup>
5+
6+
<ItemGroup>
7+
<PackageReference Include="cTrader.Automate" Version="*" />
8+
</ItemGroup>
9+
</Project>

0 commit comments

Comments
 (0)