Python 3.9

This page describes the steps to test your strategy in live trading mode in Python 3.9

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 PyCharm 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 method will be executed when you set your launchMode to LiveTrading in your code, while testing the strategy locally. The start_trading 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.

tradingRequest = AlgorumQuantClient.algorum_types.TradingRequest(
  bk_api_key, bk_api_secret_key,
  client_code, password, two_factor_auth, sampling_time, brokerage_platform)
client.start_trading(tradingRequest)

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.