This article is part of a series looking into how the Auquan toolbox and template files work.

This function does exactly what it says on the label: it gets predictions. Specifically, the getPrediction function will combine all of the features you’ve created, plus any other logic you include, and calculate the predictions at each point in time. The getPrediction function will only use data up to that timestamp. This ensures that your prediction models don’t suffer from lookahead bias.

You can call your previously created features by referencing their featureId. For example, to use the moving average feature and a custom feature, you would write the following code:

def getPrediction(self, time, currentMarketFeatures, instrumentManager):

        # holder for all the instrument features
        lookbackInstrumentFeatures = instrumentManager.getLookbackInstrumentFeatures()

        ms5Data = lookbackInstrumentFeatures.getFeatureDf('ms_5')
        # dataframe for a historical instrument feature (ms_5 in this case).   
        # The index is the timestamps of atmost lookback data points. 
        # The last row of this data frame would contain the features
        # which are being calculated in this update cycle or for this time.
        # The second to last row (if exists) would have the features for the previous
        # time update.
        # The columns of this dataframe are the stock symbols/instrumentIds.

        ms5 = ms5Data.iloc[-1] 

        # This returns the value of the feature at the last time update
        # Returns a series with index as all the instrumentIds. 

        customData = lookbackInstrumentFeatures.getFeatureDf('my_custom_feature_key')
        custom = customData.iloc[-1]
        predictions = ms5 / custom 
        return predictions

Predictions from this function can be of many types:

  • You can calculate (predict) the FairValue of a parameter, for example, price.
  • You can predict the probability that price will increase in the future.
  • You can predict the ratio of price of two securities.
  • You can predict the ranking of a basket of securities.

Output of the prediction function is used by the toolbox to make further trading decisions via the execution system. In competitions, this function is called by the scorer to assess your strategy’s performance.


I'm the community lead at Auquan. Feel free to message me if you get into any problems. A fun fact about me is I actually studied medicine at university.


Leave a Reply

Your email address will not be published. Required fields are marked *