Alpha Streams

Upgrading Classic Algorithms

Upgrading Classic Algorithms

Introduction

With a few code adjustments, you can quickly turn a classic algorithm into an Alpha Streams capable strategy. The algorithm must emit Insight objects to be classified as an Alpha. When we deploy your classic algorithm into production all the trading and position management logic will be ignored.

Converting Classic Algorithms

There are only two steps required to convert your classic algorithm to be compatible with Alpha Streams. First you need to make it inherit from QCFrameworkBridge, and second, you need to modify your algorithm to emit Insight objects at an appropriate time in your algorithm.

Step 1: Inherit from QCFrameworkBridge

At the top of your algorithm, you'll likely have inherited from the QCAlgorithm base class. To start, you should modify this to extend from QCFrameworkAlgorithm.

// Step 1. Update base class from QCAlgorithm to QCAlgorithmFrameworkBridge
public class ConvertToFrameworkAlgorithm : QCAlgorithmFrameworkBridge
{
       ...
}
# Step 1. Update base class from QCAlgorithm to QCAlgorithmFrameworkBridge
class ConvertToFrameworkAlgorithm(QCAlgorithmFrameworkBridge):
       ....

Step 2: Call EmitInsights

Next, at appropriate points in your code, you need to call the function which generates trade signals for Funds following your strategy. Emitting Insight objects may line up with when you place trades. Take care in setting the insight properties and don't emit insights superfluously or they could negatively affect your overall score.

// 2. Call EmitInsights with insights created in correct direction, here we're going short
//    The EmitInsights method can accept multiple insights separated by commas
EmitInsights(
    // Creates an insight for our symbol, predicting that it will move down within
    // the fast ema period number of days
    Insight.Price(_symbol, TimeSpan.FromDays(FastEmaPeriod), InsightDirection.Down)
);
# Step 2. Call EmitInsights with insights created in correct direction,
# here we're going short. The EmitInsights method can accept multiple insights
# separated by commas.
self.EmitInsights(
    # Creates an insight for our symbol, predicting that it will move down within
    #  the fast ema period number of days
    Insight.Price(self.symbol, timedelta(self.FastEmaPeriod), InsightDirection.Down)
)

In creating these insights you should think about:

  • What is the time period of my insight / expected holding period?
  • Does my trade signal give me a confidence of investment?
  • What is the expected move magnitude?

If you cannot determine these values with some intrinsic data driven hypothesis we recommend leaving them unset.

Determining Insight Confidence and Magnitude

Your Insight period, magnitude and confidence are important properties that can be hard to generate when porting a classic algorithm. See the Creating Alpha section for more information.

You can also see our Tutorials and Videos. You can also get in touch with us via Chat.

Did you find this page Helpful ?