1. Home
  2. Docs
  3. DLPAL S
  4. Quantopian code generation

Quantopian code generation

From the search or system tracking results select the strategies for code generation and click Quantopian Code.

An example of Quantopian code generation for selected strategies is shown below

The code generated may be saved by clicking on File and then Save.

You may copy and paste the code into a Quantopian strategy. Indentation is taken care off in the code but a few adjustments may be required.

In the case of strategies with a delay in trade input, all bars in the code are shifted according to the delay value. Therefore, the delay is already accounted for when a signal is generated.

Raw Code

Click on “Raw Code” from search results to generate raw code for selected strategies:

You may copy and paste the raw code in a line editor for further manipulation. Raw code is also generated automatically and saved in two text files. Each line in the files contains the following:

Strategy Code;File;Type;TradeOn,Target;Stop;C

where File is the filename, Type is LONG OR SHORT, TradeOn is Open or Close, Target is the profit target, stop is the stop-loss and C is % or pts. Strategy Code is the formula code used by the native language of the various supported platforms.

The raw code generation applies only to the Search and Database results. Two files with identical content are saved automatically in sub-directory Results:

(1) A file called GeneratedCode.txt which is overwritten every time new code is generated.

(2) A file with the name: RawCode_mm_dd_yyyy_hh_mm.txt

This file is overwritten only if new code generation takes place during the same minute mm that the file was initially generated.

The text files containing raw code can be deleted using a new tool added to File Maintenance under Results and called “Code .TXT FILES”.

System Code

Click on “System Code” to generate system code for selected strategies:



– System code can be generated only when there is one symbol (data file) in results and with strategies that have the same exit parameters. If there several symbols, results for each can be saved in a different results file to   be used for code generation.
– On Quantopian strategy the exits are evaluated on 1-minute data.
– In the case of intraday strategies, the frequency of data must be changed in the code