Automated Trading

Overview

IQBroker can be used for automated trading. In this mode, you develop trading strategies (scripts) that automatically buy and sell instruments based on an algorithm.

Start an Automated Trading Portfolio

You can either create a new portfolio, or get started with one of the provided system portfolios.

For example, open the system portfolio "Bollinger Bands Support / Resistance":

The new portfolio looks like this:

The main sections are:

  • Portfolio Mode - switch among the main modes that are used to develop and run Automated Trading
  • Backtesting Settings - settings for the current mode (which is "Backtesting")
  • Portfolio Settings - common settings for the portfolio; they apply to all the modes
  • Run Portfolio - start or stop running the portfolio in the current mode
  • Portfolio Strategies - shows all of the trading strategies used in this portfolio
  • Backtesting Progress - shows progress while running the portfolio

The available modes are:

  • Backtesting - simulate the strategies by running them on historical market data. This mode is used to develop the strategies (by writing scripts).
  • Optimization - fine-tune the strategies by running hundreds or thousands of backtests, using many different combinations of parameters, to find the optimal set of parameters (usually, those that provide the most Net Profit).
  • Live Trading - run the strategies on the live market

Portfolio Settings

These settings apply to all of the modes.

Basic Tab


Start Date / End Date - when to start and end the simulation. (These settings don't exist in Live Trading.)

EOD Time - End-of-Day time: when strategy account snapshots are taken, and some portfolio-level scripts are invoked

Base Currency Code - used to unify calculations when symbols with different currencies are used

Advanced Tab

All of these settings are optional.

Commission - a script that calculates the brokerage commission of executed order fills

Dynamic Allocation - a script that redistributes cash between strategies based on their performance

Risk Management - a script that modifies or cancels orders based on portfolio-level risk analysis

Slippage - a script that simulates market slippage

Tax System - a script that reduces profit by calculating capital gains taxes


If you select a Dynamic Allocation script then a new tab appears: Transfers. It shows cash transfers between the strategies.

If you select a Tax System script then a new tab appears: Taxes. It shows the taxes that you would have to pay.

The Dynamic Allocation and Risk Management scripts are Portfolio-level. This means that they can take into account the performance of all of the active strategies; they're not restricted to a single strategy or symbol.

Data Tab

In order to perform Backtesting, IQBroker needs to load all of the necessary historical data from the data provider. For example, if the strategies use Day Bars then IQBroker needs to load EOD data for all of the symbols in the portfolio for the selected simulation date range. The Data tab shows the progress of loading this data.

IQBroker saves all of the data that it has loaded from the data provider on disk, so after loading the data for the first time only new data needs to be loaded.

Another issue is whether to keep all of the data in memory or not. Keeping the data in memory is recommended, because it makes repeated backtests and optimizations much faster. However, some large data sets may not fit in the computer's memory. In that case, the data must be loaded one small piece at a time.

Keep entire data in memory - when this option is enabled, the entire data for the backtest is kept in memory.This makes repeated backtests or optimizations faster. Disable this option only if you run out of memory.

Unload Data from Memory - if you need to free up memory then click this button

Backfill portfolio data automatically - when this option is enabled, IQBroker will try to load new data from the data provider whenever a Backtest is run

Backfill - click this button to load new data from the data provider immediately