.NET 5 & C#

This page describes the steps to test your strategy in paper trading mode in .NET 5 & C#

Testing locally in Paper Trading mode

You can test your strategy locally with live data in paper trading mode by setting your launchMode parameter to PaperTrading. Rest of the parameters are same as the Backtesting mode (except for the start date and end date, which are not applicable for live/paper trading). You can run or debug your strategy straight from Visual Studio, PyCharm and connect to your Algorum Quant Engine to test your strategy in Paper Trading mode. This might be useful during debugging of your strategy in real time with virtual money.

Below code in Main.cs will be executed when you set your launchMode to PaperTrading in your appsettings.json, while testing the strategy locally. The StartTradingAsync method will take parameters like brokerage Api Key, Api Secret Key, other brokerage account authentication parameters, tick data sampling time in seconds and brokerage platform, and will initiate the strategy execution. After this method call your strategy will start receiving the real-time market data from Algorum Cloud.

await strategy.StartTradingAsync( new TradingRequest()
   ApiKey = bkApiKey,
   ApiSecretKey = bkApiSecretKey,
   ClientCode = clientCode,
   Password = password,
   TwoFactorAuth = twoFactorAuth,
   SamplingTimeInSeconds = samplingTime,
   BrokeragePlatform = brokeragePlatform
} );

Run your strategy in Paper Trading mode on Algorum Cloud

Once you are done with local testing in paper trading mode, you can publish your code to Algorum Cloud and you can run your strategy in paper trading mode in Algorum Cloud using the strategy-start-paper-trading CLI command. This command takes the strategy name, Brokerage API Key and Brokerage Secret Key (applicable for Alpaca users), and will run your strategy in paper trading mode. Like backtesting, the Algorum CLI shows up any stats and metrics that your strategy is publishing, and the log stream can show you the log messages from your strategy in real time.