Skip to main content

Technical analysis library

Backtesting in qi uses the qi-ta library, which is a thin q wrapper around the widely used ta-lib. Functions like bbands and atr are drawn from here.

QSharpe

For backtesting, qi has its own Domain Specific Language (DSL) called qsharpe. Below is a sample qsharpe (.qs) file:

Parameters

Paramaters are stored in .params files, and have the same structure as .conf files, e.g.

Folder structure

In any given qi project, qi expects strategies to be stored in a strategies folder, under which are folders named after each strategy:

Running a strategy

To run a strategy do: q qi.q -strat mr1 -params v1 The -params argument is not required if there is only one .params file.

Shared logic

The folder strategies/common is reserved for functionality that can be used by all strategies. Under common, there can be two folders:
  • lib - for .qs files with common logic
  • params - common parameters

Example using shared logic

If we imagine that we have created the following shared folder:
We can then create the following:
and run q qi.q -strat mr2 which will use defaults.params from common, or we can do: q qi.q -strat mr2 -params passive Note: in this second case, defaults will still be used, but will be overriden by passive. If we now create a local params file so that we have:
and we now do q qi.q -strat mr2 The order of params files being loaded is:
  1. common/params/defaults.params
  2. mr2/custom.qs