Going Live with a Strategy on Blueshift®¶
live mode, blueshift supports real time trading for supported
brokers (brokers that support real time updates on trades and
data through a streaming API). For details, check out
Trading real time with live mode.
The launch button¶
On the code editor or visual editor page you will see a button after the button, that will look like this .
Clicking on the button does a few things in sequence as described below.
A quick check of your strategy¶
If you are using a strategy created in the latest Blueshift version , a quick static analysis points out any issues in the code, if present. Otherwise, you can proceed to live trading stepper page as described in the next section.
For strategies created using earlier version, we carry out a quick automated static analysis of your strategy code to check if it is compatible with a live run1. The things we check for are
- All reference to
zipline(now deprecated) is caught and if possible, automatically converted to
- Disable API functions that are not applicable or irrelevant for a
live run. For example any occurrence of
set_account_currencymaybe automatically removed.
- Flag unsupported modules or functions from the existing backtest engine. This, of course, cannot be automatically moved as we cannot guarantee this will not break the rest of the code. You must remove them and adapt your strategy accordingly to continue to the live run.
The outcome of the static analysis is presented like below in a dialogue box.
Suggested changes are shown and highlighted in a context diff format as shown below.
Here original code is shown on the left hand side with lines to be removed highlighted in red. The replacement is shown on the right hand sides with suggested insertions in green. You must accept any changes suggested to continue. In case there are no requirements for any modification, or you are happy to accept the suggested changes, you can go to the next step.
Setting up the live run¶
Once the strategy passes through the static analysis, you will be redirected to the live site to choose your live run setup. It is a four step process
- Configure Settings - this is where you give general inputs about your live run configuration on the fly - for example, defining a new broker configuration.
- Select Algo Parameters - Here you provide the parameters for this
specific run - e.g. the
broker, the amount of
capitalallocated for this run etc. You must choose a day to terminate the algorithm, which can be no later than the nearest Friday close 2 (close of trading for the current week). You also may not launch an algo during the weekends (Saturdays and Sundays).
Choose execution mode - Blueshift support either automatic or user-confirmed execution mode, depending on the broker you have selected.
Accept Terms and Conditions - You must read and accept these to continue.
Review And Confirm - Review of the live run about to be launched and confirm the details. This will capture inputs like the entry point strategy, the broker details etc. Any requirements or instructions specific to this run will also be highlighted in red. You must ensure them for the live run to succeed3.
If everything goes well, you will land up in a new page that lists the new strategy run - the execution list page.
Monitoring and controlling your live runs¶
Once the algo is launched, you can see realtime updates on this on the algo console.
Apart from the
Console tab, The
Dashboard tab shows overall algo
performance in realtime as well as its risks and positions. The tab
Trades shows the details of trades/ orders and finally, the
tab shows an immutable copy of the algo code that is running.
To control the execution lifecycle, click
My Algo from the top menu
on the same page. This will show the execution list pages.
The execution list page shows all the strategies that are running live
now or were launched earlier (unless you
Click on a particular strategy to see more details on that - this takes
you back to the strategy page as before with the
Code tabs. On the list page,
Active tab shows the
currently running executions. Hit the
stop button to stop an execution (you can also stop an algorithm from
Dashboard page). The next tab on the list page
shows srategies that are currently terminated - either stopped by user
(grey), by some error (red) or after the execution reached its end date
(blue) as shown below.
On this page, you can also restart an execution that was previously
stopped (without any error!) - simply click the
Restart button and
follow the restarting steps.
Also, to reduce the clutter, you can archive your past algo runs. Algos
Archived cannot be restarted.
What can go wrong in the launch process¶
Many, but below are the major points to take care of
If your strategy is not compatible with live run, you will not be able to proceed further from the static analysis.
Set up the broker and other configuration carefully. The inputs will vary depending on the specific broker you are using. Make sure all the details are correct - e.g. your account number, your tokens etc.
Read and follow the instructions in red in the review sections. Some brokers may have specific instructions to launch the strategy successfully3.
Finally, make sure your strategy and broker and other parameters are consistent. For example, if your strategy trades only equities and you launch it with your Forex brokers, the result is uncertain. Also if you try to launch a strategy during a holiday, it may fail.
Caution: Algorithmic Trading
Algorithmic or program trading, while powerful, needs a careful, cautious approach. Automated trading is far from fire and forget. Many things can go wrong. While we try our best to catch and highlight such cases by design, nobody's perfect. Also there are things beyond control of Blueshift® that can go wrong:
- strategy code going rogue, firing numerous or spurious orders, or
- data feeds delivering corrupt data, or
- the broker connectivity unstable or even unavailable or
- an unexpected program crash and many, many more...
Be watchful and remember to take appropriate precautions and corrective measures when needed.