.NET 5 & C#

This page guides you through the steps required to backtest your strategy in Algorum Cloud in .NET 5 & C#

Now that you have tested your strategy logic locally, let us deploy it onto Algorum Cloud for faster and reliable backtesting.

Create Docker Image for your strategy

Algorum runs your strategy in Algorum Cloud using Docker Image of your strategy. So, first step is to download and install the Docker Desktop for your OS. Once the Docker Desktop is installed on your system, then create a docker image for your strategy. Add a Docker Support from the project menu of your Visual Studio project (Right Click on the project and go into Add menu and click on the Docker Support menu item), with Linux as OS, and it adds all the necessary docker file commands to create a docker image of your strategy.

Docker file sample

FROM mcr.microsoft.com/dotnet/runtime:5.0 AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY ["Algorum.Strategy.GoldenCrossover/Algorum.Strategy.GoldenCrossover.csproj", "Algorum.Strategy.GoldenCrossover/"]
RUN dotnet restore "Algorum.Strategy.GoldenCrossover/Algorum.Strategy.GoldenCrossover.csproj"
COPY . .
WORKDIR "/src/Algorum.Strategy.GoldenCrossover"
RUN dotnet build "Algorum.Strategy.GoldenCrossover.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Algorum.Strategy.GoldenCrossover.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Algorum.Strategy.GoldenCrossover.dll"]

Right Click on the Docker file added to your project and use Build Docker Image menu to build docker image for your strategy project. This will build a docker image with the image name as algorumstrategygoldencorssover. The docker image name is the name of your project without the spaces and all lowercase.

Now that you have your strategy docker image, let us see how to create a strategy container in Algorum Cloud and upload your strategy docker image to it.

Create Strategy in Algorum Cloud

Using Algorum CLI strategy-create command, you can create your strategy container in Algorum Cloud. This command just needs a strategy name and an optional description.

977

Algorum CLI - Create a Strategy

Upload Strategy Docker Image to your Strategy in Algorum Cloud

After a strategy is created in Algorum Cloud, upload your strategy docker image from your local system to Algorum Cloud using the strategy-package-push command. This command takes the name of the strategy in Algorum Cloud where you wan to push your docker images, and the docker image name from your local docker repository. If you want to see the list of docker images in your local docker repository use the docker-images Algorum CLI command.

976

Algorum CLI - Uploading Strategy Docker Image

Starting backtest for your strategy in Algorum Cloud

Use strategy-backtest command to start the backtest for your strategy. This command takes strategy name, backtesting start date, end date and brokerage API Key and Secret Key (applicable in Alpaca Brokerage Platform users). It will start the backtest on Algorum Cloud, and will keep pushing the progress and metrics events to the Algorum CLI console.

977

Algorum CLI - Backtesting a Strategy

Trouble shoot strategy backtest start-up problems

In case you are seeing that the backtest starting is taking time and you are not seeing the backtest progress or log stream (View real time Log Stream of your strategy), there could be some error in your strategy code. You can get the raw logs of your strategy container deployed in Algorum Cloud using the log-raw-download Algorum CLI command. These logs are captured from your strategy container on the Algorum Cloud and could possible provide information on why the strategy backtest is not started/running as expected.