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.
- 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.
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 meet 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 the
StrategyJobdecorator, 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
RollingFutureStrategyconstituents 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, \
schedule='50 16 ? * MON-FRI *',
memory=1024, cpu=1, gpu=0,
outputs=[HistoryOutput, BottomPositionsOutput, ExecutedOrdersOutput,
DiagnosticsOutput, ParameterOutput, IntradayHistoryOutput,
PositionsOutput, SerializationOutput, BottomOrdersOutput,
start_date=dtm.date(2020, 1, 6),
scheduleparameter will define the frequency at which the strategy will run where the parameter is a Cron expression defining the minute, hour and day.
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
_jobat the end of the filename. Example: if the notebook is called
my_strategy.ipynb, then the .py file needs to be called
- The name of the .py file cannot contain any white spaces.
nbconvertscript needs to be removed from the .py file. Tip: check that the contents of the .py file are as expected.
To allow for the strategy to be deployed, it needs to be pushed to the user's repo.
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
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.
To deactivate a deployed strategy, set
@StrategyJobdecorator, then re-deploy the strategy.