- Getting Started
- What is Investfly?
-
User Management
-
Market Analysis
-
Trading
-
Automated Strategies
-
Logical Expressions
- Custom Indicators
- Investfly SDK API Docs
Working with Automated Trading Strategy
Read Automation Concepts first if you haven’t already.
Once the trading strategy is defined, you will use the strategy details page to update, run backtests, and deploy your algorithmic trading strategy.
Access Strategy Detail Page
- Access the strategy list table.
- Click on the strategy name.
Updating Strategy
You can update any part of the automated trading strategy definition, including entry and exit conditions. To update:
- Access the strategy detail page as described above.
- Click on the pencil icon in the section you want to update.
- A dialog (the same screen you used to define the strategy) will appear.
- Modify as needed.
- Click on Save on the dialog to close it.
- The strategy is still not saved on the server yet. This allows you to modify multiple sections and finally click Save.
- Click on the Save button at the top.
Backtesting Trading Strategy
Investfly allows you to backtest your automated trading strategy with historical data. When you backtest, Investfly will step through historical data, evaluate your entry and exit conditions, and submit trades on a simulated account. Backtesting is only supported for stock trading strategies (not supported for option trading strategies).
-
Duration of Backtest
The time frame for backtesting depends on the bar size parameters used to define your entry and exit conditions. If the strategy only has DAILY bars, the backtest will run with the last 5 years of data. This means the backtest will step through 5 years x 252 trading days per year = 1260 data points. However, if the strategy has MINUTE bars, running through minute-by-minute data for the last 5 years will take a very long time. Therefore, it will only run with the last 5 days of minute-bars. This means the backtest will step through 5 days x 390 minutes per day = 1950 data points. In both cases, the backtest should finish in less than 5 minutes.
-
Reliability of Backtest Results
The results of a backtest provide some hints as to whether the strategy might work, but they should not be interpreted as a guarantee that the strategy will work. This is mainly because:
- Historical performance does not guarantee future results.
- There is a difference in the granularity of data. In live trading, we have real-time quote streams, whereas in backtesting, it runs against 1-MINUTE bars.
- The non-deterministic nature of the strategy as described in Automation Concepts. If a set of 100 stocks match open conditions and you can only buy 10 of them, which of the matching stocks are bought is indeterministic due to parallel processing.
Repeating the same backtest on the same strategy could yield different results. This is good because if executions yield favorable results, it is a strong indication that your strategy works.
-
Starting and Stopping Backtest
- Access the strategy detail page as specified above.
- Click on the Start button in the backtest section.
- The backtest will go through the following states:
- QUEUED: The backtest is queued for execution by one of our backtest servers.
- INITIALIZING: Preparing the environment to start the backtest.
- RUNNING: The backtest is running.
- When the backtest is started, you can stop it at any time by clicking the STOP button.
-
Backtest Results
The results section displays standard metrics used to evaluate backtest results such as drawdown, profitable trade percent, etc. It also displays all trades that were made during the backtest run in a table.
Deploying Strategy
The final step is to deploy the automated trading strategy to a trading account so it can start making trades in your account. We recommend deploying to a virtual account first for some time and eventually deploying to a real broker account.
- Click on the Deploy button.
- Pick the trading account to which you want to deploy.
- Click ‘Confirm Deploy’.
Once deployed, the strategy will start evaluating your entry and exit criteria in real-time and generating trade signals. You can get deeper insights into how the strategy is working by monitoring automation logs as described in the Portfolio Dashboard.