Python 3.9
This page describes the steps to test your strategy in paper trading mode in Python 3.9
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 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 method will be executed when you set your launchMode to PaperTrading 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 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.
Updated about 3 years ago