Strategy deployment

This page explains the process of deploying a strategy created on the SigTech platform to run in a live format, generating order outputs.

Good to know: strategies and other scripts can be deployed to Production using Framework v8, from the start of June 2022.

Procedure for deploying strategies

  1. Create the relevant strategy within a function.

  2. Convert the notebook file to a Python file.

  3. Commit and push the Python file to the repo.

  4. Deploy the strategy, in the Files tab.

Note: the deploying strategies feature is experimental, and is subject to continuous improvement.

Strategy requirements

Strategies on the SigTech platform can be deployed to be run continuously in a live fashion resulting in an output containing the orders from the strategy at the point in time from which its run. You can also specify the frequency at which the live strategy is run.

For a strategy to be deployed, there are a number of requirements to be met by the source code in the notebook that contains the strategy:

  1. The SigTech environment should not be initialised.

  2. The strategy to be deployed needs to be contained within a function that returns it.

  3. The function returning the strategy should be decorated with theStrategyJob decorator, with the relevant parameters passed into the decorator, such as defining the frequency of the strategy.

The following code block contains a short example of a BasketStrategy containing two RollingFutureStrategy constituents to be deployed:

import datetime as dtm

import sigtech.framework as sig

from sigtech.framework.strategies.runner.metaflow.decorators import StrategyJob
from sigtech.framework.default_strategy_objects.rolling_futures import gc_comdty_rici, si_comdty_pre_roll
from sigtech.framework.strategies.runner.output_types import ExecutedOrdersOutput,\
    DiagnosticsOutput, ParameterOutput, HistoryOutput, BottomPositionsOutput,\
    TradingInstrumentOutput, SerializationOutput, BottomOrdersOutput, \
    IntradayHistoryOutput, PositionsOutput


@StrategyJob(task_name='quick',
              enabled=True,
              schedule='50 16 ? * MON-FRI *',
              memory=1024, cpu=1, gpu=0,
              outputs=[HistoryOutput, BottomPositionsOutput, ExecutedOrdersOutput,
                       DiagnosticsOutput, ParameterOutput, IntradayHistoryOutput,
                       PositionsOutput, SerializationOutput, BottomOrdersOutput,
                       TradingInstrumentOutput])
def create_basket_strategy():
    return sig.BasketStrategy(
        currency='USD',
        start_date=dtm.date(2020, 1, 6),
        constituent_names=[
            gc_comdty_rici().name,
            si_comdty_pre_roll().name
        ],
        weights=[0.5, 0.5],
        rebalance_frequency='EOM'
    )

For the StrategyJob decorator, the schedule parameter will define the frequency at which the strategy will run where the parameter is a Cron expression defining the minute, hour and day.

Learn more: scheduling syntax

Convert to .py file

Note: this step can be skipped if the strategy to be deployed was created in a .py file directly.

If the strategy was created in a notebook, the .ipynb file must be converted to a .py file.

The conversion is made with the following script, which can be run inside the notebook itself:

!jupyter nbconvert --to script <notebook_name>.ipynb --output "<script_name>_job"

<notebook_name> is to be replaced with the filename of the .ipynb file, and <script_name> is to be replaced with the name of the .py file that is created.

A few further requirements:

  • The .py file needs to contain _job at the end of the filename. Example: if the notebook is called my_strategy.ipynb, then the .py file needs to be called my_strategy_job.py

  • The name of the .py file cannot contain any white spaces.

  • The nbconvert script needs to be removed from the .py file. Tip: check that the contents of the .py file are as expected.

Commit & push .py file to repo

To allow for the strategy to be deployed, it needs to be pushed to the user's repo.

Learn more: Git

Deploy strategy

Once the .py file has been pushed to the workspace repo, it is displayed in the Files tab.

Navigate to this tab, then click Deploy, next to the corresponding .py file.

Deployed strategies are displayed in the Strategies tab.

Strategies will run on the schedule defined in the parameters of the @StrategyJob decorator.

To perform an ad hoc calculation, click RUN NOW.

Note: a deployed strategy will run on the version of the framework that was used at the time of its deployment. To ensure a strategy runs on the latest framework it can be re-deployed following the framework update.

Deactivate

To deactivate a deployed strategy, set enable=False in the @StrategyJob decorator, then re-deploy the strategy.

Last updated

© 2023 SIG Technologies Limited