Toolbox Breakdown: getPrediction  

  RSS

David
(@david)
Member Admin
Joined: 2 years ago
Posts: 27
13/01/2020 11:07 pm  

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 time stamp. 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.


Quote
Share:
  
Working

Please Login or Register