.NET 5 & C#

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

Testing locally in Live Trading mode

You can test your strategy locally with live data in live trading mode by setting your launchMode parameter to LiveTrading. 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 and connect to your Algorum Quant Engine to test your strategy in Live Trading mode. This might be useful during debugging of your strategy in real time with real money.

Below code in Main.cs will be executed when you set your launchMode to LiveTrading 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 and the orders will be placed to the brokerage platform you specified in the StartTradingAsync method call.

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

Run your strategy in Live Trading mode on Algorum Cloud

Once you are done with local testing in live trading mode, you can publish your code to Algorum Cloud and you can run your strategy in live trading mode in Algorum Cloud using the strategy-start-live-trading CLI command. This command takes the strategy name, Brokerage API Key, Brokerage Secret Key (applicable for Alpaca users), other brokerage account authentication parameters, tick data sampling time in seconds and brokerage platform, and will run your strategy in live 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.